From a5e2208e015939841fd40b340601b00dafe79780 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Feb 2022 17:44:21 +0100 Subject: [PATCH] param file init success --- mission/devices/PayloadPcduHandler.cpp | 36 +++++++++++++------ .../payloadPcduDefinitions.h | 2 +- mission/memory/NVMParameterBase.cpp | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 129c0367..59ca517f 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -203,6 +203,7 @@ void PayloadPcduHandler::handleExtConvRead(const uint8_t* bufStart) { } void PayloadPcduHandler::handlePrintout() { + using namespace plpcdu; if (periodicPrintout) { if (opDivider.checkAndIncrement()) { sif::info << "PL PCDU ADC hex [" << std::setfill('0') << std::hex; @@ -213,6 +214,17 @@ void PayloadPcduHandler::handlePrintout() { } } sif::info << "] | T[C] " << std::dec << adcSet.tempC.value << std::endl; + sif::info << "Neg V: " << adcSet.processed[U_NEG_V_FB] << std::endl; + sif::info << "I HPA [mA]: " << adcSet.processed[I_HPA] << std::endl; + sif::info << "U HPA [V]: " << adcSet.processed[U_HPA_DIV_6] << std::endl; + sif::info << "I MPA [mA]: " << adcSet.processed[I_MPA] << std::endl; + sif::info << "U MPA [V]: " << adcSet.processed[U_MPA_DIV_6] << std::endl; + sif::info << "I TX [mA]: " << adcSet.processed[I_TX] << std::endl; + sif::info << "U TX [V]: " << adcSet.processed[U_TX_DIV_6] << std::endl; + sif::info << "I X8 [mA]: " << adcSet.processed[I_X8] << std::endl; + sif::info << "U X8 [V]: " << adcSet.processed[U_X8_DIV_6] << std::endl; + sif::info << "I DRO [mA]: " << adcSet.processed[I_DRO] << std::endl; + sif::info << "U DRO [V]: " << adcSet.processed[U_DRO_DIV_6] << std::endl; } } } @@ -257,17 +269,19 @@ void PayloadPcduHandler::checkAdcValues() { adcSet.processed[U_X8_DIV_6] = static_cast(adcSet.channels[9]) * SCALE_VOLTAGE; adcSet.processed[I_DRO] = static_cast(adcSet.channels[10]) * SCALE_CURRENT_DRO * 1000.0; adcSet.processed[U_DRO_DIV_6] = static_cast(adcSet.channels[11]) * SCALE_VOLTAGE; - if(adcSet.processed[U_BAT_DIV_6] < -6.0 or adcSet.processed[U_BAT_DIV_6] > -3.3) { - bool tooLarge = false; - if(adcSet.processed[U_BAT_DIV_6] > -3.3) { - tooLarge = true; + if(state >= States::ON_TRANS_DRO) { + if(adcSet.processed[U_BAT_DIV_6] < -6.0 or adcSet.processed[U_BAT_DIV_6] > -3.3) { + bool tooLarge = false; + if(adcSet.processed[U_BAT_DIV_6] > -3.3) { + tooLarge = true; + } + uint32_t rawVoltage = 0; + size_t serSize = 0; + SerializeAdapter::serialize(&adcSet.processed[U_BAT_DIV_6], + reinterpret_cast(&rawVoltage), &serSize, 4, SerializeIF::Endianness::NETWORK); + triggerEvent(NEG_V_OUT_OF_BOUNDS, tooLarge, rawVoltage); + transitionBackToOff(); } - uint32_t rawVoltage = 0; - size_t serSize = 0; - SerializeAdapter::serialize(&adcSet.processed[U_BAT_DIV_6], - reinterpret_cast(&rawVoltage), &serSize, 4, SerializeIF::Endianness::NETWORK); - triggerEvent(NEG_V_OUT_OF_BOUNDS, tooLarge, rawVoltage); - transitionBackToOff(); } } @@ -277,8 +291,8 @@ void PayloadPcduHandler::checkJsonFileInit() { sdcMan->getPreferredSdCard(prefSd); if(sdcMan->isSdCardMounted(prefSd)) { params.initialize(sdcMan->getCurrentMountPrefix(prefSd)); + jsonFileInitComplete = true; } - jsonFileInitComplete = true; } } diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index 2453cb7f..ca771de9 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -150,7 +150,7 @@ class PlPcduParameter : public NVMParameterBase { ReturnValue_t initialize(std::string mountPrefix) { setFullName(mountPrefix + "/conf/plpcdu.json"); ReturnValue_t result = readJsonFile(); - if(result == HasReturnvaluesIF::RETURN_OK) { + if(result != HasReturnvaluesIF::RETURN_OK) { // File does not exist. Create it. Keys and appropriate init values were // specified in constructor #if OBSW_VERBOSE_LEVEL >= 1 diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NVMParameterBase.cpp index 0802a392..c7ac7560 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NVMParameterBase.cpp @@ -19,7 +19,7 @@ ReturnValue_t NVMParameterBase::readJsonFile() { ReturnValue_t NVMParameterBase::writeJsonFile() { std::ofstream o(fullName); - o << std::setw(4) << json; + o << std::setw(4) << json << std::endl; return HasReturnvaluesIF::RETURN_OK; }