From 3bdad61ac0797e5488928c0e4961dab410060d02 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 10:42:57 +0200 Subject: [PATCH 01/11] split ACU HK set --- mission/devices/ACUHandler.cpp | 310 ++++++------------ mission/devices/ACUHandler.h | 5 +- .../devicedefinitions/GomspaceDefinitions.h | 229 ++++--------- tmtc | 2 +- 4 files changed, 159 insertions(+), 387 deletions(-) diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index f881479d..bbb22f86 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -6,7 +6,7 @@ ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCoo FailureIsolationBase *customFdir) : GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, ACU::MAX_CONFIGTABLE_ADDRESS, ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE), - acuHkTableDataset(this) {} + coreHk(this), auxHk(this) {} ACUHandler::~ACUHandler() {} @@ -22,236 +22,141 @@ void ACUHandler::fillCommandAndReplyMap() { void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); - handleDeviceTM(&acuHkTableDataset, id, true); - if (debugMode) { #if OBSW_VERBOSE_LEVEL >= 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 + PoolReadGuard pg0(&auxHk); + PoolReadGuard pg1(&coreHk); + if(pg0.getReadResult() != RETURN_OK or pg1.getReadResult() != RETURN_OK) { + return; + } + for(size_t idx = 0; idx < 3; idx++) { + float tempC = coreHk.temperatures[idx] * 0.1; + sif::info << "ACU: Temperature " << idx << ": " << tempC << " °C" << std::endl; + } + sif::info << "ACU: Ground Watchdog Timer Count: " << auxHk.wdtCntGnd.value << std::endl; sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " - << acuHkTableDataset.wdtGndLeft.value << std::endl; - acuHkTableDataset.commit(); + << auxHk.wdtGndLeft.value << std::endl; #endif } } LocalPoolDataSetBase *ACUHandler::getDataSetHandle(sid_t sid) { - if (sid == acuHkTableDataset.getSid()) { - return &acuHkTableDataset; + if (sid == coreHk.getSid()) { + return &coreHk; + } else if(sid == auxHk.getSid()) { + return &auxHk; } return nullptr; } -void ACUHandler::parseHkTableReply(const uint8_t *packet) { +ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; - acuHkTableDataset.read(); + PoolReadGuard pg0(&coreHk); + PoolReadGuard pg1(&auxHk); + auto res0 = pg0.getReadResult(); + auto res1 = pg1.getReadResult(); + if(res0 != RETURN_OK) { + return res0; + } + if(res1 != RETURN_OK) { + return res1; + } dataOffset += 12; - acuHkTableDataset.currentInChannel0 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + for(size_t idx = 0; idx < 6; idx++) { + coreHk.currentInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + dataOffset += 4; + } + for(size_t idx = 0; idx < 6; idx++) { + coreHk.voltageInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + dataOffset += 4; + } + + + coreHk.vcc = *(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); + coreHk.vbat = *(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; + for(size_t idx = 0; idx < 3; idx++) { + coreHk.temperatures[idx] = (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.mpptMode = *(packet + dataOffset); + coreHk.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; + for(size_t idx = 0; idx < 6; idx++) { + coreHk.vboostInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + dataOffset += 4; + } + for(size_t idx = 0; idx < 6; idx++) { + coreHk.powerInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + dataOffset += 4; + } + for(size_t idx = 0; idx < 3; idx++) { + auxHk.dacEnables[idx] = packet[dataOffset]; + dataOffset += 3; + } + for(size_t idx = 0; idx < 6; idx++) { + auxHk.dacRawChannelVal0[idx] = (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.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 | + auxHk.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 | + coreHk.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 | + coreHk.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); + auxHk.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - acuHkTableDataset.mpptTime = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); + coreHk.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); + coreHk.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; + for(size_t idx = 0; idx < 8; idx++) { + auxHk.deviceTypes[idx] = packet[dataOffset]; + dataOffset += 3; + } + for(size_t idx = 0; idx < 8; idx++) { + auxHk.devicesStatus[idx] = 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 | + auxHk.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 | + auxHk.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; - - acuHkTableDataset.commit(); + return RETURN_OK; } ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { using namespace P60System; - localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNEL0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNEL1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNEL2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNEL3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNEL4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNEL5, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNEL0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNEL1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNEL2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNEL3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNEL4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNEL5, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNELS, new PoolEntry(6)); + localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNELS, new PoolEntry(6)); localDataPoolMap.emplace(pool::ACU_VCC, new PoolEntry({0})); localDataPoolMap.emplace(pool::ACU_VBAT, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_TEMPERATURE_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_TEMPERATURE_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_TEMPERATURE_3, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_TEMPERATURES, new PoolEntry(3)); localDataPoolMap.emplace(pool::ACU_MPPT_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VBOOST_CHANNEL0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VBOOST_CHANNEL1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VBOOST_CHANNEL2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VBOOST_CHANNEL3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VBOOST_CHANNEL4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_VBOOST_CHANNEL5, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_VBOOST_IN_CHANNELS, new PoolEntry(6)); + localDataPoolMap.emplace(pool::ACU_POWER_IN_CHANNELS, new PoolEntry(6)); - localDataPoolMap.emplace(pool::ACU_POWER_CHANNEL0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_POWER_CHANNEL1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_POWER_CHANNEL2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_POWER_CHANNEL3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_POWER_CHANNEL4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_POWER_CHANNEL5, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::ACU_DAC_EN_0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_EN_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_EN_2, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::ACU_DAC_RAW_0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_RAW_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_RAW_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_RAW_3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_RAW_4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DAC_RAW_5, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_DAC_ENABLES, new PoolEntry(3)); + localDataPoolMap.emplace(pool::ACU_DAC_RAW_CHANNELS, new PoolEntry(6)); localDataPoolMap.emplace(pool::ACU_BOOTCAUSE, new PoolEntry({0})); localDataPoolMap.emplace(pool::ACU_BOOTCNT, new PoolEntry({0})); @@ -260,28 +165,14 @@ ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localData localDataPoolMap.emplace(pool::ACU_MPPT_TIME, new PoolEntry({0})); localDataPoolMap.emplace(pool::ACU_MPPT_PERIOD, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_0, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_1, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_2, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_3, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_4, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_5, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_6, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_7, new PoolEntry({0})); - - localDataPoolMap.emplace(pool::ACU_DEVICE_0_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_1_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_2_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_3_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_4_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_5_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_6_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(pool::ACU_DEVICE_7_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_DEVICES, new PoolEntry(8)); + localDataPoolMap.emplace(pool::ACU_DEVICES_STATUS, new PoolEntry(8)); localDataPoolMap.emplace(pool::ACU_WDT_CNT_GND, new PoolEntry({0})); localDataPoolMap.emplace(pool::ACU_WDT_GND_LEFT, new PoolEntry({0})); - poolManager.subscribeForPeriodicPacket(acuHkTableDataset.getSid(), false, 30.0, false); + poolManager.subscribeForPeriodicPacket(coreHk.getSid(), false, 10.0, true); + poolManager.subscribeForPeriodicPacket(auxHk.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } @@ -299,26 +190,13 @@ ReturnValue_t ACUHandler::childCommandHook(DeviceCommandId_t cmd, const uint8_t } void ACUHandler::printChannelStats() { - PoolReadGuard pg(&acuHkTableDataset); + PoolReadGuard pg(&coreHk); 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; + for(size_t idx = 0; idx < 6; idx++) { + sif::info << std::setw(8) << std::left << "Channel " << idx << std::dec << "| " + << static_cast(coreHk.currentInChannels[idx]) << std::setw(15) + << std::right << coreHk.voltageInChannels[idx] << std::endl; + } } void ACUHandler::setDebugMode(bool enable) { this->debugMode = enable; } diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 16a7c6db..ca0ccd2d 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -39,14 +39,15 @@ class ACUHandler : public GomspaceDeviceHandler { private: static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; - ACU::HkTableDataset acuHkTableDataset; + ACU::CoreHk coreHk; + ACU::AuxHk auxHk; bool debugMode = false; /** * @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); + ReturnValue_t parseHkTableReply(const uint8_t* packet); /** * @brief Prints channel statistics (current and voltage) to console diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 5c59d3d8..5314a280 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -55,7 +55,8 @@ enum class SetIds : uint32_t { PDU_2_AUX = 4, P60_CORE = 5, P60_AUX = 6, - ACU = 7 + ACU_CORE = 7, + ACU_AUX = 8 }; namespace pool { @@ -129,67 +130,24 @@ enum Ids : lp_id_t { PDU_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_CURRENT_IN_CHANNELS, + ACU_VOLTAGE_IN_CHANNELS, ACU_VCC, ACU_VBAT, - ACU_TEMPERATURE_1, - ACU_TEMPERATURE_2, - ACU_TEMPERATURE_3, + ACU_TEMPERATURES, 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_VBOOST_IN_CHANNELS, + ACU_POWER_IN_CHANNELS, + ACU_DAC_ENABLES, + ACU_DAC_RAW_CHANNELS, 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_DEVICES, + ACU_DEVICES_STATUS, ACU_WDT_CNT_GND, ACU_WDT_GND_LEFT, }; @@ -592,138 +550,73 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 120; static const uint8_t HK_TABLE_ENTRIES = 64; 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: - HkTableDataset(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::ACU)) {} +class CoreHk: public StaticLocalDataSet<14> { +public: + CoreHk(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::ACU_CORE)) {} - HkTableDataset(object_id_t objectId) - : 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); - lp_var_t currentInChannel1 = - lp_var_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNEL1, this); - lp_var_t currentInChannel2 = - lp_var_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNEL2, this); - lp_var_t currentInChannel3 = - lp_var_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNEL3, this); - lp_var_t currentInChannel4 = - lp_var_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNEL4, this); - lp_var_t currentInChannel5 = - lp_var_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNEL5, this); - - lp_var_t voltageInChannel0 = - lp_var_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNEL0, this); - lp_var_t voltageInChannel1 = - lp_var_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNEL1, this); - lp_var_t voltageInChannel2 = - lp_var_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNEL2, this); - lp_var_t voltageInChannel3 = - lp_var_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNEL3, this); - lp_var_t voltageInChannel4 = - lp_var_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNEL4, this); - lp_var_t voltageInChannel5 = - lp_var_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNEL5, this); - - lp_var_t vcc = lp_var_t(sid.objectId, P60System::pool::ACU_VCC, this); - lp_var_t vbat = lp_var_t(sid.objectId, P60System::pool::ACU_VBAT, this); - - lp_var_t temperature1 = - lp_var_t(sid.objectId, P60System::pool::ACU_TEMPERATURE_1, this); - lp_var_t temperature2 = - lp_var_t(sid.objectId, P60System::pool::ACU_TEMPERATURE_2, this); - lp_var_t temperature3 = - lp_var_t(sid.objectId, P60System::pool::ACU_TEMPERATURE_3, this); + CoreHk(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::ACU_CORE))) {} lp_var_t mpptMode = lp_var_t(sid.objectId, P60System::pool::ACU_MPPT_MODE, this); - lp_var_t vboostInChannel0 = - lp_var_t(sid.objectId, P60System::pool::ACU_VBOOST_CHANNEL0, this); - lp_var_t vboostInChannel1 = - lp_var_t(sid.objectId, P60System::pool::ACU_VBOOST_CHANNEL1, this); - lp_var_t vboostInChannel2 = - lp_var_t(sid.objectId, P60System::pool::ACU_VBOOST_CHANNEL2, this); - lp_var_t vboostInChannel3 = - lp_var_t(sid.objectId, P60System::pool::ACU_VBOOST_CHANNEL3, this); - lp_var_t vboostInChannel4 = - lp_var_t(sid.objectId, P60System::pool::ACU_VBOOST_CHANNEL4, this); - lp_var_t vboostInChannel5 = - lp_var_t(sid.objectId, P60System::pool::ACU_VBOOST_CHANNEL5, this); + lp_vec_t currentInChannels = + lp_vec_t(sid.objectId, P60System::pool::ACU_CURRENT_IN_CHANNELS, this); + lp_vec_t voltageInChannels = + lp_vec_t(sid.objectId, P60System::pool::ACU_VOLTAGE_IN_CHANNELS, this); - lp_var_t powerInChannel0 = - lp_var_t(sid.objectId, P60System::pool::ACU_POWER_CHANNEL0, this); - lp_var_t powerInChannel1 = - lp_var_t(sid.objectId, P60System::pool::ACU_POWER_CHANNEL1, this); - lp_var_t powerInChannel2 = - lp_var_t(sid.objectId, P60System::pool::ACU_POWER_CHANNEL2, this); - lp_var_t powerInChannel3 = - lp_var_t(sid.objectId, P60System::pool::ACU_POWER_CHANNEL3, this); - lp_var_t powerInChannel4 = - lp_var_t(sid.objectId, P60System::pool::ACU_POWER_CHANNEL4, this); - lp_var_t powerInChannel5 = - lp_var_t(sid.objectId, P60System::pool::ACU_POWER_CHANNEL5, this); + lp_var_t vcc = lp_var_t(sid.objectId, P60System::pool::ACU_VCC, this); + lp_var_t vbat = lp_var_t(sid.objectId, P60System::pool::ACU_VBAT, this); - lp_var_t dac0Enable = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_EN_0, this); - lp_var_t dac1Enable = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_EN_1, this); - lp_var_t dac2Enable = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_EN_2, this); + lp_vec_t vboostInChannels = + lp_vec_t(sid.objectId, P60System::pool::ACU_VBOOST_IN_CHANNELS, this); + lp_vec_t powerInChannels = + lp_vec_t(sid.objectId, P60System::pool::ACU_POWER_IN_CHANNELS, this); - lp_var_t dacRawChannelVal0 = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_RAW_0, this); - lp_var_t dacRawChannelVal1 = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_RAW_1, this); - lp_var_t dacRawChannelVal2 = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_RAW_2, this); - lp_var_t dacRawChannelVal3 = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_RAW_3, this); - lp_var_t dacRawChannelVal4 = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_RAW_4, this); - lp_var_t dacRawChannelVal5 = - lp_var_t(sid.objectId, P60System::pool::ACU_DAC_RAW_5, this); + lp_vec_t temperatures = + lp_vec_t(sid.objectId, P60System::pool::ACU_TEMPERATURES, this); - lp_var_t bootCause = - lp_var_t(sid.objectId, P60System::pool::ACU_BOOTCAUSE, this); lp_var_t bootcnt = lp_var_t(sid.objectId, P60System::pool::ACU_BOOTCNT, this); lp_var_t uptime = lp_var_t(sid.objectId, P60System::pool::ACU_UPTIME, this); - lp_var_t resetCause = - lp_var_t(sid.objectId, P60System::pool::ACU_RESET_CAUSE, this); lp_var_t mpptTime = lp_var_t(sid.objectId, P60System::pool::ACU_MPPT_TIME, this); lp_var_t mpptPeriod = lp_var_t(sid.objectId, P60System::pool::ACU_MPPT_PERIOD, this); - lp_var_t device0 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_0, this); - lp_var_t device1 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_1, this); - lp_var_t device2 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_2, this); - lp_var_t device3 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_3, this); - lp_var_t device4 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_4, this); - lp_var_t device5 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_5, this); - lp_var_t device6 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_6, this); - lp_var_t device7 = lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_7, this); +}; +/** + * @brief This class defines a dataset for the hk table of the ACU. + */ +class AuxHk : public StaticLocalDataSet<12> { + public: + AuxHk(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::ACU_AUX)) {} - lp_var_t device0Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_0_STATUS, this); - lp_var_t device1Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_1_STATUS, this); - lp_var_t device2Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_2_STATUS, this); - lp_var_t device3Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_3_STATUS, this); - lp_var_t device4Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_4_STATUS, this); - lp_var_t device5Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_5_STATUS, this); - lp_var_t device6Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_6_STATUS, this); - lp_var_t device7Status = - lp_var_t(sid.objectId, P60System::pool::ACU_DEVICE_7_STATUS, this); + AuxHk(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::ACU_AUX))) {} + + + lp_vec_t dacEnables = + lp_vec_t(sid.objectId, P60System::pool::ACU_DAC_ENABLES, this); + + lp_vec_t dacRawChannelVal0 = + lp_vec_t(sid.objectId, P60System::pool::ACU_DAC_RAW_CHANNELS, this); + + lp_var_t bootCause = + lp_var_t(sid.objectId, P60System::pool::ACU_BOOTCAUSE, this); + lp_var_t resetCause = + lp_var_t(sid.objectId, P60System::pool::ACU_RESET_CAUSE, 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_vec_t deviceTypes = + lp_vec_t(sid.objectId, P60System::pool::ACU_DEVICES, this); + /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ + lp_vec_t devicesStatus = + lp_vec_t(sid.objectId, P60System::pool::ACU_DEVICES_STATUS, this); lp_var_t wdtCntGnd = lp_var_t(sid.objectId, P60System::pool::ACU_WDT_CNT_GND, this); diff --git a/tmtc b/tmtc index 480e0f07..ff66dd5d 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 480e0f07e03edeb55a3d6e3d629e7601b6bf90a2 +Subproject commit ff66dd5dd2bc2ee3150ce45160303bc79ed2599d -- 2.43.0 From 99e27a5a635b0a47adf5fff9c581be7bb6a77b0c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 11:25:58 +0200 Subject: [PATCH 02/11] run afmt --- bsp_q7s/em/emObjectFactory.cpp | 1 + bsp_q7s/obsw.cpp | 2 +- mission/devices/ACUHandler.cpp | 87 ++++++++++--------- mission/devices/ACUHandler.h | 7 +- mission/devices/P60DockHandler.cpp | 2 +- mission/devices/PDU1Handler.cpp | 2 +- mission/devices/PDU2Handler.cpp | 2 +- .../devicedefinitions/GomspaceDefinitions.h | 9 +- tmtc | 2 +- 9 files changed, 58 insertions(+), 56 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index d4500e0b..327e7b87 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -1,4 +1,5 @@ #include + #include "OBSWConfig.h" #include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/ObjectFactory.h" diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index 1da60783..530c4904 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -4,11 +4,11 @@ #include #include "OBSWConfig.h" -#include "q7sConfig.h" #include "commonConfig.h" #include "core/InitMission.h" #include "fsfw/tasks/TaskFactory.h" #include "fsfw/version.h" +#include "q7sConfig.h" #include "watchdog/definitions.h" static int OBSW_ALREADY_RUNNING = -2; diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index bbb22f86..77386610 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -6,7 +6,8 @@ ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCoo FailureIsolationBase *customFdir) : GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, ACU::MAX_CONFIGTABLE_ADDRESS, ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE), - coreHk(this), auxHk(this) {} + coreHk(this), + auxHk(this) {} ACUHandler::~ACUHandler() {} @@ -15,10 +16,7 @@ ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { return buildCommandFromCommand(*id, NULL, 0); } -void ACUHandler::fillCommandAndReplyMap() { - GomspaceDeviceHandler::fillCommandAndReplyMap(); - this->insertInCommandMap(PRINT_CHANNEL_STATS); -} +void ACUHandler::fillCommandAndReplyMap() { GomspaceDeviceHandler::fillCommandAndReplyMap(); } void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); @@ -26,15 +24,14 @@ void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pack #if OBSW_VERBOSE_LEVEL >= 1 PoolReadGuard pg0(&auxHk); PoolReadGuard pg1(&coreHk); - if(pg0.getReadResult() != RETURN_OK or pg1.getReadResult() != RETURN_OK) { + if (pg0.getReadResult() != RETURN_OK or pg1.getReadResult() != RETURN_OK) { return; } - for(size_t idx = 0; idx < 3; idx++) { + for (size_t idx = 0; idx < 3; idx++) { float tempC = coreHk.temperatures[idx] * 0.1; sif::info << "ACU: Temperature " << idx << ": " << tempC << " °C" << std::endl; } - sif::info << "ACU: Ground Watchdog Timer Count: " << auxHk.wdtCntGnd.value - << std::endl; + sif::info << "ACU: Ground Watchdog Timer Count: " << auxHk.wdtCntGnd.value << std::endl; sif::info << "ACU: Ground watchdog timer, seconds left before reboot: " << auxHk.wdtGndLeft.value << std::endl; #endif @@ -44,7 +41,7 @@ void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pack LocalPoolDataSetBase *ACUHandler::getDataSetHandle(sid_t sid) { if (sid == coreHk.getSid()) { return &coreHk; - } else if(sid == auxHk.getSid()) { + } else if (sid == auxHk.getSid()) { return &auxHk; } return nullptr; @@ -56,29 +53,28 @@ ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) { PoolReadGuard pg1(&auxHk); auto res0 = pg0.getReadResult(); auto res1 = pg1.getReadResult(); - if(res0 != RETURN_OK) { + if (res0 != RETURN_OK) { return res0; } - if(res1 != RETURN_OK) { + if (res1 != RETURN_OK) { return res1; } dataOffset += 12; - for(size_t idx = 0; idx < 6; idx++) { + for (size_t idx = 0; idx < 6; idx++) { coreHk.currentInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } - for(size_t idx = 0; idx < 6; idx++) { + for (size_t idx = 0; idx < 6; idx++) { coreHk.voltageInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } - coreHk.vcc = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; coreHk.vbat = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - for(size_t idx = 0; idx < 3; idx++) { + for (size_t idx = 0; idx < 3; idx++) { coreHk.temperatures[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } @@ -86,31 +82,31 @@ ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) { coreHk.mpptMode = packet[dataOffset]; dataOffset += 3; - for(size_t idx = 0; idx < 6; idx++) { + for (size_t idx = 0; idx < 6; idx++) { coreHk.vboostInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } - for(size_t idx = 0; idx < 6; idx++) { + for (size_t idx = 0; idx < 6; idx++) { coreHk.powerInChannels[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } - for(size_t idx = 0; idx < 3; idx++) { + for (size_t idx = 0; idx < 3; idx++) { auxHk.dacEnables[idx] = packet[dataOffset]; dataOffset += 3; } - for(size_t idx = 0; idx < 6; idx++) { + for (size_t idx = 0; idx < 6; idx++) { auxHk.dacRawChannelVal0[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } auxHk.bootCause = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; coreHk.bootcnt = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; coreHk.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; auxHk.resetCause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; @@ -121,20 +117,20 @@ ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) { coreHk.mpptPeriod = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1); dataOffset += 4; - for(size_t idx = 0; idx < 8; idx++) { + for (size_t idx = 0; idx < 8; idx++) { auxHk.deviceTypes[idx] = packet[dataOffset]; dataOffset += 3; } - for(size_t idx = 0; idx < 8; idx++) { + for (size_t idx = 0; idx < 8; idx++) { auxHk.devicesStatus[idx] = packet[dataOffset]; dataOffset += 3; } auxHk.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; auxHk.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | - *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); + *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; return RETURN_OK; } @@ -176,23 +172,10 @@ ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localData return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ACUHandler::childCommandHook(DeviceCommandId_t cmd, const uint8_t *commandData, - size_t commandDataLen) { - switch (cmd) { - case PRINT_CHANNEL_STATS: { - printChannelStats(); - return RETURN_OK; - } - default: { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - } -} - void ACUHandler::printChannelStats() { PoolReadGuard pg(&coreHk); sif::info << "ACU Info: Current [mA], Voltage [mV]" << std::endl; - for(size_t idx = 0; idx < 6; idx++) { + for (size_t idx = 0; idx < 6; idx++) { sif::info << std::setw(8) << std::left << "Channel " << idx << std::dec << "| " << static_cast(coreHk.currentInChannels[idx]) << std::setw(15) << std::right << coreHk.voltageInChannels[idx] << std::endl; @@ -200,3 +183,25 @@ void ACUHandler::printChannelStats() { } void ACUHandler::setDebugMode(bool enable) { this->debugMode = enable; } + +ReturnValue_t ACUHandler::printStatus(DeviceCommandId_t cmd) { + ReturnValue_t result = RETURN_OK; + switch (cmd) { + case (GOMSPACE::PRINT_SWITCH_V_I): { + PoolReadGuard pg(&coreHk); + result = pg.getReadResult(); + if (result != HasReturnvaluesIF::RETURN_OK) { + break; + } + printChannelStats(); + break; + } + default: { + return DeviceHandlerIF::COMMAND_NOT_SUPPORTED; + } + } + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Reading PDU1 HK table failed!" << std::endl; + } + return result; +} diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index ca0ccd2d..3154e547 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -29,16 +29,13 @@ class ACUHandler : public GomspaceDeviceHandler { */ virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; - virtual void fillCommandAndReplyMap() override; + ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t* commandData, - size_t commandDataLen) override; + virtual void fillCommandAndReplyMap() override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; private: - static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; - ACU::CoreHk coreHk; ACU::AuxHk auxHk; bool debugMode = false; diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index f1df649d..25fb238f 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -251,7 +251,7 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { return HasReturnvaluesIF::RETURN_OK; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_SUPPORTED; } } sif::warning << "Reading P60 Dock HK table failed" << std::endl; diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 44f8fb04..fca0fbeb 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -122,7 +122,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { break; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_SUPPORTED; } } if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 1476f95d..d0cef3f5 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -76,7 +76,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { break; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return DeviceHandlerIF::COMMAND_NOT_SUPPORTED; } } if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 5314a280..0c7cc2d7 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -38,7 +38,8 @@ 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 +//! [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console +//! For the ACU device, only print voltages and currents of the 6 ACU channels static const DeviceCommandId_t PRINT_SWITCH_V_I = 32; static const DeviceCommandId_t PRINT_LATCHUPS = 33; @@ -550,8 +551,8 @@ static const uint16_t MAX_HKTABLE_ADDRESS = 120; static const uint8_t HK_TABLE_ENTRIES = 64; static const uint16_t HK_TABLE_REPLY_SIZE = 262; -class CoreHk: public StaticLocalDataSet<14> { -public: +class CoreHk : public StaticLocalDataSet<14> { + public: CoreHk(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, static_cast(::P60System::SetIds::ACU_CORE)) {} @@ -583,7 +584,6 @@ public: lp_var_t(sid.objectId, P60System::pool::ACU_MPPT_TIME, this); lp_var_t mpptPeriod = lp_var_t(sid.objectId, P60System::pool::ACU_MPPT_PERIOD, this); - }; /** * @brief This class defines a dataset for the hk table of the ACU. @@ -596,7 +596,6 @@ class AuxHk : public StaticLocalDataSet<12> { AuxHk(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, static_cast(::P60System::SetIds::ACU_AUX))) {} - lp_vec_t dacEnables = lp_vec_t(sid.objectId, P60System::pool::ACU_DAC_ENABLES, this); diff --git a/tmtc b/tmtc index ff66dd5d..c01f1d01 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ff66dd5dd2bc2ee3150ce45160303bc79ed2599d +Subproject commit c01f1d01916160888cf745ee3db6a2c46d795408 -- 2.43.0 From 4e62f3b11218ec3575d15ce6216498ec17725fc3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 11:35:55 +0200 Subject: [PATCH 03/11] bugfixes for cp script --- scripts/q7s-cp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/q7s-cp.py b/scripts/q7s-cp.py index a189e3e6..d0543b45 100755 --- a/scripts/q7s-cp.py +++ b/scripts/q7s-cp.py @@ -27,7 +27,7 @@ def prompt_ssh_key_removal(): print("Invalid port detected") else: break - cmd = f'ssh-keygen -f "${{HOME}}/.ssh/known_hosts" -R "[localhost]:${port}"' + cmd = f'ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[localhost]:{port}"' print(f"Removing problematic SSH key with command {cmd}..") os.system(cmd) -- 2.43.0 From 8ae6fe0be5fa7f14526b16be922760738a9e4615 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 12:39:10 +0200 Subject: [PATCH 04/11] moved HK defs --- .../devices/devicedefinitions/GomspaceDefinitions.h | 10 +++++----- tmtc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 0c7cc2d7..4faf5299 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -607,6 +607,11 @@ class AuxHk : public StaticLocalDataSet<12> { lp_var_t resetCause = lp_var_t(sid.objectId, P60System::pool::ACU_RESET_CAUSE, this); + lp_var_t wdtCntGnd = + lp_var_t(sid.objectId, P60System::pool::ACU_WDT_CNT_GND, this); + lp_var_t wdtGndLeft = + lp_var_t(sid.objectId, P60System::pool::ACU_WDT_GND_LEFT, 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. @@ -616,11 +621,6 @@ class AuxHk : public StaticLocalDataSet<12> { /** The status of each device. 0 = None, 1 = Ok, 2 = Error, 3 = Not found */ lp_vec_t devicesStatus = lp_vec_t(sid.objectId, P60System::pool::ACU_DEVICES_STATUS, this); - - lp_var_t wdtCntGnd = - lp_var_t(sid.objectId, P60System::pool::ACU_WDT_CNT_GND, this); - lp_var_t wdtGndLeft = - lp_var_t(sid.objectId, P60System::pool::ACU_WDT_GND_LEFT, this); }; } // namespace ACU diff --git a/tmtc b/tmtc index c01f1d01..580b3818 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c01f1d01916160888cf745ee3db6a2c46d795408 +Subproject commit 580b3818489a87f9ea1b31754c7b0285c2bb6a10 -- 2.43.0 From e522aadd44dc865257418fb36da6134a0dd79ca2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 14:04:46 +0200 Subject: [PATCH 05/11] set HKs valid --- mission/devices/ACUHandler.cpp | 2 ++ tmtc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 77386610..15b2c2a0 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -132,6 +132,8 @@ ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) { auxHk.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); dataOffset += 6; + coreHk.setValidity(true, true); + auxHk.setValidity(true, true); return RETURN_OK; } diff --git a/tmtc b/tmtc index 580b3818..b9de13ff 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 580b3818489a87f9ea1b31754c7b0285c2bb6a10 +Subproject commit b9de13ffe7a4f8112e2e7732049816833f89d17d -- 2.43.0 From 660f0d2dcd6195b5d1428e35fe8cf9c5412e337d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 14:19:57 +0200 Subject: [PATCH 06/11] some minor fixes --- mission/devices/ACUHandler.cpp | 2 +- mission/devices/devicedefinitions/GomspaceDefinitions.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 15b2c2a0..a3b5eeee 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -95,7 +95,7 @@ ReturnValue_t ACUHandler::parseHkTableReply(const uint8_t *packet) { dataOffset += 3; } for (size_t idx = 0; idx < 6; idx++) { - auxHk.dacRawChannelVal0[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; + auxHk.dacRawChannelVals[idx] = (packet[dataOffset] << 8) | packet[dataOffset + 1]; dataOffset += 4; } diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 4faf5299..18059fc8 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -599,7 +599,7 @@ class AuxHk : public StaticLocalDataSet<12> { lp_vec_t dacEnables = lp_vec_t(sid.objectId, P60System::pool::ACU_DAC_ENABLES, this); - lp_vec_t dacRawChannelVal0 = + lp_vec_t dacRawChannelVals = lp_vec_t(sid.objectId, P60System::pool::ACU_DAC_RAW_CHANNELS, this); lp_var_t bootCause = -- 2.43.0 From 62ef9c7e70a7b0662818573332e1f47299abe837 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 18:25:39 +0200 Subject: [PATCH 07/11] set datapool entries of rad sensor valid --- mission/devices/RadiationSensorHandler.cpp | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index b3a9954a..19f72d68 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -169,7 +169,7 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); offset += 2; dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); - + dataset.setValidity(true, true); if (printPeriodicData) { sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::dec << std::endl; diff --git a/tmtc b/tmtc index fe36485e..4de3e7d1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit fe36485e854c4433ee98efe15616b9baa528316f +Subproject commit 4de3e7d107ae16c7c89eae340419ec92097fb92f -- 2.43.0 From a2fad6061a89efd6f4c2593b191a00cba5c25935 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 18:36:38 +0200 Subject: [PATCH 08/11] repoint tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 4de3e7d1..e7cb7ca0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 4de3e7d107ae16c7c89eae340419ec92097fb92f +Subproject commit e7cb7ca0963663a9674591c2945c5f24647cb00c -- 2.43.0 From 2f155d835098f36bd63f47509f79b2021e7bf708 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 18:39:13 +0200 Subject: [PATCH 09/11] bump changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2128a01d..6d963b7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,11 @@ list yields a list of all related PRs for each release. username appended at the end is created as a side-product now PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/248 +## Fixed + +- `q7s-cp.py` bugfix + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/256 + ### Heater - Adds `HealthIF` to heaters. Heaters are own system object with queues now which allows to set them faulty. -- 2.43.0 From 5df905182c0577404ebc0c6f4a06b0b242b63b34 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 18:40:17 +0200 Subject: [PATCH 10/11] these brackets are less confusing --- mission/devices/RadiationSensorHandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 19f72d68..f2694476 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -158,17 +158,17 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, int16_t tempRaw = ((packet[offset] & 0x0f) << 8) | packet[offset + 1]; dataset.temperatureCelcius = tempRaw * 0.125; offset += 2; - dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset + 1)); + dataset.ain0 = (*(packet + offset) << 8) | *(packet + offset + 1); offset += 2; - dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); + dataset.ain1 = (*(packet + offset) << 8) | *(packet + offset + 1); offset += 6; - dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); + dataset.ain4 = (*(packet + offset) << 8) | *(packet + offset + 1); offset += 2; - dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); + dataset.ain5 = (*(packet + offset) << 8) | *(packet + offset + 1); offset += 2; - dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); + dataset.ain6 = (*(packet + offset) << 8) | *(packet + offset + 1); offset += 2; - dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); + dataset.ain7 = (*(packet + offset) << 8) | *(packet + offset + 1); dataset.setValidity(true, true); if (printPeriodicData) { sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" -- 2.43.0 From f111001572c0c582aad7a8576cd43aea5c522cfe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 23 May 2022 18:59:31 +0200 Subject: [PATCH 11/11] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index e7cb7ca0..7f03dcb3 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit e7cb7ca0963663a9674591c2945c5f24647cb00c +Subproject commit 7f03dcb3a613d26462ac2571140ed6ecb91dd9f0 -- 2.43.0