From c42d68812c57aa5153d8e44507d032a51ce0c97c Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Thu, 7 Mar 2024 21:16:07 +0100 Subject: [PATCH] DPL limit scaling: prevent division by zero this check was removed on error when moving the scaling code into its own function. --- src/PowerLimiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index ec3542ad..a128f958 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -655,7 +655,7 @@ static int32_t scalePowerLimit(std::shared_ptr inverter, int32 } } - if (dcProdChnls == dcTotalChnls) { return newLimit; } + if (dcProdChnls == 0 || dcProdChnls == dcTotalChnls) { return newLimit; } MessageOutput.printf("[DPL::scalePowerLimit] %d channels total, %d producing " "channels, scaling power limit\r\n", dcTotalChnls, dcProdChnls);