From 4e3fa54ae25f54dde23b0669737dbb20d86f3cce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 12:22:08 +0200 Subject: [PATCH 1/6] split P60 dock HK into core and aux HK --- linux/devices/GPSHyperionLinuxController.cpp | 1 - mission/devices/ACUHandler.cpp | 9 +- mission/devices/ACUHandler.h | 2 + mission/devices/GomspaceDeviceHandler.cpp | 18 +- mission/devices/GomspaceDeviceHandler.h | 4 +- mission/devices/P60DockHandler.cpp | 175 +++++++++--------- mission/devices/P60DockHandler.h | 4 +- mission/devices/PDU1Handler.cpp | 10 +- mission/devices/PDU1Handler.h | 2 +- mission/devices/PDU2Handler.cpp | 10 +- mission/devices/PDU2Handler.h | 1 + .../devicedefinitions/GomspaceDefinitions.h | 50 +++-- mission/utility/compileTime.h | 113 ++++++----- 13 files changed, 205 insertions(+), 194 deletions(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index 34e02001..4ab0988b 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -3,7 +3,6 @@ #include "OBSWConfig.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" - #include "mission/utility/compileTime.h" #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 7c6e048c..3abe5f53 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -4,7 +4,7 @@ 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), + ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE), acuHkTableDataset(this) {} ACUHandler::~ACUHandler() {} @@ -39,6 +39,13 @@ void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pack #endif } +LocalPoolDataSetBase *ACUHandler::getDataSetHandle(sid_t sid) { + if (sid == acuHkTableDataset.getSid()) { + return &acuHkTableDataset; + } + return nullptr; +} + void ACUHandler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; acuHkTableDataset.read(); diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index f3af5eae..3b1feaf3 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -31,6 +31,8 @@ class ACUHandler : public GomspaceDeviceHandler { virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t* commandData, size_t commandDataLen) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + private: static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 25bde5db..26c09901 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -7,20 +7,14 @@ GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, uint16_t maxConfigTableAddress, - uint16_t maxHkTableAddress, uint16_t hkTableReplySize, - LocalPoolDataSetBase* hkTableDataset) + uint16_t maxHkTableAddress, uint16_t hkTableReplySize) : DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress), maxHkTableAddress(maxHkTableAddress), - hkTableReplySize(hkTableReplySize), - hkTableDataset(hkTableDataset) { + hkTableReplySize(hkTableReplySize) { 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() {} @@ -405,14 +399,6 @@ ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTa 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; - } -} - 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 3d50b27b..fedc91d9 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -39,7 +39,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { */ GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset); + uint16_t hkTableReplySize); virtual ~GomspaceDeviceHandler(); /** @@ -100,7 +100,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { */ virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0; - virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; + virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) = 0; /** * @brief Can be overriden by child classes to implement device specific commands. diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 455784fb..9a337687 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -6,9 +6,9 @@ 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) {} + P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE), + coreHk(this), + auxHk(this) {} P60DockHandler::~P60DockHandler() {} @@ -23,7 +23,7 @@ void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t * * Hk table will be sent to the commander if hk table request was not triggered by the * P60DockHandler itself. */ - handleDeviceTM(&p60dockHkTableDataset, id, true); + handleDeviceTM(&coreHk, id, true); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1 p60dockHkTableDataset.read(); @@ -73,8 +73,12 @@ void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t * void P60DockHandler::parseHkTableReply(const uint8_t *packet) { using namespace P60Dock; uint16_t dataOffset = 0; - PoolReadGuard pg(&p60dockHkTableDataset); - if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + PoolReadGuard pg0(&coreHk); + PoolReadGuard pg1(&auxHk); + if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or + pg1.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + coreHk.setValidity(false, true); + auxHk.setValidity(false, true); return; } /** @@ -83,129 +87,116 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { */ dataOffset += 12; for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) { - p60dockHkTableDataset.currents[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.currents[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; } for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) { - p60dockHkTableDataset.voltages[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.voltages[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; } for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) { - p60dockHkTableDataset.outputEnables[idx] = *(packet + dataOffset); + coreHk.outputEnables[idx] = *(packet + dataOffset); dataOffset += 3; } - p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 | + auxHk.bootcause = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + *(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); + coreHk.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); + auxHk.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); + auxHk.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.battMode = *(packet + dataOffset); + coreHk.battMode = *(packet + dataOffset); dataOffset += 3; - p60dockHkTableDataset.heaterOn = *(packet + dataOffset); + auxHk.heaterOn = *(packet + dataOffset); /* + 13 because here begins a new gomspace csp data field */ dataOffset += 13; - p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset); + auxHk.converter5VStatus = *(packet + dataOffset); dataOffset += 3; for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) { - p60dockHkTableDataset.latchups[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.latchups[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; } - p60dockHkTableDataset.dockVbatVoltageValue = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.dockVbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.dockVccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.dockVccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.batteryTemperature1 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.batteryTemperature2 = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; for (uint8_t idx = 0; idx < NUM_DEVS; idx++) { - p60dockHkTableDataset.devicesType[idx] = *(packet + dataOffset); + auxHk.devicesType[idx] = *(packet + dataOffset); dataOffset += 3; } for (uint8_t idx = 0; idx < NUM_DEVS; idx++) { - p60dockHkTableDataset.devicesStatus[idx] = *(packet + dataOffset); + auxHk.devicesStatus[idx] = *(packet + dataOffset); dataOffset += 3; } - p60dockHkTableDataset.dearmStatus = *(packet + dataOffset); + auxHk.dearmStatus = *(packet + dataOffset); dataOffset += 3; - p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 | - *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + auxHk.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); + auxHk.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); + auxHk.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); + auxHk.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); + auxHk.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); + auxHk.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); + auxHk.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); + auxHk.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); + auxHk.wdtCspLeft1 = *(packet + dataOffset); dataOffset += 3; - p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset); + auxHk.wdtCspLeft2 = *(packet + dataOffset); dataOffset += 3; - p60dockHkTableDataset.batteryChargeCurrent = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.batteryDischargeCurrent = - *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + auxHk.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - p60dockHkTableDataset.ant6Depl = *(packet + dataOffset); + auxHk.ant6Depl = *(packet + dataOffset); dataOffset += 3; - p60dockHkTableDataset.ar6Depl = *(packet + dataOffset); - p60dockHkTableDataset.setValidity(true, true); + auxHk.ar6Depl = *(packet + dataOffset); + coreHk.setValidity(true, true); + auxHk.setValidity(true, true); } ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, @@ -260,7 +251,8 @@ ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &local localDataPoolMap.emplace(pool::P60DOCK_ANT6_DEPL, new PoolEntry({0})); localDataPoolMap.emplace(pool::P60DOCK_AR6_DEPL, new PoolEntry({0})); - poolManager.subscribeForPeriodicPacket(p60dockHkTableDataset.getSid(), false, 10.0, false); + poolManager.subscribeForPeriodicPacket(coreHk.getSid(), false, 10.0, false); + poolManager.subscribeForPeriodicPacket(auxHk.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } @@ -268,16 +260,17 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { - PoolReadGuard pg(&p60dockHkTableDataset); - result = pg.getReadResult(); - if (result != HasReturnvaluesIF::RETURN_OK) { + PoolReadGuard pg0(&coreHk); + PoolReadGuard pg1(&auxHk); + if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or + pg1.getReadResult() != HasReturnvaluesIF::RETURN_OK) { break; } printHkTableSwitchIV(); return HasReturnvaluesIF::RETURN_OK; } case (GOMSPACE::PRINT_LATCHUPS): { - PoolReadGuard pg(&p60dockHkTableDataset); + PoolReadGuard pg(&auxHk); result = pg.getReadResult(); printHkTableLatchups(); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -296,25 +289,22 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { void P60DockHandler::printHkTableSwitchIV() { using namespace P60Dock; sif::info << "P60 Dock Info:" << std::endl; - sif::info << "Boot Cause: " << p60dockHkTableDataset.bootcause - << " | Boot Count: " << std::setw(4) << std::right << p60dockHkTableDataset.bootCount - << std::endl; - sif::info << "Reset Cause: " << p60dockHkTableDataset.resetcause - << " | Battery Mode: " << static_cast(p60dockHkTableDataset.battMode.value) - << std::endl; + sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right + << coreHk.bootCount << std::endl; + sif::info << "Reset Cause: " << auxHk.resetcause + << " | Battery Mode: " << static_cast(coreHk.battMode.value) << std::endl; sif::info << "SwitchState, Currents [mA], Voltages [mV]:" << std::endl; sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Dock VBAT VCC" << std::dec - << "| -, " << std::setw(4) << std::right << p60dockHkTableDataset.dockVccCurrent << ", " - << std::setw(5) << p60dockHkTableDataset.dockVbatVoltageValue << std::endl; + << "| -, " << std::setw(4) << std::right << auxHk.dockVccCurrent << ", " << std::setw(5) + << auxHk.dockVbatVoltageValue << std::endl; sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "BATT" << std::dec << "| -, " - << std::setw(4) << std::right << p60dockHkTableDataset.batteryCurrent.value << ", " - << std::setw(5) << p60dockHkTableDataset.batteryVoltage.value << std::endl; + << std::setw(4) << std::right << coreHk.batteryCurrent.value << ", " << std::setw(5) + << coreHk.batteryVoltage.value << std::endl; auto genericPrintoutHandler = [&](std::string name, uint8_t idx) { sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << name << std::dec << "| " - << unsigned(p60dockHkTableDataset.outputEnables[idx]) << ", " << std::setw(4) - << std::right << p60dockHkTableDataset.currents[idx] << ", " << std::setw(5) - << p60dockHkTableDataset.voltages[idx] << std::endl; + << unsigned(coreHk.outputEnables[idx]) << ", " << std::setw(4) << std::right + << coreHk.currents[idx] << ", " << std::setw(5) << coreHk.voltages[idx] << std::endl; }; genericPrintoutHandler("ACU VCC", hk::ACU_VCC); @@ -328,12 +318,21 @@ void P60DockHandler::printHkTableSwitchIV() { genericPrintoutHandler("Stack 5V", hk::STACK_5V); } +LocalPoolDataSetBase *P60DockHandler::getDataSetHandle(sid_t sid) { + if (sid == coreHk.getSid()) { + return &coreHk; + } else if (sid == auxHk.getSid()) { + return &auxHk; + } + return nullptr; +} + void P60DockHandler::printHkTableLatchups() { using namespace P60Dock; sif::info << "P60 Latchup Information" << std::endl; auto genericPrintoutHandler = [&](std::string name, uint8_t idx) { sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << name << std::dec << "| " - << std::setw(4) << std::right << p60dockHkTableDataset.latchups[idx] << std::endl; + << std::setw(4) << std::right << auxHk.latchups[idx] << std::endl; }; genericPrintoutHandler("ACU VCC", hk::ACU_VCC); genericPrintoutHandler("ACU VBAT", hk::ACU_VBAT); diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index b86f37bb..47484680 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -31,12 +31,14 @@ class P60DockHandler : public GomspaceDeviceHandler { * @return */ ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; void printHkTableSwitchIV(); void printHkTableLatchups(); private: - P60Dock::HkTableDataset p60dockHkTableDataset; + P60Dock::CoreHkSet coreHk; + P60Dock::HkTableDataset auxHk; static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 16; PoolEntry hkCurrents = PoolEntry(P60Dock::hk::CHNLS_LEN); diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index e0c369a3..be26d984 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -7,8 +7,7 @@ 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), + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE), pdu1HkTableDataset(this) {} PDU1Handler::~PDU1Handler() {} @@ -430,6 +429,13 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDat return HasReturnvaluesIF::RETURN_OK; } +LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { + if (sid == pdu1HkTableDataset.getSid()) { + return &pdu1HkTableDataset; + } + return nullptr; +} + ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 732c38d2..67afc922 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -36,7 +36,7 @@ class PDU1Handler : 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; - + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExectuion) override; private: diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 48e7f90e..69a8f3fd 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -7,8 +7,7 @@ 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), + PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE), pdu2HkTableDataset(this) {} PDU2Handler::~PDU2Handler() {} @@ -54,6 +53,13 @@ void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, vo this->hookArgs = args; } +LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) { + if (sid == pdu2HkTableDataset.getSid()) { + return &pdu2HkTableDataset; + } + return nullptr; +} + void PDU2Handler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; pdu2HkTableDataset.read(); diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index ca639568..ab113dda 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -36,6 +36,7 @@ class PDU2Handler : 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, bool afterExecution) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; private: static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 24; diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 3a66ca69..4b277b40 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -351,7 +351,9 @@ static const uint16_t MAX_CONFIGTABLE_ADDRESS = 408; static const uint16_t MAX_HKTABLE_ADDRESS = 187; static const uint16_t HK_TABLE_SIZE = 188; -static const uint8_t HK_TABLE_DATA_SET_ID = 0x3; +static constexpr uint32_t CORE_TABLE_SET_ID = 0x3; +static constexpr uint32_t AUX_TABLE_DATA_SET_ID = 0x4; + static const uint8_t HK_TABLE_ENTRIES = 100; /** @@ -360,18 +362,11 @@ static const uint8_t HK_TABLE_ENTRIES = 100; */ static const uint16_t HK_TABLE_REPLY_SIZE = 407; -/** - * @brief This class defines a dataset for the hk table of the P60 Dock. - * @details - * 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 { +class CoreHkSet : public StaticLocalDataSet<16> { public: - HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} + CoreHkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CORE_TABLE_SET_ID) {} - HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} + CoreHkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CORE_TABLE_SET_ID)) {} /** Measured output currents */ lp_vec_t currents = @@ -387,22 +382,42 @@ class HkTableDataset : public StaticLocalDataSet { lp_vec_t outputEnables = lp_vec_t(sid.objectId, P60System::pool::OUTPUT_ENABLE, this); + lp_var_t bootCount = + lp_var_t(sid.objectId, P60System::pool::P60DOCK_BOOT_CNT, this); + lp_var_t battMode = + lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATT_MODE, this); + + // Difference between charge and discharge current + lp_var_t batteryCurrent = + lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATTERY_CURRENT, this); + lp_var_t batteryVoltage = + lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATTERY_VOLTAGE, this); lp_var_t temperature1 = lp_var_t(sid.objectId, P60System::pool::P60DOCK_TEMPERATURE_1, this); lp_var_t temperature2 = lp_var_t(sid.objectId, P60System::pool::P60DOCK_TEMPERATURE_2, this); +}; +/** + * @brief This class defines a dataset for the hk table of the P60 Dock. + * @details + * 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<32> { + public: + HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUX_TABLE_DATA_SET_ID) {} + + HkTableDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, AUX_TABLE_DATA_SET_ID)) {} lp_var_t bootcause = lp_var_t(sid.objectId, P60System::pool::P60DOCK_BOOT_CAUSE, this); - lp_var_t bootCount = - lp_var_t(sid.objectId, P60System::pool::P60DOCK_BOOT_CNT, this); lp_var_t uptime = lp_var_t(sid.objectId, P60System::pool::P60DOCK_UPTIME, this); lp_var_t resetcause = lp_var_t(sid.objectId, P60System::pool::P60DOCK_RESETCAUSE, this); - lp_var_t battMode = - lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATT_MODE, this); + /** Battery heater control only possible on BP4 packs */ lp_var_t heaterOn = lp_var_t(sid.objectId, P60System::pool::P60DOCK_HEATER_ON, this); @@ -418,11 +433,6 @@ class HkTableDataset : public StaticLocalDataSet { lp_var_t(sid.objectId, P60System::pool::P60DOCK_DOCK_VBAT, this); lp_var_t dockVccCurrent = lp_var_t(sid.objectId, P60System::pool::P60DOCK_DOCK_VCC_CURRENT, this); - // Difference between charge and discharge current - lp_var_t batteryCurrent = - lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATTERY_CURRENT, this); - lp_var_t batteryVoltage = - lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATTERY_VOLTAGE, this); lp_var_t batteryTemperature1 = lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATTERY_TEMPERATURE_1, this); diff --git a/mission/utility/compileTime.h b/mission/utility/compileTime.h index c55673f6..0e367248 100644 --- a/mission/utility/compileTime.h +++ b/mission/utility/compileTime.h @@ -5,14 +5,17 @@ * Authors: * * Assembled from the code released on Stackoverflow by: - * Dennis (instructable.com/member/nqtronix) | https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string + * Dennis (instructable.com/member/nqtronix) | + * https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string * and - * Alexis Wilke | https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date + * Alexis Wilke | + * https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date * * Assembled by Jean Rabault * - * UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of compilation from macros using the compiler defined __TIME__ macro. - * This should include Gregorian calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps. + * UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of + * compilation from macros using the compiler defined __TIME__ macro. This should include Gregorian + * calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps. * * Careful: __TIME__ is the local time of the computer, NOT the UTC time in general! * @@ -22,76 +25,66 @@ #define COMPILE_TIME_H_ // Some definitions for calculation -#define SEC_PER_MIN 60UL -#define SEC_PER_HOUR 3600UL -#define SEC_PER_DAY 86400UL -#define SEC_PER_YEAR (SEC_PER_DAY*365) +#define SEC_PER_MIN 60UL +#define SEC_PER_HOUR 3600UL +#define SEC_PER_DAY 86400UL +#define SEC_PER_YEAR (SEC_PER_DAY * 365) // extracts 1..4 characters from a string and interprets it as a decimal value -#define CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0) -#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0') -#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0') -#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0') +#define CONV_STR2DEC_1(str, i) (str[i] > '0' ? str[i] - '0' : 0) +#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i) * 10 + str[i + 1] - '0') +#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i) * 10 + str[i + 2] - '0') +#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i) * 10 + str[i + 3] - '0') // Custom "glue logic" to convert the month name to a usable number -#define GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \ - str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \ - str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \ - str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \ - str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \ - str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \ - str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \ - str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \ - str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \ - str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \ - str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \ - str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0) +#define GET_MONTH(str, i) \ + (str[i] == 'J' && str[i + 1] == 'a' && str[i + 2] == 'n' ? 1 \ + : str[i] == 'F' && str[i + 1] == 'e' && str[i + 2] == 'b' ? 2 \ + : str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'r' ? 3 \ + : str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'r' ? 4 \ + : str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'y' ? 5 \ + : str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'n' ? 6 \ + : str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'l' ? 7 \ + : str[i] == 'A' && str[i + 1] == 'u' && str[i + 2] == 'g' ? 8 \ + : str[i] == 'S' && str[i + 1] == 'e' && str[i + 2] == 'p' ? 9 \ + : str[i] == 'O' && str[i + 1] == 'c' && str[i + 2] == 't' ? 10 \ + : str[i] == 'N' && str[i + 1] == 'o' && str[i + 2] == 'v' ? 11 \ + : str[i] == 'D' && str[i + 1] == 'e' && str[i + 2] == 'c' ? 12 \ + : 0) // extract the information from the time string given by __TIME__ and __DATE__ -#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6) -#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3) -#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0) -#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4) -#define __TIME_MONTH__ GET_MONTH(__DATE__, 0) -#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7) +#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6) +#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3) +#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0) +#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4) +#define __TIME_MONTH__ GET_MONTH(__DATE__, 0) +#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7) // Days in February #define _UNIX_TIMESTAMP_FDAY(year) \ - (((year) % 400) == 0UL ? 29UL : \ - (((year) % 100) == 0UL ? 28UL : \ - (((year) % 4) == 0UL ? 29UL : \ - 28UL))) + (((year) % 400) == 0UL ? 29UL \ + : (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL))) // Days in the year -#define _UNIX_TIMESTAMP_YDAY(year, month, day) \ - ( \ - /* January */ day \ - /* February */ + (month >= 2 ? 31UL : 0UL) \ - /* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \ - /* April */ + (month >= 4 ? 31UL : 0UL) \ - /* May */ + (month >= 5 ? 30UL : 0UL) \ - /* June */ + (month >= 6 ? 31UL : 0UL) \ - /* July */ + (month >= 7 ? 30UL : 0UL) \ - /* August */ + (month >= 8 ? 31UL : 0UL) \ - /* September */+ (month >= 9 ? 31UL : 0UL) \ - /* October */ + (month >= 10 ? 30UL : 0UL) \ - /* November */ + (month >= 11 ? 31UL : 0UL) \ - /* December */ + (month >= 12 ? 30UL : 0UL) \ - ) +#define _UNIX_TIMESTAMP_YDAY(year, month, day) \ + (/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \ + (month >= 4 ? 31UL : 0UL) /* May */ + (month >= 5 ? 30UL : 0UL) /* June */ + \ + (month >= 6 ? 31UL : 0UL) /* July */ + (month >= 7 ? 30UL : 0UL) /* August */ + \ + (month >= 8 ? 31UL : 0UL) /* September */ + (month >= 9 ? 31UL : 0UL) /* October */ + \ + (month >= 10 ? 30UL : 0UL) /* November */ + (month >= 11 ? 31UL : 0UL) /* December */ + \ + (month >= 12 ? 30UL : 0UL)) // get the UNIX timestamp from a digits representation -#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ - ( /* time */ second \ - + minute * SEC_PER_MIN \ - + hour * SEC_PER_HOUR \ - + /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \ - + /* year */ (year - 1970UL) * SEC_PER_YEAR \ - + ((year - 1969UL) / 4UL) * SEC_PER_DAY \ - - ((year - 1901UL) / 100UL) * SEC_PER_DAY \ - + ((year - 1601UL) / 400UL) * SEC_PER_DAY \ - ) +#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ + (/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \ + /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY + \ + /* year */ (year - 1970UL) * SEC_PER_YEAR + ((year - 1969UL) / 4UL) * SEC_PER_DAY - \ + ((year - 1901UL) / 100UL) * SEC_PER_DAY + ((year - 1601UL) / 400UL) * SEC_PER_DAY) // the UNIX timestamp -#define UNIX_TIMESTAMP (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__)) +#define UNIX_TIMESTAMP \ + (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, \ + __TIME_MINUTES__, __TIME_SECONDS__)) #endif From 5e4c3728edb3abab62e0ac68b2e0ec9ff1a553db Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 12:53:51 +0200 Subject: [PATCH 2/6] split up p60 hk packets --- mission/devices/PCDUHandler.cpp | 10 ++-- .../devicedefinitions/GomspaceDefinitions.h | 55 ++++++++++--------- tmtc | 2 +- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index 44b9181a..c819b223 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -51,7 +51,8 @@ ReturnValue_t PCDUHandler::initialize() { return RETURN_FAILED; } result = pdu2Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU2::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + static_cast(P60System::SetIds::PDU_2), this->getObjectId(), commandQueue->getId(), + true); if (result != RETURN_OK) { sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " << "PDU2Handler" << std::endl; @@ -66,7 +67,8 @@ ReturnValue_t PCDUHandler::initialize() { return RETURN_FAILED; } result = pdu1Handler->getSubscriptionInterface()->subscribeForSetUpdateMessage( - PDU1::HK_TABLE_DATA_SET_ID, this->getObjectId(), commandQueue->getId(), true); + static_cast(P60System::SetIds::PDU_1), this->getObjectId(), commandQueue->getId(), + true); if (result != RETURN_OK) { sif::error << "PCDUHandler::initialize: Failed to subscribe for set update messages from " << "PDU1Handler" << std::endl; @@ -101,10 +103,10 @@ void PCDUHandler::readCommandQueue() { MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { - if (sid == sid_t(objects::PDU2_HANDLER, PDU2::HK_TABLE_DATA_SET_ID)) { + if (sid == sid_t(objects::PDU2_HANDLER, static_cast(P60System::SetIds::PDU_2))) { updateHkTableDataset(storeId, &pdu2HkTableDataset, &timeStampPdu2HkDataset); updatePdu2SwitchStates(); - } else if (sid == sid_t(objects::PDU1_HANDLER, PDU1::HK_TABLE_DATA_SET_ID)) { + } else if (sid == sid_t(objects::PDU1_HANDLER, static_cast(P60System::SetIds::PDU_1))) { updateHkTableDataset(storeId, &pdu1HkTableDataset, &timeStampPdu1HkDataset); updatePdu1SwitchStates(); } else { diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 4b277b40..93fe9e6b 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -43,6 +43,8 @@ static const DeviceCommandId_t PRINT_LATCHUPS = 33; namespace P60System { +enum class SetIds : uint32_t { PDU_1 = 1, PDU_2 = 2, P60_CORE = 3, P60_AUX = 4, ACU = 5 }; + namespace pool { enum Ids : lp_id_t { @@ -351,9 +353,6 @@ static const uint16_t MAX_CONFIGTABLE_ADDRESS = 408; static const uint16_t MAX_HKTABLE_ADDRESS = 187; static const uint16_t HK_TABLE_SIZE = 188; -static constexpr uint32_t CORE_TABLE_SET_ID = 0x3; -static constexpr uint32_t AUX_TABLE_DATA_SET_ID = 0x4; - static const uint8_t HK_TABLE_ENTRIES = 100; /** @@ -364,9 +363,11 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 407; class CoreHkSet : public StaticLocalDataSet<16> { public: - CoreHkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CORE_TABLE_SET_ID) {} + CoreHkSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::P60_CORE)) {} - CoreHkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CORE_TABLE_SET_ID)) {} + CoreHkSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::P60_CORE))) {} /** Measured output currents */ lp_vec_t currents = @@ -406,10 +407,16 @@ class CoreHkSet : public StaticLocalDataSet<16> { */ class HkTableDataset : public StaticLocalDataSet<32> { public: - HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUX_TABLE_DATA_SET_ID) {} + HkTableDataset(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::P60_AUX)) {} HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, AUX_TABLE_DATA_SET_ID)) {} + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::P60_AUX))) {} + + /** Number of detected latchups on each output channel */ + lp_vec_t latchups = + lp_vec_t(sid.objectId, P60System::pool::LATCHUPS, + this); lp_var_t bootcause = lp_var_t(sid.objectId, P60System::pool::P60DOCK_BOOT_CAUSE, this); @@ -424,11 +431,6 @@ class HkTableDataset : public StaticLocalDataSet<32> { lp_var_t converter5VStatus = lp_var_t(sid.objectId, P60System::pool::P60DOCK_CONV_5V_ENABLE_STATUS, this); - /** Number of detected latchups on each output channel */ - lp_vec_t latchups = - lp_vec_t(sid.objectId, P60System::pool::LATCHUPS, - this); - lp_var_t dockVbatVoltageValue = lp_var_t(sid.objectId, P60System::pool::P60DOCK_DOCK_VBAT, this); lp_var_t dockVccCurrent = @@ -439,11 +441,6 @@ class HkTableDataset : public StaticLocalDataSet<32> { lp_var_t batteryTemperature2 = lp_var_t(sid.objectId, P60System::pool::P60DOCK_BATTERY_TEMPERATURE_2, this); - lp_vec_t devicesType = - lp_vec_t(sid.objectId, P60System::pool::DEVICES_TYPE, this); - lp_vec_t devicesStatus = - lp_vec_t(sid.objectId, P60System::pool::DEVICES_STATUS, this); - lp_var_t dearmStatus = lp_var_t(sid.objectId, P60System::pool::P60DOCK_DEARM_STATUS, this); @@ -477,6 +474,11 @@ class HkTableDataset : public StaticLocalDataSet<32> { lp_var_t(sid.objectId, P60System::pool::P60DOCK_ANT6_DEPL, this); lp_var_t ar6Depl = lp_var_t(sid.objectId, P60System::pool::P60DOCK_AR6_DEPL, this); + + lp_vec_t devicesType = + lp_vec_t(sid.objectId, P60System::pool::DEVICES_TYPE, this); + lp_vec_t devicesStatus = + lp_vec_t(sid.objectId, P60System::pool::DEVICES_STATUS, this); }; } // namespace P60Dock @@ -494,7 +496,6 @@ 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 enum SwitchChannels : uint8_t { TCS_BOARD_3V3 = 0, @@ -527,10 +528,11 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x50; */ class PDU1HkTableDataset : public StaticLocalDataSet { public: - PDU1HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} + PDU1HkTableDataset(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::PDU_1)) {} PDU1HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::PDU_1))) {} /** Measured output currents */ lp_var_t currentOutTCSBoard3V3 = @@ -698,7 +700,6 @@ class PDU1HkTableDataset : public StaticLocalDataSet { } // namespace PDU1 namespace PDU2 { -static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; enum SwitchChannels : uint8_t { Q7S = 0, @@ -731,10 +732,11 @@ static const uint16_t CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA = 0x50; */ class PDU2HkTableDataset : public StaticLocalDataSet { public: - PDU2HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} + PDU2HkTableDataset(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::PDU_2)) {} PDU2HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::PDU_2))) {} /** Measured output currents */ lp_var_t currentOutQ7S = @@ -903,8 +905,6 @@ class PDU2HkTableDataset : public StaticLocalDataSet { namespace ACU { -static const uint32_t HK_TABLE_DATA_SET_ID = 0x4; - /* When receiving full housekeeping (telemetry) table */ static const uint16_t MAX_REPLY_LENGTH = 262; static const uint16_t MAX_CONFIGTABLE_ADDRESS = 26; @@ -917,10 +917,11 @@ static const uint16_t HK_TABLE_REPLY_SIZE = 262; */ class HkTableDataset : public StaticLocalDataSet { public: - HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {} + HkTableDataset(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::ACU)) {} HkTableDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {} + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::ACU))) {} lp_var_t currentInChannel0 = lp_var_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNEL0, this); diff --git a/tmtc b/tmtc index 8f2ff303..ab5cca85 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8f2ff3034fff627b807f32c02fd9e676126bae5f +Subproject commit ab5cca85bfb71875ba0c49e8ed6ef575f851c0c5 From 64b3afae22c835e8d19ecd5822d2bd31d7e6f301 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 13:07:28 +0200 Subject: [PATCH 3/6] new event for battery mode: broadcast and changed --- common/config/commonSubsystemIds.h | 4 ++++ mission/devices/P60DockHandler.cpp | 13 ++++++++++++- mission/devices/P60DockHandler.h | 9 +++++++++ .../devices/devicedefinitions/GomspaceDefinitions.h | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index a93986a1..f7a8ee3a 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -24,6 +24,10 @@ enum: uint8_t { ACS_BOARD_ASS = 123, SUS_BOARD_ASS = 124, TCS_BOARD_ASS = 125, + P60_DOCK_HANDLER = 126, + PDU1_HANDLER = 127, + PDU2_HANDLER = 128, + ACU_HANDLER = 129, COMMON_SUBSYSTEM_ID_END }; } diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 9a337687..b7a84159 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -116,8 +116,16 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; auxHk.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + dataOffset += 4; - coreHk.battMode = *(packet + dataOffset); + uint8_t newBattMode = packet[dataOffset]; + if (firstHk) { + triggerEvent(BATT_MODE, newBattMode); + } else if (newBattMode != coreHk.battMode.value) { + triggerEvent(BATT_MODE_CHANGED, coreHk.battMode.value, newBattMode); + } + coreHk.battMode = newBattMode; + dataOffset += 3; auxHk.heaterOn = *(packet + dataOffset); /* + 13 because here begins a new gomspace csp data field */ @@ -195,6 +203,9 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { auxHk.ant6Depl = *(packet + dataOffset); dataOffset += 3; auxHk.ar6Depl = *(packet + dataOffset); + if (firstHk) { + firstHk = false; + } coreHk.setValidity(true, true); auxHk.setValidity(true, true); } diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index 47484680..feb52edc 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -4,6 +4,7 @@ #include #include "GomspaceDeviceHandler.h" +#include "commonSubsystemIds.h" /** * @brief Device handler for the P60Dock. The P60Dock serves as carrier for the ACU, PDU1 and @@ -11,6 +12,13 @@ */ class P60DockHandler : public GomspaceDeviceHandler { public: + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::P60_DOCK_HANDLER; + + //! [EXPORT] : [COMMENT] Battery mode is broadcasted at startup. P1: Mode + static constexpr Event BATT_MODE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + //! [EXPORT] : [COMMENT] Battery mode has changed. P1: Old mode. P2: New mode + static constexpr Event BATT_MODE_CHANGED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); virtual ~P60DockHandler(); @@ -39,6 +47,7 @@ class P60DockHandler : public GomspaceDeviceHandler { private: P60Dock::CoreHkSet coreHk; P60Dock::HkTableDataset auxHk; + bool firstHk = true; static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 16; PoolEntry hkCurrents = PoolEntry(P60Dock::hk::CHNLS_LEN); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 93fe9e6b..8b19c909 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -43,6 +43,8 @@ static const DeviceCommandId_t PRINT_LATCHUPS = 33; namespace P60System { +enum class BatteryModes : uint8_t { CRITICAL = 1, SAFE = 2, NORMAL = 3, FULL = 4 }; + enum class SetIds : uint32_t { PDU_1 = 1, PDU_2 = 2, P60_CORE = 3, P60_AUX = 4, ACU = 5 }; namespace pool { From d570b5c4608cdaea8092c7a72eeff5dd5cb30267 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 13:08:20 +0200 Subject: [PATCH 4/6] use different severities --- mission/devices/P60DockHandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index feb52edc..4f5589b6 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -15,9 +15,9 @@ class P60DockHandler : public GomspaceDeviceHandler { static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::P60_DOCK_HANDLER; //! [EXPORT] : [COMMENT] Battery mode is broadcasted at startup. P1: Mode - static constexpr Event BATT_MODE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + static constexpr Event BATT_MODE = event::makeEvent(SUBSYSTEM_ID, 0, severity::INFO); //! [EXPORT] : [COMMENT] Battery mode has changed. P1: Old mode. P2: New mode - static constexpr Event BATT_MODE_CHANGED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + static constexpr Event BATT_MODE_CHANGED = event::makeEvent(SUBSYSTEM_ID, 1, severity::MEDIUM); P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); virtual ~P60DockHandler(); From 0e7cd7de6f2915ec57e2c65f674e088cb4cc5d24 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 13:11:20 +0200 Subject: [PATCH 5/6] add p60 boot count broadcast --- mission/devices/P60DockHandler.cpp | 3 +++ mission/devices/P60DockHandler.h | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index b7a84159..d37673fc 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -111,6 +111,9 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { dataOffset += 6; coreHk.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + if(firstHk) { + triggerEvent(P60_BOOT_COUNT, coreHk.bootCount.value); + } dataOffset += 6; auxHk.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index 4f5589b6..d08a46e0 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -14,10 +14,12 @@ class P60DockHandler : public GomspaceDeviceHandler { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::P60_DOCK_HANDLER; + //! [EXPORT] : [COMMENT] P60 boot count is broadcasted once at SW startup. P1: Boot count + static constexpr Event P60_BOOT_COUNT = event::makeEvent(SUBSYSTEM_ID, 0, severity::INFO); //! [EXPORT] : [COMMENT] Battery mode is broadcasted at startup. P1: Mode - static constexpr Event BATT_MODE = event::makeEvent(SUBSYSTEM_ID, 0, severity::INFO); + static constexpr Event BATT_MODE = event::makeEvent(SUBSYSTEM_ID, 1, severity::INFO); //! [EXPORT] : [COMMENT] Battery mode has changed. P1: Old mode. P2: New mode - static constexpr Event BATT_MODE_CHANGED = event::makeEvent(SUBSYSTEM_ID, 1, severity::MEDIUM); + static constexpr Event BATT_MODE_CHANGED = event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM); P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); virtual ~P60DockHandler(); From a9419cd3288e8c8855203094b7e1337e4eb78b4f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Apr 2022 14:51:47 +0200 Subject: [PATCH 6/6] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 5189b20b..3a1c7c62 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5189b20b0e732c0a504bd0d1278eef8653b10293 +Subproject commit 3a1c7c62887eb377c498bd9cdac47b93f40c85ba