From 8c132048e678201100bba964805e2ef86fe5364c Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 15 Feb 2024 23:22:24 +0100 Subject: [PATCH] 0.8.82 * fixed crash once firmware version was read and sent via MqTT #1428 * possible fix: reset yield offset on midnight #1429 --- src/CHANGES.md | 4 ++++ src/app.cpp | 3 +-- src/defines.h | 2 +- src/hm/hmInverter.h | 20 ++++++++++---------- src/publisher/pubMqttIvData.h | 22 +++++++++++----------- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index f39a5640..75fede55 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,9 @@ # Development Changes +## 0.8.82 - 2024-02-15 +* fixed crash once firmware version was read and sent via MqTT #1428 +* possible fix: reset yield offset on midnight #1429 + ## 0.8.81 - 2024-02-13 * fixed authentication with empty token #1415 * added new setting for future function to send log via MqTT diff --git a/src/app.cpp b/src/app.cpp index bee12387..0bead49e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -466,8 +466,6 @@ void app:: zeroIvValues(bool checkAvail, bool skipYieldDay) { continue; // skip to next inverter if (!iv->config->enabled) continue; // skip to next inverter - if (iv->commEnabled) - continue; // skip to next inverter if (checkAvail) { if (!iv->isAvailable()) @@ -495,6 +493,7 @@ void app:: zeroIvValues(bool checkAvail, bool skipYieldDay) { pos = iv->getPosByChFld(ch, FLD_MP, rec); iv->setValue(pos, rec, 0.0f); } + iv->resetAlarms(); iv->doCalculations(); } diff --git a/src/defines.h b/src/defines.h index 200c2561..68094ba3 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 81 +#define VERSION_PATCH 82 //------------------------------------- typedef struct { diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index f608908e..50b4267c 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -149,9 +149,6 @@ class Inverter { uint32_t tsMaxAcPower = 0; // holds the timestamp when the MaxAC power was seen bool commEnabled = true; // 'pause night communication' sets this field to false - static uint32_t *timestamp; // system timestamp - static cfgInst_t *generalConfig; // general inverter configuration from setup - public: Inverter() { @@ -826,20 +823,23 @@ class Inverter { radioId.b[0] = 0x01; } - private: - float mOffYD[6], mLastYD[6]; - bool mDevControlRequest = false; // true if change needed - uint8_t mGridLen = 0; - std::array mGridProfile; - uint8_t mAlarmNxtWrPos = 0; // indicates the position in array (rolling buffer) - public: + static uint32_t *timestamp; // system timestamp + static cfgInst_t *generalConfig; // general inverter configuration from setup + uint16_t mDtuRxCnt = 0; uint16_t mDtuTxCnt = 0; uint8_t mGetLossInterval = 0; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debug uint16_t mIvRxCnt = 0; uint16_t mIvTxCnt = 0; uint16_t mAckCount = 0; + + private: + float mOffYD[6], mLastYD[6]; + bool mDevControlRequest = false; // true if change needed + uint8_t mGridLen = 0; + std::array mGridProfile; + uint8_t mAlarmNxtWrPos = 0; // indicates the position in array (rolling buffer) }; template diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index c430da85..c3ae3814 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -179,20 +179,20 @@ class PubMqttIvData { if (MqttSentStatus::LAST_SUCCESS_SENT == rec->mqttSentStatus) { if(InverterDevInform_All == mCmd) { snprintf(mSubTopic.data(), mSubTopic.size(), "%s/firmware", mIv->config->name); - snprintf(mVal.data(), mVal.size(), "{\"version\":%d,\"build_year\":\"%s\",\"build_month_day\":%d,\"build_hour_min\":%d,\"bootloader\":%d}", - mIv->getChannelFieldValue(CH0, FLD_FW_VERSION, rec), - mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_YEAR, rec), - mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_MONTH_DAY, rec), - mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_HOUR_MINUTE, rec), - mIv->getChannelFieldValue(CH0, FLD_BOOTLOADER_VER, rec)); + snprintf(mVal.data(), mVal.size(), "{\"version\":%d,\"build_year\":\"%d\",\"build_month_day\":%d,\"build_hour_min\":%d,\"bootloader\":%d}", + static_cast(mIv->getChannelFieldValue(CH0, FLD_FW_VERSION, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_YEAR, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_MONTH_DAY, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_HOUR_MINUTE, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_BOOTLOADER_VER, rec))); retained = true; } else if(InverterDevInform_Simple == mCmd) { snprintf(mSubTopic.data(), mSubTopic.size(), "%s/hardware", mIv->config->name); - snprintf(mVal.data(), mVal.size(), "{\"part\":%d,\"version\":\"%s\",\"grid_profile_code\":%d,\"grid_profile_version\":%d}", - mIv->getChannelFieldValue(CH0, FLD_PART_NUM, rec), - mIv->getChannelFieldValue(CH0, FLD_HW_VERSION, rec), - mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec), - mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_VERSION, rec)); + snprintf(mVal.data(), mVal.size(), "{\"part\":%d,\"version\":\"%d\",\"grid_profile_code\":%d,\"grid_profile_version\":%d}", + static_cast(mIv->getChannelFieldValue(CH0, FLD_PART_NUM, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_HW_VERSION, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec)), + static_cast(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_VERSION, rec))); retained = true; } else { snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d/%s", mIv->config->name, rec->assign[mPos].ch, fields[rec->assign[mPos].fieldId]);