From 05a8344497857677d0e206a5bfe9285956db7a65 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:26:16 +0200 Subject: [PATCH 01/36] rename eco function Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index aab093df5b..6824d83f5a 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -774,9 +774,9 @@ static const char *eaton_input_eco_mode_check_range(double value) } /* High Efficiency (aka ECO) mode */ -static info_lkp_t eaton_input_mode_info[] = { +static info_lkp_t eaton_input_eco_mode_on_off_info[] = { { 0, "normal", NULL, NULL }, - { 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ecomode" = checked and working fine */ + { 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ecomode" = tested on 9E model and working fine */ { 2, "ESS", NULL, NULL }, /* Energy Saver System, makes sense for UPS that implements this mode (93PM G2, 9395P) */ { 0, NULL, NULL, NULL } }; @@ -864,7 +864,7 @@ static info_lkp_t eaton_input_bypass_mode_on_info[] = { { 0, NULL, NULL, NULL } }; -/* Automatic Bypass mode Off */ +/* Automatic Bypass mode off (switch on inverter) */ static info_lkp_t eaton_input_bypass_mode_off_info[] = { { 0, "disabled", NULL, NULL }, { 1, "off", NULL, NULL }, @@ -1641,7 +1641,7 @@ static hid_info_t mge_hid2nut[] = { "input.bypass.frequency.nominal", 0, 0, "UPS.Flow.[2].ConfigFrequency", NULL, "%.0f", HU_FLAG_STATIC, NULL }, /* ECO(HE) Mode switch */ - { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_mode_info }, + { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, /* Auto Bypass Mode on/off */ /* needs check this variable, maybe "Bypass switch ability" like Qualify bypass */ @@ -1755,7 +1755,7 @@ static hid_info_t mge_hid2nut[] = /* Command to switch ECO Mode */ { "ecomode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL }, - { "ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_mode_info }, + { "ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_eco_mode_on_off_info }, { "essmode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "2", HU_TYPE_CMD, NULL }, { "essmode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL }, From 5a8abbd4b9d6033e61143ea9605d99f87fb04356 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:26:12 +0200 Subject: [PATCH 02/36] comment added Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 6824d83f5a..02dbb23354 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1640,7 +1640,7 @@ static hid_info_t mge_hid2nut[] = { "input.bypass.frequency", 0, 0, "UPS.PowerConverter.Input.[2].Frequency", NULL, "%.1f", 0, NULL }, { "input.bypass.frequency.nominal", 0, 0, "UPS.Flow.[2].ConfigFrequency", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - /* ECO(HE) Mode switch */ + /* ECO(HE) Mode switch, to use when Auto Bypass Mode is on */ { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, /* Auto Bypass Mode on/off */ From 80df4a0286f35b4711e44c09288a6650a16fb34d Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:30:19 +0200 Subject: [PATCH 03/36] add debug log in case out of limits for bypass/eco Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 02dbb23354..7c88591472 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -769,6 +769,13 @@ static const char *eaton_input_eco_mode_check_range(double value) ) { return "ECO"; /* Enter Eco mode */ } else { + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < eco_low || bypass_voltage > eco_high) { + upsdebugx(1, "Bypass voltage out of transfer ECO limits: %.2f V", bypass_voltage); + } + if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { + upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.2f Hz", bypass_frequency); + } return NULL; /* Do not enter Eco mode */ } } @@ -853,6 +860,13 @@ static const char *eaton_input_bypass_check_range(double value) ) { return "on"; /* Enter bypass mode */ } else { + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < bypass_low || bypass_voltage > bypass_high) { + upsdebugx(1, "Bypass voltage out of transfer bypass limits: %.2f V", bypass_voltage); + } + if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { + upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.2f Hz", bypass_frequency); + } return NULL; /* Do not enter bypass mode */ } } From c818bab69560d4e975e0ebe5046a177f20edf0e4 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:35:38 +0200 Subject: [PATCH 04/36] change double to %.1f of voltage and frequency Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 7c88591472..f2b1a8f30e 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -771,10 +771,10 @@ static const char *eaton_input_eco_mode_check_range(double value) } else { /* Condensed debug messages for out of range voltage and frequency */ if (bypass_voltage < eco_low || bypass_voltage > eco_high) { - upsdebugx(1, "Bypass voltage out of transfer ECO limits: %.2f V", bypass_voltage); + upsdebugx(1, "Bypass voltage out of transfer ECO limits: %.1f V", bypass_voltage); } if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.2f Hz", bypass_frequency); + upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.1f Hz", bypass_frequency); } return NULL; /* Do not enter Eco mode */ } @@ -862,10 +862,10 @@ static const char *eaton_input_bypass_check_range(double value) } else { /* Condensed debug messages for out of range voltage and frequency */ if (bypass_voltage < bypass_low || bypass_voltage > bypass_high) { - upsdebugx(1, "Bypass voltage out of transfer bypass limits: %.2f V", bypass_voltage); + upsdebugx(1, "Bypass voltage out of transfer bypass limits: %.1f V", bypass_voltage); } if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.2f Hz", bypass_frequency); + upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.1f Hz", bypass_frequency); } return NULL; /* Do not enter bypass mode */ } From 1ada6b050d17d2fbdf374d50ea6d2ee6435312b7 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:13:04 +0200 Subject: [PATCH 05/36] added input.bypass.switchable Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index f2b1a8f30e..0e1e142482 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1630,7 +1630,7 @@ static hid_info_t mge_hid2nut[] = { "input.transfer.frequency.bypass.range", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.FrequencyRangeBypassTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.transfer.frequency.eco.range", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.FrequencyRangeEcoTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.transfer.hysteresis", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HysteresisVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - /* input.transfer.forced = 1 needs for Bypass Switch On/Off */ + /* input.transfer.forced = 1 needs for Auto Bypass Switch On/Off */ { "input.transfer.forced", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].ForcedTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.trim.high", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HighVoltageBuckTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.sensitivity", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerConverter.Output.SensitivityMode", NULL, "%s", HU_FLAG_SEMI_STATIC, mge_sensitivity_info }, @@ -1658,11 +1658,12 @@ static hid_info_t mge_hid2nut[] = { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, /* Auto Bypass Mode on/off */ - /* needs check this variable, maybe "Bypass switch ability" like Qualify bypass */ - /* { "input.bypass.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_info }, */ { "input.bypass.switch.on", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_on_info }, { "input.bypass.switch.off", ST_FLAG_RW | ST_FLAG_STRING, 12, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_off_info }, + /* Transfer on automatic Bypass switch with rules x.OverloadTransferEnable and x.OutOfToleranceTransferEnable */ + { "input.bypass.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, + /* Output page */ { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.1f", 0, NULL }, { "output.L1-N.voltage", 0, 0, "UPS.PowerConverter.Output.Phase.[1].Voltage", NULL, "%.1f", 0, NULL }, From c1ce63abe0dd9efdb893a85671710262606e8174 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:32:22 +0200 Subject: [PATCH 06/36] added input.transfer.bypass.overload and input.transfer.bypass.outlimits Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 0e1e142482..f06902d5db 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1632,6 +1632,8 @@ static hid_info_t mge_hid2nut[] = { "input.transfer.hysteresis", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HysteresisVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, /* input.transfer.forced = 1 needs for Auto Bypass Switch On/Off */ { "input.transfer.forced", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].ForcedTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, + { "input.transfer.bypass.overload", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OverloadTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, + { "input.transfer.bypass.outlimits", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OutOfToleranceTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.trim.high", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HighVoltageBuckTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.sensitivity", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerConverter.Output.SensitivityMode", NULL, "%s", HU_FLAG_SEMI_STATIC, mge_sensitivity_info }, { "input.voltage.extended", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.ExtendedVoltageMode", NULL, "%s", HU_FLAG_SEMI_STATIC, yes_no_info }, @@ -1661,7 +1663,7 @@ static hid_info_t mge_hid2nut[] = { "input.bypass.switch.on", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_on_info }, { "input.bypass.switch.off", ST_FLAG_RW | ST_FLAG_STRING, 12, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_off_info }, - /* Transfer on automatic Bypass switch with rules x.OverloadTransferEnable and x.OutOfToleranceTransferEnable */ + /* Transfer on automatic Bypass switch with rules 'input.transfer.bypass.overload' and 'input.transfer.bypass.outlimits' */ { "input.bypass.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, /* Output page */ From ba44bc72bf11e77ab48cd4c07e66450c9691b1f3 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:54:54 +0200 Subject: [PATCH 07/36] added to cmdvartab and nut-names.txt Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 9 ++++++--- docs/nut-names.txt | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index ba915cd114..fd5c2e6290 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -68,9 +68,12 @@ VARDESC input.transfer.low.max "greatest settable low voltage transfer point (V) VARDESC input.transfer.high.min "smallest settable high voltage transfer point (V)" VARDESC input.transfer.high.max "greatest settable high voltage transfer point (V)" VARDESC input.eco.switchable "Input High Efficiency (aka ECO) mode switch" -VARDESC input.transfer.forced "Input forced transfer modes enable/disable" -VARDESC input.bypass.switch.on "Put the UPS in bypass mode" -VARDESC input.bypass.switch.off "Take the UPS out of bypass mode" +VARDESC input.transfer.forced "Input forced auto Bypass transfer modes enable/disable" +VARDESC input.transfer.bypass.overload "Rule for auto transfer on Bypass when overload enable/disable" +VARDESC input.transfer.bypass.outlimits "Rule for auto transfer on Bypass when out of tolerance enable/disable" +VARDESC input.bypass.switchable "Input auto transfer on Bypass when overload or out of tolerance enable/disable" +VARDESC input.bypass.switch.on "Put the UPS in Bypass mode" +VARDESC input.bypass.switch.off "Take the UPS out of Bypass mode" VARDESC input.sensitivity "Input power sensitivity" VARDESC input.quality "Input power quality" VARDESC input.current "Input current (A)" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 07a62bbcc0..45e161923d 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -309,6 +309,14 @@ input: Incoming line/power information voltage transfer point (V) | 10 | input.transfer.forced | Input forced transfer modes (enabled or disabled) | enabled +| input.transfer.bypass.overload | Rule for auto transfer on Bypass when + overload (enabled or disabled) | enabled +| input.transfer.bypass.outlimits | Rule for auto transfer on Bypass when + out of tolerance (enabled or disabled) + |enabled +| input.bypass.switchable | Input auto transfer on Bypass when overload + or out of tolerance (enabled or disabled) + | enabled | input.bypass.switch.on | Put the UPS in bypass mode | on | input.bypass.switch.off | Take the UPS out of bypass mode | disabled | input.load | Load on (ePDU) input (percent From 0cd125f166942667618a87df3468a1ae75ae002f Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Tue, 19 Nov 2024 18:58:50 +0200 Subject: [PATCH 08/36] bypass to Bypass in nut-names.txt Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- docs/nut-names.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 45e161923d..b78ea918bc 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -317,8 +317,8 @@ input: Incoming line/power information | input.bypass.switchable | Input auto transfer on Bypass when overload or out of tolerance (enabled or disabled) | enabled -| input.bypass.switch.on | Put the UPS in bypass mode | on -| input.bypass.switch.off | Take the UPS out of bypass mode | disabled +| input.bypass.switch.on | Put the UPS in Bypass mode | on +| input.bypass.switch.off | Take the UPS out of Bypass mode | disabled | input.load | Load on (ePDU) input (percent of full) | 25 | input.realpower | Current sum value of all (ePDU) From 546fdce8b6bad7b615eb2496af2e4e7f89c02e1e Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:07:02 +0200 Subject: [PATCH 09/36] change rest bypass to Bypass Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 4 ++-- docs/nut-names.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index fd5c2e6290..f097624adb 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -237,8 +237,8 @@ CMDDESC test.battery.stop "Stop the battery test" CMDDESC test.system.start "Start a system test" CMDDESC calibrate.start "Start run time calibration" CMDDESC calibrate.stop "Stop run time calibration" -CMDDESC bypass.start "Put the UPS in bypass mode" -CMDDESC bypass.stop "Take the UPS out of bypass mode" +CMDDESC bypass.start "Put the UPS in Bypass mode" +CMDDESC bypass.stop "Take the UPS out of Bypass mode" CMDDESC ecomode.enable "Put UPS in High Efficiency (aka ECO) mode" CMDDESC ecomode.disable "Take the UPS out of High Efficiency (aka ECO) mode" CMDDESC essmode.enable "Put UPS in Energy Saver System (aka ESS) mode" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index b78ea918bc..5ba9bff655 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -879,8 +879,8 @@ Instant commands | test.system.start | Start a system test | calibrate.start | Start runtime calibration | calibrate.stop | Stop runtime calibration -| bypass.start | Put the UPS in bypass mode -| bypass.stop | Take the UPS out of bypass mode +| bypass.start | Put the UPS in Bypass mode +| bypass.stop | Take the UPS out of Bypass mode | ecomode.enable | Put UPS in High Efficiency (aka ECO) mode | ecomode.disable | Take the UPS out of High Efficiency (aka ECO) mode | essmode.enable | Put UPS in Energy Saver System (aka ESS) mode From 937a9537b7273446239fb641625119f7247f5e19 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:07:04 +0200 Subject: [PATCH 10/36] rename input.transfer.forced to input.transfer.bypass.forced Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 2 +- docs/nut-names.txt | 2 +- drivers/mge-hid.c | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index f097624adb..f283e471cc 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -68,7 +68,7 @@ VARDESC input.transfer.low.max "greatest settable low voltage transfer point (V) VARDESC input.transfer.high.min "smallest settable high voltage transfer point (V)" VARDESC input.transfer.high.max "greatest settable high voltage transfer point (V)" VARDESC input.eco.switchable "Input High Efficiency (aka ECO) mode switch" -VARDESC input.transfer.forced "Input forced auto Bypass transfer modes enable/disable" +VARDESC input.transfer.bypass.forced "Input forced auto Bypass transfer modes enable/disable" VARDESC input.transfer.bypass.overload "Rule for auto transfer on Bypass when overload enable/disable" VARDESC input.transfer.bypass.outlimits "Rule for auto transfer on Bypass when out of tolerance enable/disable" VARDESC input.bypass.switchable "Input auto transfer on Bypass when overload or out of tolerance enable/disable" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 5ba9bff655..fb87c065c2 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -307,7 +307,7 @@ input: Incoming line/power information point (percent of nominal Hz) | 5 | input.transfer.hysteresis | Threshold of switching protection modes, voltage transfer point (V) | 10 -| input.transfer.forced | Input forced transfer modes +| input.transfer.bypass.forced | Input forced transfer modes (enabled or disabled) | enabled | input.transfer.bypass.overload | Rule for auto transfer on Bypass when overload (enabled or disabled) | enabled diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index f06902d5db..fc01033a6b 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1630,8 +1630,7 @@ static hid_info_t mge_hid2nut[] = { "input.transfer.frequency.bypass.range", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.FrequencyRangeBypassTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.transfer.frequency.eco.range", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.FrequencyRangeEcoTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.transfer.hysteresis", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HysteresisVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - /* input.transfer.forced = 1 needs for Auto Bypass Switch On/Off */ - { "input.transfer.forced", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].ForcedTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, + { "input.transfer.bypass.forced", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].ForcedTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.bypass.overload", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OverloadTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.bypass.outlimits", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OutOfToleranceTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.trim.high", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HighVoltageBuckTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, @@ -1656,10 +1655,10 @@ static hid_info_t mge_hid2nut[] = { "input.bypass.frequency", 0, 0, "UPS.PowerConverter.Input.[2].Frequency", NULL, "%.1f", 0, NULL }, { "input.bypass.frequency.nominal", 0, 0, "UPS.Flow.[2].ConfigFrequency", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - /* ECO(HE) Mode switch, to use when Auto Bypass Mode is on */ + /* ECO(HE) Mode switch, to use when input.bypass.switch.on is on */ { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, - /* Auto Bypass Mode on/off */ + /* Auto Bypass Mode on/off, to use when input.transfer.bypass.forced is enabled */ { "input.bypass.switch.on", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_on_info }, { "input.bypass.switch.off", ST_FLAG_RW | ST_FLAG_STRING, 12, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_off_info }, From 234cc37ac5ca14c444da15c4c3d060d7b7535bc7 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:11:57 +0200 Subject: [PATCH 11/36] small comments change Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index fc01033a6b..32ec431a75 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -783,7 +783,7 @@ static const char *eaton_input_eco_mode_check_range(double value) /* High Efficiency (aka ECO) mode */ static info_lkp_t eaton_input_eco_mode_on_off_info[] = { { 0, "normal", NULL, NULL }, - { 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ecomode" = tested on 9E model and working fine */ + { 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ECO" = tested on 9E model and working fine */ { 2, "ESS", NULL, NULL }, /* Energy Saver System, makes sense for UPS that implements this mode (93PM G2, 9395P) */ { 0, NULL, NULL, NULL } }; @@ -1769,13 +1769,13 @@ static hid_info_t mge_hid2nut[] = { "outlet.2.load.off", 0, 0, "UPS.OutletSystem.Outlet.[3].DelayBeforeShutdown", NULL, "0", HU_TYPE_CMD, NULL }, { "outlet.2.load.on", 0, 0, "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", NULL, "0", HU_TYPE_CMD, NULL }, - /* Command to switch ECO Mode */ + /* Command to switch ECO(HE) Mode */ { "ecomode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL }, { "ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_eco_mode_on_off_info }, { "essmode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "2", HU_TYPE_CMD, NULL }, { "essmode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL }, - /* Command to switch Automatic Bypass Mode On/Off */ + /* Command to switch Automatic Bypass Mode on/off */ { "bypass.start", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "1", HU_TYPE_CMD, eaton_input_bypass_mode_on_info }, { "bypass.stop", 0, 0, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "1", HU_TYPE_CMD, NULL }, From 2da901205c83d322e4b6e317db610d43783a8261 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:09:02 +0200 Subject: [PATCH 12/36] add ess mode Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/usbhid-ups.c | 10 +++++++--- drivers/usbhid-ups.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index d8c13a5a89..895e3891ef 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -293,6 +293,7 @@ static status_lkp_t status_info[] = { { "bypassauto", STATUS(BYPASSAUTO) }, { "bypassman", STATUS(BYPASSMAN) }, { "ecomode", STATUS(ECOMODE) }, + { "essmode", STATUS(ESSMODE) }, { "off", STATUS(OFF) }, { "cal", STATUS(CALIB) }, { "overheat", STATUS(OVERHEAT) }, @@ -387,7 +388,7 @@ info_lkp_t bypass_manual_info[] = { info_lkp_t eco_mode_info[] = { { 0, "normal", NULL, NULL }, { 1, "ecomode", NULL, NULL }, - { 2, "ESS", NULL, NULL }, /* makes sense for UPS that implements this mode */ + { 2, "essmode", NULL, NULL }, { 0, NULL, NULL, NULL } }; /* note: this value is reverted (0=set, 1=not set). We report "being @@ -2136,7 +2137,7 @@ static void ups_alarm_set(void) } /*if (ups_status & STATUS(ECOMODE)) { alarm_set("ECO(HE) mode!"); - }*/ /* disable alarm for eco as we dont want raise alarm ? */ + }*/ /* disable alarm for eco as we dont want raise alarm ? */ } /* Return the current value of ups_status */ @@ -2444,7 +2445,10 @@ static void ups_status_set(void) status_set("BYPASS"); /* on bypass */ } if (ups_status & STATUS(ECOMODE)) { - status_set("ECO"); /* on ECO Mode */ + status_set("ECO"); /* on ECO(HE) Mode */ + } + if (ups_status & STATUS(ESSMODE)) { + status_set("ESS"); /* on ESS Mode */ } if (ups_status & STATUS(OFF)) { status_set("OFF"); /* ups is off */ diff --git a/drivers/usbhid-ups.h b/drivers/usbhid-ups.h index e992aea330..6da83ae9da 100644 --- a/drivers/usbhid-ups.h +++ b/drivers/usbhid-ups.h @@ -144,6 +144,7 @@ typedef enum { BYPASSAUTO, /* on automatic bypass */ BYPASSMAN, /* on manual/service bypass */ ECOMODE, /* High Efficiency (aka ECO Mode) */ + ESSMODE, /* Energy Saver System */ OFF, /* ups is off */ CALIB, /* calibration */ OVERHEAT, /* overheat; Belkin, TrippLite */ From 43469703de39c4d9bb90cc6b7242a4f71bb6b7bc Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:11:46 +0200 Subject: [PATCH 13/36] small comment added Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/usbhid-ups.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usbhid-ups.h b/drivers/usbhid-ups.h index 6da83ae9da..93cc6d231a 100644 --- a/drivers/usbhid-ups.h +++ b/drivers/usbhid-ups.h @@ -144,7 +144,7 @@ typedef enum { BYPASSAUTO, /* on automatic bypass */ BYPASSMAN, /* on manual/service bypass */ ECOMODE, /* High Efficiency (aka ECO Mode) */ - ESSMODE, /* Energy Saver System */ + ESSMODE, /* Energy Saver System Mode */ OFF, /* ups is off */ CALIB, /* calibration */ OVERHEAT, /* overheat; Belkin, TrippLite */ From 9087d5f50f4f4d35e6cb5b9e3839d057cac83824 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:17:26 +0200 Subject: [PATCH 14/36] small comments change Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 32ec431a75..bb60a8bcdb 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -780,11 +780,11 @@ static const char *eaton_input_eco_mode_check_range(double value) } } -/* High Efficiency (aka ECO) mode */ +/* High Efficiency (aka ECO) mode, Energy Saver System (aka ESS) mode makes sense for UPS like (93PM G2, 9395P) */ static info_lkp_t eaton_input_eco_mode_on_off_info[] = { { 0, "normal", NULL, NULL }, { 1, "ECO", eaton_input_eco_mode_check_range, NULL }, /* NOTE: "ECO" = tested on 9E model and working fine */ - { 2, "ESS", NULL, NULL }, /* Energy Saver System, makes sense for UPS that implements this mode (93PM G2, 9395P) */ + { 2, "ESS", NULL, NULL }, { 0, NULL, NULL, NULL } }; From 24be33d030dd415cc8ab39a7687398018e3d4213 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:23:48 +0200 Subject: [PATCH 15/36] small comments added Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index bb60a8bcdb..1780594d58 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1578,7 +1578,7 @@ static hid_info_t mge_hid2nut[] = /* NOTE: entry [3] is above as mge_onbatt_info */ { "BOOL", 0, 0, "UPS.PowerConverter.Input.[4].PresentStatus.Used", NULL, NULL, 0, bypass_manual_info }, /* Manual bypass */ /* NOTE: needs to be tested */ - { "BOOL", 0, 0, "UPS.PowerConverter.Input.[5].PresentStatus.Used", NULL, NULL, 0, eco_mode_info }, /* ECO/HE Mode */ + { "BOOL", 0, 0, "UPS.PowerConverter.Input.[5].PresentStatus.Used", NULL, NULL, 0, eco_mode_info }, /* ECO(HE),ESS Mode */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FanFailure", NULL, NULL, 0, fanfail_info }, { "BOOL", 0, 0, "UPS.BatterySystem.Battery.PresentStatus.Present", NULL, NULL, 0, nobattery_info }, { "BOOL", 0, 0, "UPS.BatterySystem.Charger.PresentStatus.InternalFailure", NULL, NULL, 0, chargerfail_info }, From e35c2a0b33599fbfe749f08a8c461acf46709949 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Thu, 21 Nov 2024 01:47:35 +0200 Subject: [PATCH 16/36] fix nut-names.txt Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- docs/nut-names.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nut-names.txt b/docs/nut-names.txt index fb87c065c2..ab72fcad70 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -313,7 +313,7 @@ input: Incoming line/power information overload (enabled or disabled) | enabled | input.transfer.bypass.outlimits | Rule for auto transfer on Bypass when out of tolerance (enabled or disabled) - |enabled + | enabled | input.bypass.switchable | Input auto transfer on Bypass when overload or out of tolerance (enabled or disabled) | enabled From f1d6b6bf74bbde141cdf5569a13338c8a4aad0de Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Thu, 21 Nov 2024 02:23:32 +0200 Subject: [PATCH 17/36] fix again Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- docs/nut-names.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nut-names.txt b/docs/nut-names.txt index ab72fcad70..2c4f3b0887 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -303,7 +303,7 @@ input: Incoming line/power information transfer point (V) | 264 | input.transfer.frequency.bypass.range | Frequency range Bypass transfer point (percent of nominal Hz) | 10 -| input.transfer.frequency.eco.range | Frequency range ECO transfer +| input.transfer.frequency.eco.range | Frequency range ECO transfer point (percent of nominal Hz) | 5 | input.transfer.hysteresis | Threshold of switching protection modes, voltage transfer point (V) | 10 From 3bd957e8678d3eaa0f6eb0bfef63713f9b4588c5 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:01:52 +0200 Subject: [PATCH 18/36] more small comments changes Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 1780594d58..866fbf5fef 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1655,10 +1655,10 @@ static hid_info_t mge_hid2nut[] = { "input.bypass.frequency", 0, 0, "UPS.PowerConverter.Input.[2].Frequency", NULL, "%.1f", 0, NULL }, { "input.bypass.frequency.nominal", 0, 0, "UPS.Flow.[2].ConfigFrequency", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - /* ECO(HE) Mode switch, to use when input.bypass.switch.on is on */ + /* ECO(HE), ESS Mode switch, to use when 'input.bypass.switch.on' is on */ { "input.eco.switchable", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[5].Switchable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_eco_mode_on_off_info }, - /* Auto Bypass Mode on/off, to use when input.transfer.bypass.forced is enabled */ + /* Auto Bypass Mode on/off, to use when 'input.transfer.bypass.forced' is enabled */ { "input.bypass.switch.on", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].SwitchOnControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_on_info }, { "input.bypass.switch.off", ST_FLAG_RW | ST_FLAG_STRING, 12, "UPS.PowerConverter.Input.[2].SwitchOffControl", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_input_bypass_mode_off_info }, @@ -1769,7 +1769,7 @@ static hid_info_t mge_hid2nut[] = { "outlet.2.load.off", 0, 0, "UPS.OutletSystem.Outlet.[3].DelayBeforeShutdown", NULL, "0", HU_TYPE_CMD, NULL }, { "outlet.2.load.on", 0, 0, "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", NULL, "0", HU_TYPE_CMD, NULL }, - /* Command to switch ECO(HE) Mode */ + /* Command to switch ECO(HE), ESS Mode */ { "ecomode.disable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "0", HU_TYPE_CMD, NULL }, { "ecomode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "1", HU_TYPE_CMD, eaton_input_eco_mode_on_off_info }, { "essmode.enable", 0, 0, "UPS.PowerConverter.Input.[5].Switchable", NULL, "2", HU_TYPE_CMD, NULL }, From 22a9d85d5fb6d6e4868146c871deeb11e2429f37 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:22:29 +0200 Subject: [PATCH 19/36] comments changes Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 3 +-- drivers/usbhid-ups.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 866fbf5fef..6d604f3893 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -1577,8 +1577,7 @@ static hid_info_t mge_hid2nut[] = { "BOOL", 0, 0, "UPS.PowerConverter.Input.[2].PresentStatus.Used", NULL, NULL, 0, bypass_auto_info }, /* Automatic bypass */ /* NOTE: entry [3] is above as mge_onbatt_info */ { "BOOL", 0, 0, "UPS.PowerConverter.Input.[4].PresentStatus.Used", NULL, NULL, 0, bypass_manual_info }, /* Manual bypass */ - /* NOTE: needs to be tested */ - { "BOOL", 0, 0, "UPS.PowerConverter.Input.[5].PresentStatus.Used", NULL, NULL, 0, eco_mode_info }, /* ECO(HE),ESS Mode */ + { "BOOL", 0, 0, "UPS.PowerConverter.Input.[5].PresentStatus.Used", NULL, NULL, 0, eco_mode_info }, /* ECO(HE), ESS Mode */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FanFailure", NULL, NULL, 0, fanfail_info }, { "BOOL", 0, 0, "UPS.BatterySystem.Battery.PresentStatus.Present", NULL, NULL, 0, nobattery_info }, { "BOOL", 0, 0, "UPS.BatterySystem.Charger.PresentStatus.InternalFailure", NULL, NULL, 0, chargerfail_info }, diff --git a/drivers/usbhid-ups.h b/drivers/usbhid-ups.h index 93cc6d231a..af3c673f9e 100644 --- a/drivers/usbhid-ups.h +++ b/drivers/usbhid-ups.h @@ -144,7 +144,7 @@ typedef enum { BYPASSAUTO, /* on automatic bypass */ BYPASSMAN, /* on manual/service bypass */ ECOMODE, /* High Efficiency (aka ECO Mode) */ - ESSMODE, /* Energy Saver System Mode */ + ESSMODE, /* Energy Saver System (aka ESS Mode) */ OFF, /* ups is off */ CALIB, /* calibration */ OVERHEAT, /* overheat; Belkin, TrippLite */ From dc2a23e9655e29edd7a084cb0de02464a39829a3 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:35:06 +0200 Subject: [PATCH 20/36] change enable/disable to (enabled or disabled) in cmdvartab Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index f283e471cc..10e3f00984 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -68,10 +68,10 @@ VARDESC input.transfer.low.max "greatest settable low voltage transfer point (V) VARDESC input.transfer.high.min "smallest settable high voltage transfer point (V)" VARDESC input.transfer.high.max "greatest settable high voltage transfer point (V)" VARDESC input.eco.switchable "Input High Efficiency (aka ECO) mode switch" -VARDESC input.transfer.bypass.forced "Input forced auto Bypass transfer modes enable/disable" -VARDESC input.transfer.bypass.overload "Rule for auto transfer on Bypass when overload enable/disable" -VARDESC input.transfer.bypass.outlimits "Rule for auto transfer on Bypass when out of tolerance enable/disable" -VARDESC input.bypass.switchable "Input auto transfer on Bypass when overload or out of tolerance enable/disable" +VARDESC input.transfer.bypass.forced "Input forced auto Bypass transfer modes (enabled or disabled)" +VARDESC input.transfer.bypass.overload "Rule for auto transfer on Bypass when overload (enabled or disabled)" +VARDESC input.transfer.bypass.outlimits "Rule for auto transfer on Bypass when out of tolerance (enabled or disabled)" +VARDESC input.bypass.switchable "Input auto transfer on Bypass when overload or out of tolerance (enabled or disabled)" VARDESC input.bypass.switch.on "Put the UPS in Bypass mode" VARDESC input.bypass.switch.off "Take the UPS out of Bypass mode" VARDESC input.sensitivity "Input power sensitivity" From 995da6aa27f48c6d45a42aa94b40c3dc092a9d3f Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:58:27 +0200 Subject: [PATCH 21/36] more clear description for input.transfer.bypass.forced Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 2 +- docs/nut-names.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index 10e3f00984..352150bdbf 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -68,7 +68,7 @@ VARDESC input.transfer.low.max "greatest settable low voltage transfer point (V) VARDESC input.transfer.high.min "smallest settable high voltage transfer point (V)" VARDESC input.transfer.high.max "greatest settable high voltage transfer point (V)" VARDESC input.eco.switchable "Input High Efficiency (aka ECO) mode switch" -VARDESC input.transfer.bypass.forced "Input forced auto Bypass transfer modes (enabled or disabled)" +VARDESC input.transfer.bypass.forced "Input forced auto Bypass switch (on/off) transfer modes (enabled or disabled)" VARDESC input.transfer.bypass.overload "Rule for auto transfer on Bypass when overload (enabled or disabled)" VARDESC input.transfer.bypass.outlimits "Rule for auto transfer on Bypass when out of tolerance (enabled or disabled)" VARDESC input.bypass.switchable "Input auto transfer on Bypass when overload or out of tolerance (enabled or disabled)" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 2c4f3b0887..839833ad0b 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -307,7 +307,8 @@ input: Incoming line/power information point (percent of nominal Hz) | 5 | input.transfer.hysteresis | Threshold of switching protection modes, voltage transfer point (V) | 10 -| input.transfer.bypass.forced | Input forced transfer modes +| input.transfer.bypass.forced | Input forced auto Bypass switch + (on/off) transfer modes (enabled or disabled) | enabled | input.transfer.bypass.overload | Rule for auto transfer on Bypass when overload (enabled or disabled) | enabled From 0f04a56987c415fd26b1e3eb9422bf575e408ecf Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:02:27 +0200 Subject: [PATCH 22/36] much clear description for input.transfer.bypass.forced Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- data/cmdvartab | 2 +- docs/nut-names.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/cmdvartab b/data/cmdvartab index 352150bdbf..0fa48d55aa 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -68,7 +68,7 @@ VARDESC input.transfer.low.max "greatest settable low voltage transfer point (V) VARDESC input.transfer.high.min "smallest settable high voltage transfer point (V)" VARDESC input.transfer.high.max "greatest settable high voltage transfer point (V)" VARDESC input.eco.switchable "Input High Efficiency (aka ECO) mode switch" -VARDESC input.transfer.bypass.forced "Input forced auto Bypass switch (on/off) transfer modes (enabled or disabled)" +VARDESC input.transfer.bypass.forced "Rule for allow auto Bypass switch (on/off) transfer modes (enabled or disabled)" VARDESC input.transfer.bypass.overload "Rule for auto transfer on Bypass when overload (enabled or disabled)" VARDESC input.transfer.bypass.outlimits "Rule for auto transfer on Bypass when out of tolerance (enabled or disabled)" VARDESC input.bypass.switchable "Input auto transfer on Bypass when overload or out of tolerance (enabled or disabled)" diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 839833ad0b..74bb0eb11f 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -307,7 +307,7 @@ input: Incoming line/power information point (percent of nominal Hz) | 5 | input.transfer.hysteresis | Threshold of switching protection modes, voltage transfer point (V) | 10 -| input.transfer.bypass.forced | Input forced auto Bypass switch +| input.transfer.bypass.forced | Rule for allow auto Bypass switch (on/off) transfer modes (enabled or disabled) | enabled | input.transfer.bypass.overload | Rule for auto transfer on Bypass when From c736ae865c19d3b112c4ee06df0e629991b1029e Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:04:17 +0200 Subject: [PATCH 23/36] change vars in eaton_input_bypass_check_range() Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 151 +++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 6d604f3893..37feeb9308 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -791,84 +791,85 @@ static info_lkp_t eaton_input_eco_mode_on_off_info[] = { /* Function to check if the current bypass voltage/frequency is within the configured limits */ static const char *eaton_input_bypass_check_range(double value) { - double bypass_voltage; - double bypass_low; - double bypass_high; - double out_nominal; - double bypass_frequency; - double frequency_range; - double lower_frequency_limit; - double upper_frequency_limit; - double out_frequency_nominal; - + double bypass_voltage; + double bypass_low_transfer; + double bypass_high_transfer; + double out_voltage_nominal; + double bypass_frequency; + double frequency_range_transfer; + double lower_frequency_limit; + double upper_frequency_limit; + double out_frequency_nominal; + + NUT_UNUSED_VARIABLE(value); /* Get the bypass voltage/frequency and transfer points */ - const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); - const char* bypass_low_str = dstate_getinfo("input.transfer.bypass.low"); - const char* bypass_high_str = dstate_getinfo("input.transfer.bypass.high"); - const char* out_nominal_str = dstate_getinfo("output.voltage.nominal"); - const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); - const char* frequency_range_str = dstate_getinfo("input.transfer.frequency.bypass.range"); - const char* out_nominal_frequency_str = dstate_getinfo("output.frequency.nominal"); - - NUT_UNUSED_VARIABLE(value); - - if (bypass_voltage_str == NULL || bypass_low_str == NULL - || bypass_high_str == NULL || out_nominal_str == NULL - || bypass_frequency_str == NULL || frequency_range_str == NULL - || out_nominal_frequency_str == NULL - ) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s, %s, %s, %s", - bypass_voltage_str, bypass_low_str, bypass_high_str, out_nominal_str, - bypass_frequency_str, frequency_range_str, out_nominal_frequency_str); - return NULL; /* Handle the error appropriately */ - } - - str_to_double(bypass_voltage_str, &bypass_voltage, 10); - str_to_double(bypass_low_str, &bypass_low, 10); - str_to_double(bypass_high_str, &bypass_high, 10); - str_to_double(out_nominal_str, &out_nominal, 10); - str_to_double(bypass_frequency_str, &bypass_frequency, 10); - str_to_double(frequency_range_str, &frequency_range, 10); - str_to_double(out_nominal_frequency_str, &out_frequency_nominal, 10); - - /* Default values if user-defined limits are not available or out of range - 20% below nominal output voltage - 15% above nominal output voltage - 10% below/above output frequency nominal - */ - - /* Set the frequency limit */ - if (frequency_range > 0) { - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range); - upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range); - } else { - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 10); - upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 10); - } - - /* Check if user-defined limits are available and within valid range */ - if ((bypass_low > 0 && bypass_high > 0) - && (bypass_voltage >= bypass_low && bypass_voltage <= bypass_high) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { - return "on"; /* Enter bypass mode */ - } + const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); + const char* bypass_low_transfer_str = dstate_getinfo("input.transfer.bypass.low"); + const char* bypass_high_transfer_str = dstate_getinfo("input.transfer.bypass.high"); + const char* out_voltage_nominal_str = dstate_getinfo("output.voltage.nominal"); + const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); + const char* frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.bypass.range"); + const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); + + if (bypass_voltage_str == NULL || bypass_low_transfer_str == NULL + || bypass_high_transfer_str == NULL || out_voltage_nominal_str == NULL + || bypass_frequency_str == NULL || frequency_range_transfer_str == NULL + || out_frequency_nominal_str == NULL + ) { + upsdebugx(1, "Failed to get values: %s, %s, %s, %s, %s, %s, %s", + bypass_voltage_str, bypass_low_transfer_str, bypass_high_transfer_str, + out_voltage_nominal_str, bypass_frequency_str, frequency_range_transfer_str, + out_frequency_nominal_str); + return NULL; /* Handle the error appropriately */ + } + + str_to_double(bypass_voltage_str, &bypass_voltage, 10); + str_to_double(bypass_low_transfer_str, &bypass_low_transfer, 10); + str_to_double(bypass_high_transfer_str, &bypass_high_transfer, 10); + str_to_double(out_voltage_nominal_str, &out_voltage_nominal, 10); + str_to_double(bypass_frequency_str, &bypass_frequency, 10); + str_to_double(frequency_range_transfer_str, &frequency_range_transfer, 10); + str_to_double(out_frequency_nominal_str, &out_frequency_nominal, 10); + + /* Default values if user-defined limits are not available or out of range + 20% below nominal output voltage + 15% above nominal output voltage + 10% below/above output frequency nominal + */ + + /* Set the frequency limit */ + if (frequency_range_transfer > 0) { + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); + upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); + } else { + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 10); + upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 10); + } + + /* Check if user-defined limits are available and within valid range */ + if ((bypass_low_transfer > 0 && bypass_high_transfer > 0) + && (bypass_voltage >= bypass_low_transfer && bypass_voltage <= bypass_high_transfer) + && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) + ) { + return "on"; /* Enter bypass mode */ + } - if ((bypass_voltage >= out_nominal * 0.8 && bypass_voltage <= out_nominal * 1.15) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { - return "on"; /* Enter bypass mode */ - } else { - /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < bypass_low || bypass_voltage > bypass_high) { - upsdebugx(1, "Bypass voltage out of transfer bypass limits: %.1f V", bypass_voltage); - } - if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.1f Hz", bypass_frequency); - } - return NULL; /* Do not enter bypass mode */ - } + /* Check if default limits are within valid range */ + if ((bypass_voltage >= out_voltage_nominal * 0.8 && bypass_voltage <= out_voltage_nominal * 1.15) + && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) + ) { + return "on"; /* Enter bypass mode */ + } else { + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < bypass_low_transfer || bypass_voltage > bypass_high_transfer) { + upsdebugx(1, "Bypass voltage out of transfer bypass limits: %.1f V", bypass_voltage); + } + if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { + upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.1f Hz", bypass_frequency); + } + return NULL; /* Do not enter bypass mode */ + } } /* Automatic Bypass mode on */ From 4d7f9558595118b1c361fed3c40851768bc68247 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:31:26 +0200 Subject: [PATCH 24/36] change vars in eaton_input_eco_mode_check_range() Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 140 +++++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 37feeb9308..2889c508a1 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -698,86 +698,88 @@ static info_lkp_t outlet_eco_yes_no_info[] = { /* Function to check if the current High Efficiency (aka ECO) mode voltage/frequency is within the configured limits */ static const char *eaton_input_eco_mode_check_range(double value) { - double bypass_voltage; - double eco_low; - double eco_high; - double out_nominal; + double bypass_voltage; + double eco_low_transfer; + double eco_high_transfer; + double out_voltage_nominal; double out_frequency_nominal; double bypass_frequency; - double frequency_range; - double lower_frequency_limit; - double upper_frequency_limit; - - /* Get the Eco mode voltage/frequency and transfer points */ - const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); - const char* eco_low_str = dstate_getinfo("input.transfer.eco.low"); - const char* eco_high_str = dstate_getinfo("input.transfer.eco.high"); - const char* out_nominal_str = dstate_getinfo("output.voltage.nominal"); - const char* out_nominal_frequency_str = dstate_getinfo("output.frequency.nominal"); - const char* frequency_range_str = dstate_getinfo("input.transfer.frequency.eco.range"); - const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); + double frequency_range_transfer; + double lower_frequency_limit; + double upper_frequency_limit; - NUT_UNUSED_VARIABLE(value); + NUT_UNUSED_VARIABLE(value); + + /* Get the ECO mode voltage/frequency and transfer points */ + const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); + const char* eco_low_transfer_str = dstate_getinfo("input.transfer.eco.low"); + const char* eco_high_transfer_str = dstate_getinfo("input.transfer.eco.high"); + const char* out_voltage_nominal_str = dstate_getinfo("output.voltage.nominal"); + const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); + const char* frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.eco.range"); + const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); - if (eco_low_str == NULL || eco_high_str == NULL - || bypass_voltage_str == NULL || bypass_frequency_str == NULL - || out_nominal_str == NULL || out_nominal_frequency_str == NULL - || frequency_range_str == NULL - ) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s, %s, %s, %s", - eco_low_str, eco_high_str, - bypass_voltage_str, bypass_frequency_str, - out_nominal_str, out_nominal_frequency_str, - frequency_range_str); - return NULL; /* Handle the error appropriately */ - } - str_to_double(bypass_voltage_str, &bypass_voltage, 10); - str_to_double(eco_low_str, &eco_low, 10); - str_to_double(eco_high_str, &eco_high, 10); - str_to_double(out_nominal_str, &out_nominal, 10); - str_to_double(out_nominal_frequency_str, &out_frequency_nominal, 10); - str_to_double(frequency_range_str, &frequency_range, 10); + + if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL + || bypass_voltage_str == NULL || bypass_frequency_str == NULL + || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL + || frequency_range_transfer_str == NULL + ) { + upsdebugx(1, "Failed to get values: %s, %s, %s, %s, %s, %s, %s", + eco_low_transfer_str, eco_high_transfer_str, + bypass_voltage_str, bypass_frequency_str, + out_voltage_nominal_str, out_frequency_nominal_str, + frequency_range_transfer_str); + return NULL; /* Handle the error appropriately */ + } + + str_to_double(bypass_voltage_str, &bypass_voltage, 10); + str_to_double(eco_low_transfer_str, &eco_low_transfer, 10); + str_to_double(eco_high_transfer_str, &eco_high_transfer, 10); + str_to_double(out_voltage_nominal_str, &out_voltage_nominal, 10); + str_to_double(out_frequency_nominal_str, &out_frequency_nominal, 10); + str_to_double(frequency_range_transfer_str, &frequency_range_transfer, 10); str_to_double(bypass_frequency_str, &bypass_frequency, 10); - /* Default values if user-defined limits are not available or out of range - 5% below nominal output voltage - 5% above nominal output voltage - 5% below/above output frequency nominal - */ + /* Default values if user-defined limits are not available or out of range + 5% below nominal output voltage + 5% above nominal output voltage + 5% below/above output frequency nominal + */ - /* Set the frequency limit */ - if (frequency_range > 0) { - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range); - upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range); - } else { - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 5); + /* Set the frequency limit */ + if (frequency_range_transfer > 0) { + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); + upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); + } else { + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 5); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 5); - } + } - /* Check if user-defined limits are available and within valid range */ - if ((eco_low > 0 && eco_high > 0) - && (bypass_voltage >= eco_low && bypass_voltage <= eco_high) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { - return "ECO"; /* Enter Eco mode */ - } + /* Check if user-defined limits are available and within valid range */ + if ((eco_low_transfer > 0 && eco_high_transfer > 0) + && (bypass_voltage >= eco_low_transfer && bypass_voltage <= eco_high_transfer) + && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) + ) { + return "ECO"; /* Enter Eco mode */ + } - /* Default values if user-defined limits are not available or out of range */ - if ((bypass_voltage >= out_nominal * 0.95 && bypass_voltage <= out_nominal * 1.05) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { - return "ECO"; /* Enter Eco mode */ - } else { - /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < eco_low || bypass_voltage > eco_high) { - upsdebugx(1, "Bypass voltage out of transfer ECO limits: %.1f V", bypass_voltage); - } - if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.1f Hz", bypass_frequency); - } - return NULL; /* Do not enter Eco mode */ - } + /* Default values if user-defined limits are not available or out of range */ + if ((bypass_voltage >= out_voltage_nominal * 0.95 && bypass_voltage <= out_voltage_nominal * 1.05) + && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) + ) { + return "ECO"; /* Enter Eco mode */ + } else { + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < eco_low_transfer || bypass_voltage > eco_high_transfer) { + upsdebugx(1, "Bypass voltage out of transfer ECO limits: %.1f V", bypass_voltage); + } + if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { + upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.1f Hz", bypass_frequency); + } + return NULL; /* Do not enter Eco mode */ + } } /* High Efficiency (aka ECO) mode, Energy Saver System (aka ESS) mode makes sense for UPS like (93PM G2, 9395P) */ From 39c17ca9c4611c76b6f02bcba69fd61cf282e47c Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:05:07 +0200 Subject: [PATCH 25/36] change the state for debug when no eco transfer limits avalible to use defaults Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 2889c508a1..e1b3896bbe 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -721,18 +721,27 @@ static const char *eaton_input_eco_mode_check_range(double value) + if (bypass_voltage_str == NULL || bypass_frequency_str == NULL + || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL) { + upsdebugx(1, "Failed to get values: %s, %s, %s, %s", + bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", + bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", + out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", + out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); + return NULL; /* Handle the error appropriately */ +} + /* In case we dont have ECO transfer limit variables but still have ability to enter Bypass/ECO modes, + * will use default limits later in code. + * Possibly like reported by debug log for 9SX1000i https://github.com/networkupstools/nut/issues/2685 + */ if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL - || bypass_voltage_str == NULL || bypass_frequency_str == NULL - || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL - || frequency_range_transfer_str == NULL - ) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s, %s, %s, %s", - eco_low_transfer_str, eco_high_transfer_str, - bypass_voltage_str, bypass_frequency_str, - out_voltage_nominal_str, out_frequency_nominal_str, - frequency_range_transfer_str); - return NULL; /* Handle the error appropriately */ - } + || frequency_range_transfer_str == NULL) { + upsdebugx(1, "Failed to get values: %s, %s, %s", + eco_low_transfer_str ? eco_low_transfer_str : "eco.low.transfer = NULL", + eco_high_transfer_str ? eco_high_transfer_str : "eco.high.transfer = NULL", + frequency_range_transfer_str ? frequency_range_transfer_str : "frequency.range.transfer = NULL"); + /* Not return NULL, We will use default values for limits */ +} str_to_double(bypass_voltage_str, &bypass_voltage, 10); str_to_double(eco_low_transfer_str, &eco_low_transfer, 10); @@ -762,14 +771,14 @@ static const char *eaton_input_eco_mode_check_range(double value) && (bypass_voltage >= eco_low_transfer && bypass_voltage <= eco_high_transfer) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { - return "ECO"; /* Enter Eco mode */ + return "ECO"; /* Enter ECO mode */ } /* Default values if user-defined limits are not available or out of range */ if ((bypass_voltage >= out_voltage_nominal * 0.95 && bypass_voltage <= out_voltage_nominal * 1.05) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { - return "ECO"; /* Enter Eco mode */ + return "ECO"; /* Enter ECO mode */ } else { /* Condensed debug messages for out of range voltage and frequency */ if (bypass_voltage < eco_low_transfer || bypass_voltage > eco_high_transfer) { @@ -778,7 +787,7 @@ static const char *eaton_input_eco_mode_check_range(double value) if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.1f Hz", bypass_frequency); } - return NULL; /* Do not enter Eco mode */ + return NULL; /* Do not enter ECO mode */ } } @@ -857,7 +866,7 @@ static const char *eaton_input_bypass_check_range(double value) return "on"; /* Enter bypass mode */ } - /* Check if default limits are within valid range */ + /* Default values if user-defined limits are not available or out of range */ if ((bypass_voltage >= out_voltage_nominal * 0.8 && bypass_voltage <= out_voltage_nominal * 1.15) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { From 000d03a5a958ba4d14ee05f9a7c469c3425f185a Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:35:57 +0200 Subject: [PATCH 26/36] move NUT_UNUSED_VARIABLE(value); back down Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index e1b3896bbe..439b8c5150 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -708,8 +708,6 @@ static const char *eaton_input_eco_mode_check_range(double value) double lower_frequency_limit; double upper_frequency_limit; - NUT_UNUSED_VARIABLE(value); - /* Get the ECO mode voltage/frequency and transfer points */ const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); const char* eco_low_transfer_str = dstate_getinfo("input.transfer.eco.low"); @@ -719,7 +717,7 @@ static const char *eaton_input_eco_mode_check_range(double value) const char* frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.eco.range"); const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); - + NUT_UNUSED_VARIABLE(value); if (bypass_voltage_str == NULL || bypass_frequency_str == NULL || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL) { @@ -732,7 +730,7 @@ static const char *eaton_input_eco_mode_check_range(double value) } /* In case we dont have ECO transfer limit variables but still have ability to enter Bypass/ECO modes, * will use default limits later in code. - * Possibly like reported by debug log for 9SX1000i https://github.com/networkupstools/nut/issues/2685 + * Possibly reported by debug log for 9SX1000i https://github.com/networkupstools/nut/issues/2685 */ if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL || frequency_range_transfer_str == NULL) { @@ -799,7 +797,7 @@ static info_lkp_t eaton_input_eco_mode_on_off_info[] = { { 0, NULL, NULL, NULL } }; -/* Function to check if the current bypass voltage/frequency is within the configured limits */ +/* Function to check if the current Bypass transfer voltage/frequency is within the configured limits */ static const char *eaton_input_bypass_check_range(double value) { double bypass_voltage; @@ -812,9 +810,7 @@ static const char *eaton_input_bypass_check_range(double value) double upper_frequency_limit; double out_frequency_nominal; - NUT_UNUSED_VARIABLE(value); - - /* Get the bypass voltage/frequency and transfer points */ + /* Get the Bypass mode voltage/frequency and transfer points */ const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); const char* bypass_low_transfer_str = dstate_getinfo("input.transfer.bypass.low"); const char* bypass_high_transfer_str = dstate_getinfo("input.transfer.bypass.high"); @@ -823,6 +819,8 @@ static const char *eaton_input_bypass_check_range(double value) const char* frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.bypass.range"); const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); + NUT_UNUSED_VARIABLE(value); + if (bypass_voltage_str == NULL || bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL || out_voltage_nominal_str == NULL || bypass_frequency_str == NULL || frequency_range_transfer_str == NULL @@ -863,14 +861,14 @@ static const char *eaton_input_bypass_check_range(double value) && (bypass_voltage >= bypass_low_transfer && bypass_voltage <= bypass_high_transfer) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { - return "on"; /* Enter bypass mode */ + return "on"; /* Enter Bypass mode */ } /* Default values if user-defined limits are not available or out of range */ if ((bypass_voltage >= out_voltage_nominal * 0.8 && bypass_voltage <= out_voltage_nominal * 1.15) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { - return "on"; /* Enter bypass mode */ + return "on"; /* Enter Bypass mode */ } else { /* Condensed debug messages for out of range voltage and frequency */ if (bypass_voltage < bypass_low_transfer || bypass_voltage > bypass_high_transfer) { @@ -879,7 +877,7 @@ static const char *eaton_input_bypass_check_range(double value) if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.1f Hz", bypass_frequency); } - return NULL; /* Do not enter bypass mode */ + return NULL; /* Do not enter Bypass mode */ } } From 9d1048e836fabd5680b673a1f0101a5281083a84 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:41:51 +0200 Subject: [PATCH 27/36] change voltage limit setting same as frequency Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 439b8c5150..49c052f4e0 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -808,6 +808,8 @@ static const char *eaton_input_bypass_check_range(double value) double frequency_range_transfer; double lower_frequency_limit; double upper_frequency_limit; + double lower_voltage_limit; + double upper_voltage_limit; double out_frequency_nominal; /* Get the Bypass mode voltage/frequency and transfer points */ @@ -852,30 +854,33 @@ static const char *eaton_input_bypass_check_range(double value) lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); } else { + /* Set default values if user-defined limits are not available or out of range */ lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 10); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 10); } - /* Check if user-defined limits are available and within valid range */ - if ((bypass_low_transfer > 0 && bypass_high_transfer > 0) - && (bypass_voltage >= bypass_low_transfer && bypass_voltage <= bypass_high_transfer) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { - return "on"; /* Enter Bypass mode */ - } + /* Set the voltage limit */ + if (bypass_low_transfer > 0 && bypass_high_transfer > 0) { + lower_voltage_limit = bypass_low_transfer; + upper_voltage_limit = bypass_high_transfer; + } else { + /* Set default values if user-defined limits are not available or out of range */ + lower_voltage_limit = out_voltage_nominal * 0.8; + upper_voltage_limit = out_voltage_nominal * 1.15; + } - /* Default values if user-defined limits are not available or out of range */ - if ((bypass_voltage >= out_voltage_nominal * 0.8 && bypass_voltage <= out_voltage_nominal * 1.15) + /* Check if limits are within valid range */ + if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { return "on"; /* Enter Bypass mode */ } else { /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < bypass_low_transfer || bypass_voltage > bypass_high_transfer) { - upsdebugx(1, "Bypass voltage out of transfer bypass limits: %.1f V", bypass_voltage); + if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { + upsdebugx(1, "Input Bypass voltage is outside Bypass transfer limits: %.1f V", bypass_voltage); } if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Bypass frequency out of transfer bypass limits: %.1f Hz", bypass_frequency); + upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency); } return NULL; /* Do not enter Bypass mode */ } From 239123f393d0aede6a65fc78fbf32209eddbdd8d Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Fri, 29 Nov 2024 20:18:38 +0200 Subject: [PATCH 28/36] change voltage limit setting same as frequency in eco function also Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 49c052f4e0..507bdcf3d0 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -707,6 +707,8 @@ static const char *eaton_input_eco_mode_check_range(double value) double frequency_range_transfer; double lower_frequency_limit; double upper_frequency_limit; + double lower_voltage_limit; + double upper_voltage_limit; /* Get the ECO mode voltage/frequency and transfer points */ const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); @@ -760,30 +762,33 @@ static const char *eaton_input_eco_mode_check_range(double value) lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); } else { + /* Set default values if user-defined limits are not available or out of range */ lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 5); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 5); } - /* Check if user-defined limits are available and within valid range */ - if ((eco_low_transfer > 0 && eco_high_transfer > 0) - && (bypass_voltage >= eco_low_transfer && bypass_voltage <= eco_high_transfer) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { - return "ECO"; /* Enter ECO mode */ + /* Set the voltage limit */ + if (eco_low_transfer > 0 && eco_high_transfer > 0) { + lower_voltage_limit = eco_low_transfer; + upper_voltage_limit = eco_high_transfer; + } else { + /* Set default values if user-defined limits are not available or out of range */ + lower_voltage_limit = out_voltage_nominal * 0.95; + upper_voltage_limit = out_voltage_nominal * 1.05; } - /* Default values if user-defined limits are not available or out of range */ - if ((bypass_voltage >= out_voltage_nominal * 0.95 && bypass_voltage <= out_voltage_nominal * 1.05) + /* Check if limits are within valid range */ + if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { return "ECO"; /* Enter ECO mode */ } else { - /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < eco_low_transfer || bypass_voltage > eco_high_transfer) { - upsdebugx(1, "Bypass voltage out of transfer ECO limits: %.1f V", bypass_voltage); + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { + upsdebugx(1, "Input Bypass voltage is outside ECO transfer limits: %.1f V", bypass_voltage); } if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Bypass frequency out of transfer ECO limits: %.1f Hz", bypass_frequency); + upsdebugx(1, "Input Bypass frequency is outside ECO transfer limits: %.1f Hz", bypass_frequency); } return NULL; /* Do not enter ECO mode */ } From e29675b976658c9011f8b2ae3c09f87eca780413 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sat, 30 Nov 2024 15:33:35 +0200 Subject: [PATCH 29/36] Fix for bypass limit In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 507bdcf3d0..357827d07b 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -762,7 +762,7 @@ static const char *eaton_input_eco_mode_check_range(double value) lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); } else { - /* Set default values if user-defined limits are not available or out of range */ + /* Set default values if user-defined limits are not available or out of range */ lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 5); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 5); } @@ -771,7 +771,7 @@ static const char *eaton_input_eco_mode_check_range(double value) if (eco_low_transfer > 0 && eco_high_transfer > 0) { lower_voltage_limit = eco_low_transfer; upper_voltage_limit = eco_high_transfer; - } else { + } else { /* Set default values if user-defined limits are not available or out of range */ lower_voltage_limit = out_voltage_nominal * 0.95; upper_voltage_limit = out_voltage_nominal * 1.05; @@ -784,7 +784,7 @@ static const char *eaton_input_eco_mode_check_range(double value) return "ECO"; /* Enter ECO mode */ } else { /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { + if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { upsdebugx(1, "Input Bypass voltage is outside ECO transfer limits: %.1f V", bypass_voltage); } if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { @@ -827,18 +827,25 @@ static const char *eaton_input_bypass_check_range(double value) const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); NUT_UNUSED_VARIABLE(value); - - if (bypass_voltage_str == NULL || bypass_low_transfer_str == NULL - || bypass_high_transfer_str == NULL || out_voltage_nominal_str == NULL - || bypass_frequency_str == NULL || frequency_range_transfer_str == NULL - || out_frequency_nominal_str == NULL - ) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s, %s, %s, %s", - bypass_voltage_str, bypass_low_transfer_str, bypass_high_transfer_str, - out_voltage_nominal_str, bypass_frequency_str, frequency_range_transfer_str, - out_frequency_nominal_str); - return NULL; /* Handle the error appropriately */ - } + + if (bypass_voltage_str == NULL || bypass_frequency_str == NULL + || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL) { + upsdebugx(1, "Failed to get values: %s, %s, %s, %s", + bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", + bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", + out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", + out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); + return NULL; /* Handle the error appropriately */ +} + /* In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode */ + if (bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL + || frequency_range_transfer_str == NULL) { + upsdebugx(1, "Failed to get values: %s, %s, %s", + bypass_low_transfer_str ? bypass_low_transfer_str : "input.transfer.bypass.low = NULL", + bypass_high_transfer_str ? bypass_high_transfer_str : "input.transfer.bypass.high = NULL", + frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.bypass.range = NULL"); + /* Not return NULL, We will use default values for limits */ +} str_to_double(bypass_voltage_str, &bypass_voltage, 10); str_to_double(bypass_low_transfer_str, &bypass_low_transfer, 10); From cd7077e0f507de5f4f757a3f0236a30acb0f794e Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sat, 30 Nov 2024 15:37:37 +0200 Subject: [PATCH 30/36] fix eco vars in debug meassage Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 357827d07b..bfce6abeda 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -737,9 +737,9 @@ static const char *eaton_input_eco_mode_check_range(double value) if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL || frequency_range_transfer_str == NULL) { upsdebugx(1, "Failed to get values: %s, %s, %s", - eco_low_transfer_str ? eco_low_transfer_str : "eco.low.transfer = NULL", - eco_high_transfer_str ? eco_high_transfer_str : "eco.high.transfer = NULL", - frequency_range_transfer_str ? frequency_range_transfer_str : "frequency.range.transfer = NULL"); + eco_low_transfer_str ? eco_low_transfer_str : "input.transfer.eco.low = NULL", + eco_high_transfer_str ? eco_high_transfer_str : "input.transfer.eco.high = NULL", + frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.eco.range = NULL"); /* Not return NULL, We will use default values for limits */ } From 9f68ab593c4d45620e222e0c2768107de086b198 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sat, 30 Nov 2024 21:46:16 +0200 Subject: [PATCH 31/36] add debug log when enter to eco/bypass modes Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index c3a57f6a54..3050dc11ef 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -935,6 +935,7 @@ static const char *eaton_input_eco_mode_check_range(double value) if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { + upsdebugx(1, "%s: Entering ECO mode due to input conditions being within the transfer limits.", __func__); return "ECO"; /* Enter ECO mode */ } else { /* Condensed debug messages for out of range voltage and frequency */ @@ -981,7 +982,7 @@ static const char *eaton_input_bypass_check_range(double value) const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); NUT_UNUSED_VARIABLE(value); - + if (bypass_voltage_str == NULL || bypass_frequency_str == NULL || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL) { upsdebugx(1, "Failed to get values: %s, %s, %s, %s", @@ -994,7 +995,7 @@ static const char *eaton_input_bypass_check_range(double value) /* In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode */ if (bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL || frequency_range_transfer_str == NULL) { - upsdebugx(1, "Failed to get values: %s, %s, %s", + upsdebugx(1, "Failed to get values: %s, %s, %s", bypass_low_transfer_str ? bypass_low_transfer_str : "input.transfer.bypass.low = NULL", bypass_high_transfer_str ? bypass_high_transfer_str : "input.transfer.bypass.high = NULL", frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.bypass.range = NULL"); @@ -1039,6 +1040,7 @@ static const char *eaton_input_bypass_check_range(double value) if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) ) { + upsdebugx(1, "%s: Entering Bypass mode due to input conditions being within the transfer limits.", __func__); return "on"; /* Enter Bypass mode */ } else { /* Condensed debug messages for out of range voltage and frequency */ From 3adc4c0737518c5ccd425f7c8e39bf84f7886735 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sun, 1 Dec 2024 12:19:29 +0200 Subject: [PATCH 32/36] Fix for bypass/eco when no values or outside of limits Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 3050dc11ef..67683ccba9 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -882,7 +882,9 @@ static const char *eaton_input_eco_mode_check_range(double value) bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - return NULL; /* Handle the error appropriately */ + /* Disable ECO mode switching */ + dstate_setinfo("input.eco.switchable", "normal"); + return NULL; /* Do not enter ECO mode */ } /* In case we dont have ECO transfer limit variables but still have ability to enter Bypass/ECO modes, * will use default limits later in code. @@ -945,7 +947,9 @@ static const char *eaton_input_eco_mode_check_range(double value) if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { upsdebugx(1, "Input Bypass frequency is outside ECO transfer limits: %.1f Hz", bypass_frequency); } - return NULL; /* Do not enter ECO mode */ + /* Disable ECO mode switching */ + dstate_setinfo("input.eco.switchable", "normal"); + return NULL; /* Do not enter ECO mode */ } } @@ -990,7 +994,9 @@ static const char *eaton_input_bypass_check_range(double value) bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - return NULL; /* Handle the error appropriately */ + /* Disable Bypass mode switching */ + dstate_setinfo("input.bypass.switch.on", "disabled"); + return NULL; /* Do not enter Bypass mode */ } /* In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode */ if (bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL @@ -1050,6 +1056,8 @@ static const char *eaton_input_bypass_check_range(double value) if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency); } + /* Disable Bypass mode switching */ + dstate_setinfo("input.bypass.switch.on", "disabled"); return NULL; /* Do not enter Bypass mode */ } } From 87d5c1712013bf4275126ce2cdbca8c08e99267a Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Sun, 1 Dec 2024 16:57:30 +0200 Subject: [PATCH 33/36] add debug message for bypass/eco outside limits Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 67683ccba9..68372c9df1 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -882,9 +882,10 @@ static const char *eaton_input_eco_mode_check_range(double value) bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - /* Disable ECO mode switching */ + /* Disable ECO mode switching, do not enter ECO mode */ dstate_setinfo("input.eco.switchable", "normal"); - return NULL; /* Do not enter ECO mode */ + upsdebugx(1, "%s: Disable ECO mode due to missing input/output variables.", __func__); + return NULL; } /* In case we dont have ECO transfer limit variables but still have ability to enter Bypass/ECO modes, * will use default limits later in code. @@ -947,9 +948,10 @@ static const char *eaton_input_eco_mode_check_range(double value) if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { upsdebugx(1, "Input Bypass frequency is outside ECO transfer limits: %.1f Hz", bypass_frequency); } - /* Disable ECO mode switching */ + /* Disable ECO mode switching, do not enter ECO mode */ dstate_setinfo("input.eco.switchable", "normal"); - return NULL; /* Do not enter ECO mode */ + upsdebugx(1, "%s: Disable ECO mode due to input conditions being outside the transfer limits.", __func__); + return NULL; } } @@ -994,9 +996,10 @@ static const char *eaton_input_bypass_check_range(double value) bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - /* Disable Bypass mode switching */ + /* Disable Bypass mode switching, do not enter Bypass mode */ dstate_setinfo("input.bypass.switch.on", "disabled"); - return NULL; /* Do not enter Bypass mode */ + upsdebugx(1, "%s: Disable Bypass mode due to missing input/output variables.", __func__); + return NULL; } /* In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode */ if (bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL @@ -1056,9 +1059,10 @@ static const char *eaton_input_bypass_check_range(double value) if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency); } - /* Disable Bypass mode switching */ + /* Disable Bypass mode switching, do not enter Bypass mode */ dstate_setinfo("input.bypass.switch.on", "disabled"); - return NULL; /* Do not enter Bypass mode */ + upsdebugx(1, "%s: Disable Bypass mode due to input conditions being outside the transfer limits.", __func__); + return NULL; } } From f4c1ef2af2bd479a2bc31fcf361dfe1ea2a63fdd Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 1 Dec 2024 23:32:00 +0100 Subject: [PATCH 34/36] drivers/mge-hid.c: restore white-space (TAB indentation and between decl type and varname) [#2684] Signed-off-by: Jim Klimov --- drivers/mge-hid.c | 399 +++++++++++++++++++++++----------------------- 1 file changed, 203 insertions(+), 196 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 2cde73ae61..917ec9a1ce 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -227,10 +227,10 @@ static char mge_scratch_buf[20]; #define ABM_PATH_MODE 1 /* Internal flag to process battery status (CHRG/DISCHRG) and ABM */ -static int advanced_battery_monitoring = ABM_UNKNOWN; +static int advanced_battery_monitoring = ABM_UNKNOWN; /* Internal flag to process the different ABM paths as seen in HID */ -static int advanced_battery_path = ABM_PATH_UNKNOWN; +static int advanced_battery_path = ABM_PATH_UNKNOWN; /* TODO: Lifted from strptime.c... maybe should externalize the fallback? * NOTE: HAVE_DECL_* are always defined, 0 or 1. Many other flags are not. @@ -242,7 +242,7 @@ static long round (double value) static long round (LDOUBLE value) # endif { - long intpart; + long intpart; intpart = (long)value; value = value - intpart; @@ -256,7 +256,7 @@ static long round (LDOUBLE value) /* Used to store internally if ABM is enabled or not */ static const char *eaton_abm_enabled_fun(double value) { - int abm_enabled_value = (int)value; + int abm_enabled_value = (int)value; switch (abm_enabled_value) { @@ -286,7 +286,7 @@ static info_lkp_t eaton_abm_enabled_info[] = { /* ABM Path: UPS.BatterySystem.Charger.Mode (battery.charger.mode.status) */ static const char *eaton_abm_path_mode_fun(double value) { - int abm_path_mode_value = (int)value; + int abm_path_mode_value = (int)value; /* If unknown/disabled ABM, reset ABM path to give UPS a chance to use another once re-enabled */ if (advanced_battery_monitoring == ABM_UNKNOWN || advanced_battery_monitoring == ABM_DISABLED) { @@ -313,7 +313,7 @@ static info_lkp_t eaton_abm_path_mode_info[] = { /* ABM Path: UPS.BatterySystem.Charger.Status (battery.charger.type.status) */ static const char *eaton_abm_path_status_fun(double value) { - int abm_path_status_value = (int)value; + int abm_path_status_value = (int)value; /* If unknown/disabled ABM, reset ABM path to give UPS a chance to use another once re-enabled */ if (advanced_battery_monitoring == ABM_UNKNOWN || advanced_battery_monitoring == ABM_DISABLED) { @@ -359,7 +359,7 @@ static info_lkp_t eaton_abm_enabled_legacy_info[] = { /* Used to process ABM status text (for battery.charger.status) */ static const char *eaton_abm_status_fun(double value) { - int abm_status_value = (int)value; + int abm_status_value = (int)value; /* Don't process if ABM is unknown or disabled */ if (advanced_battery_monitoring == ABM_UNKNOWN || advanced_battery_monitoring == ABM_DISABLED) { @@ -447,7 +447,7 @@ static info_lkp_t eaton_charger_type_info[] = { /* Used to process ABM status flags, for ups.status (CHRG/DISCHRG) */ static const char *eaton_abm_chrg_dischrg_fun(double value) { - int abm_chrg_dischrg_value = (int)value; + int abm_chrg_dischrg_value = (int)value; /* Don't process if ABM is unknown or disabled */ if (advanced_battery_monitoring == ABM_UNKNOWN || advanced_battery_monitoring == ABM_DISABLED) @@ -586,7 +586,7 @@ static const char *mge_date_conversion_fun(double value) static const char *mge_time_conversion_fun(double value) { - time_t sec = value; + time_t sec = value; struct tm tmbuf; if (strftime(mge_scratch_buf, sizeof(mge_scratch_buf), "%H:%M:%S", localtime_r(&sec, &tmbuf)) == 8) { @@ -874,107 +874,110 @@ static info_lkp_t outlet_eco_yes_no_info[] = { /* Function to check if the current High Efficiency (aka ECO) mode voltage/frequency is within the configured limits */ static const char *eaton_input_eco_mode_check_range(double value) { - double bypass_voltage; - double eco_low_transfer; - double eco_high_transfer; - double out_voltage_nominal; - double out_frequency_nominal; - double bypass_frequency; - double frequency_range_transfer; - double lower_frequency_limit; - double upper_frequency_limit; - double lower_voltage_limit; - double upper_voltage_limit; - - /* Get the ECO mode voltage/frequency and transfer points */ - const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); - const char* eco_low_transfer_str = dstate_getinfo("input.transfer.eco.low"); - const char* eco_high_transfer_str = dstate_getinfo("input.transfer.eco.high"); - const char* out_voltage_nominal_str = dstate_getinfo("output.voltage.nominal"); - const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); - const char* frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.eco.range"); - const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); - - NUT_UNUSED_VARIABLE(value); - - if (bypass_voltage_str == NULL || bypass_frequency_str == NULL - || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s", - bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", - bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", - out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", - out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - /* Disable ECO mode switching, do not enter ECO mode */ - dstate_setinfo("input.eco.switchable", "normal"); - upsdebugx(1, "%s: Disable ECO mode due to missing input/output variables.", __func__); - return NULL; -} - /* In case we dont have ECO transfer limit variables but still have ability to enter Bypass/ECO modes, + double bypass_voltage; + double eco_low_transfer; + double eco_high_transfer; + double out_voltage_nominal; + double out_frequency_nominal; + double bypass_frequency; + double frequency_range_transfer; + double lower_frequency_limit; + double upper_frequency_limit; + double lower_voltage_limit; + double upper_voltage_limit; + + /* Get the ECO mode voltage/frequency and transfer points */ + const char *bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); + const char *eco_low_transfer_str = dstate_getinfo("input.transfer.eco.low"); + const char *eco_high_transfer_str = dstate_getinfo("input.transfer.eco.high"); + const char *out_voltage_nominal_str = dstate_getinfo("output.voltage.nominal"); + const char *out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); + const char *frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.eco.range"); + const char *bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); + + NUT_UNUSED_VARIABLE(value); + + if (bypass_voltage_str == NULL || bypass_frequency_str == NULL + || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL + ) { + upsdebugx(1, "Failed to get values: %s, %s, %s, %s", + bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", + bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", + out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", + out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); + /* Disable ECO mode switching, do not enter ECO mode */ + dstate_setinfo("input.eco.switchable", "normal"); + upsdebugx(1, "%s: Disable ECO mode due to missing input/output variables.", __func__); + return NULL; + } + + /* In case we dont have ECO transfer limit variables but still have ability to enter Bypass/ECO modes, * will use default limits later in code. * Possibly reported by debug log for 9SX1000i https://github.com/networkupstools/nut/issues/2685 */ - if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL - || frequency_range_transfer_str == NULL) { - upsdebugx(1, "Failed to get values: %s, %s, %s", - eco_low_transfer_str ? eco_low_transfer_str : "input.transfer.eco.low = NULL", - eco_high_transfer_str ? eco_high_transfer_str : "input.transfer.eco.high = NULL", - frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.eco.range = NULL"); - /* Not return NULL, We will use default values for limits */ -} + if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL + || frequency_range_transfer_str == NULL + ) { + upsdebugx(1, "Failed to get values: %s, %s, %s", + eco_low_transfer_str ? eco_low_transfer_str : "input.transfer.eco.low = NULL", + eco_high_transfer_str ? eco_high_transfer_str : "input.transfer.eco.high = NULL", + frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.eco.range = NULL"); + /* Not return NULL, We will use default values for limits */ + } - str_to_double(bypass_voltage_str, &bypass_voltage, 10); - str_to_double(eco_low_transfer_str, &eco_low_transfer, 10); - str_to_double(eco_high_transfer_str, &eco_high_transfer, 10); - str_to_double(out_voltage_nominal_str, &out_voltage_nominal, 10); - str_to_double(out_frequency_nominal_str, &out_frequency_nominal, 10); - str_to_double(frequency_range_transfer_str, &frequency_range_transfer, 10); + str_to_double(bypass_voltage_str, &bypass_voltage, 10); + str_to_double(eco_low_transfer_str, &eco_low_transfer, 10); + str_to_double(eco_high_transfer_str, &eco_high_transfer, 10); + str_to_double(out_voltage_nominal_str, &out_voltage_nominal, 10); + str_to_double(out_frequency_nominal_str, &out_frequency_nominal, 10); + str_to_double(frequency_range_transfer_str, &frequency_range_transfer, 10); str_to_double(bypass_frequency_str, &bypass_frequency, 10); - /* Default values if user-defined limits are not available or out of range - 5% below nominal output voltage - 5% above nominal output voltage - 5% below/above output frequency nominal - */ - - /* Set the frequency limit */ - if (frequency_range_transfer > 0) { - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); - upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); - } else { - /* Set default values if user-defined limits are not available or out of range */ - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 5); + /* Default values if user-defined limits are not available or out of range + * 5% below nominal output voltage + * 5% above nominal output voltage + * 5% below/above output frequency nominal + */ + + /* Set the frequency limit */ + if (frequency_range_transfer > 0) { + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); + upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); + } else { + /* Set default values if user-defined limits are not available or out of range */ + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 5); upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 5); - } + } - /* Set the voltage limit */ + /* Set the voltage limit */ if (eco_low_transfer > 0 && eco_high_transfer > 0) { - lower_voltage_limit = eco_low_transfer; - upper_voltage_limit = eco_high_transfer; + lower_voltage_limit = eco_low_transfer; + upper_voltage_limit = eco_high_transfer; } else { - /* Set default values if user-defined limits are not available or out of range */ - lower_voltage_limit = out_voltage_nominal * 0.95; - upper_voltage_limit = out_voltage_nominal * 1.05; - } + /* Set default values if user-defined limits are not available or out of range */ + lower_voltage_limit = out_voltage_nominal * 0.95; + upper_voltage_limit = out_voltage_nominal * 1.05; + } - /* Check if limits are within valid range */ + /* Check if limits are within valid range */ if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { + && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) + ) { upsdebugx(1, "%s: Entering ECO mode due to input conditions being within the transfer limits.", __func__); - return "ECO"; /* Enter ECO mode */ - } else { - /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { + return "ECO"; /* Enter ECO mode */ + } else { + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { upsdebugx(1, "Input Bypass voltage is outside ECO transfer limits: %.1f V", bypass_voltage); - } - if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Input Bypass frequency is outside ECO transfer limits: %.1f Hz", bypass_frequency); - } - /* Disable ECO mode switching, do not enter ECO mode */ - dstate_setinfo("input.eco.switchable", "normal"); + } + if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { + upsdebugx(1, "Input Bypass frequency is outside ECO transfer limits: %.1f Hz", bypass_frequency); + } + /* Disable ECO mode switching, do not enter ECO mode */ + dstate_setinfo("input.eco.switchable", "normal"); upsdebugx(1, "%s: Disable ECO mode due to input conditions being outside the transfer limits.", __func__); - return NULL; - } + return NULL; + } } /* High Efficiency (aka ECO) mode, Energy Saver System (aka ESS) mode makes sense for UPS like (93PM G2, 9395P) */ @@ -988,104 +991,107 @@ static info_lkp_t eaton_input_eco_mode_on_off_info[] = { /* Function to check if the current Bypass transfer voltage/frequency is within the configured limits */ static const char *eaton_input_bypass_check_range(double value) { - double bypass_voltage; - double bypass_low_transfer; - double bypass_high_transfer; - double out_voltage_nominal; - double bypass_frequency; - double frequency_range_transfer; - double lower_frequency_limit; - double upper_frequency_limit; - double lower_voltage_limit; - double upper_voltage_limit; - double out_frequency_nominal; + double bypass_voltage; + double bypass_low_transfer; + double bypass_high_transfer; + double out_voltage_nominal; + double bypass_frequency; + double frequency_range_transfer; + double lower_frequency_limit; + double upper_frequency_limit; + double lower_voltage_limit; + double upper_voltage_limit; + double out_frequency_nominal; /* Get the Bypass mode voltage/frequency and transfer points */ - const char* bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); - const char* bypass_low_transfer_str = dstate_getinfo("input.transfer.bypass.low"); - const char* bypass_high_transfer_str = dstate_getinfo("input.transfer.bypass.high"); - const char* out_voltage_nominal_str = dstate_getinfo("output.voltage.nominal"); - const char* bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); - const char* frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.bypass.range"); - const char* out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); + const char *bypass_voltage_str = dstate_getinfo("input.bypass.voltage"); + const char *bypass_low_transfer_str = dstate_getinfo("input.transfer.bypass.low"); + const char *bypass_high_transfer_str = dstate_getinfo("input.transfer.bypass.high"); + const char *out_voltage_nominal_str = dstate_getinfo("output.voltage.nominal"); + const char *bypass_frequency_str = dstate_getinfo("input.bypass.frequency"); + const char *frequency_range_transfer_str = dstate_getinfo("input.transfer.frequency.bypass.range"); + const char *out_frequency_nominal_str = dstate_getinfo("output.frequency.nominal"); NUT_UNUSED_VARIABLE(value); if (bypass_voltage_str == NULL || bypass_frequency_str == NULL - || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s", - bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", - bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", - out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", - out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - /* Disable Bypass mode switching, do not enter Bypass mode */ - dstate_setinfo("input.bypass.switch.on", "disabled"); - upsdebugx(1, "%s: Disable Bypass mode due to missing input/output variables.", __func__); - return NULL; -} - /* In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode */ + || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL + ) { + upsdebugx(1, "Failed to get values: %s, %s, %s, %s", + bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", + bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", + out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", + out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); + /* Disable Bypass mode switching, do not enter Bypass mode */ + dstate_setinfo("input.bypass.switch.on", "disabled"); + upsdebugx(1, "%s: Disable Bypass mode due to missing input/output variables.", __func__); + return NULL; + } + + /* In case we dont have Bypass transfer limit variables but still have ability to enter Bypass mode */ if (bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL - || frequency_range_transfer_str == NULL) { - upsdebugx(1, "Failed to get values: %s, %s, %s", - bypass_low_transfer_str ? bypass_low_transfer_str : "input.transfer.bypass.low = NULL", - bypass_high_transfer_str ? bypass_high_transfer_str : "input.transfer.bypass.high = NULL", - frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.bypass.range = NULL"); - /* Not return NULL, We will use default values for limits */ -} + || frequency_range_transfer_str == NULL + ) { + upsdebugx(1, "Failed to get values: %s, %s, %s", + bypass_low_transfer_str ? bypass_low_transfer_str : "input.transfer.bypass.low = NULL", + bypass_high_transfer_str ? bypass_high_transfer_str : "input.transfer.bypass.high = NULL", + frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.bypass.range = NULL"); + /* Not return NULL, We will use default values for limits */ + } + + str_to_double(bypass_voltage_str, &bypass_voltage, 10); + str_to_double(bypass_low_transfer_str, &bypass_low_transfer, 10); + str_to_double(bypass_high_transfer_str, &bypass_high_transfer, 10); + str_to_double(out_voltage_nominal_str, &out_voltage_nominal, 10); + str_to_double(bypass_frequency_str, &bypass_frequency, 10); + str_to_double(frequency_range_transfer_str, &frequency_range_transfer, 10); + str_to_double(out_frequency_nominal_str, &out_frequency_nominal, 10); + + /* Default values if user-defined limits are not available or out of range + * 20% below nominal output voltage + * 15% above nominal output voltage + * 10% below/above output frequency nominal + */ - str_to_double(bypass_voltage_str, &bypass_voltage, 10); - str_to_double(bypass_low_transfer_str, &bypass_low_transfer, 10); - str_to_double(bypass_high_transfer_str, &bypass_high_transfer, 10); - str_to_double(out_voltage_nominal_str, &out_voltage_nominal, 10); - str_to_double(bypass_frequency_str, &bypass_frequency, 10); - str_to_double(frequency_range_transfer_str, &frequency_range_transfer, 10); - str_to_double(out_frequency_nominal_str, &out_frequency_nominal, 10); - - /* Default values if user-defined limits are not available or out of range - 20% below nominal output voltage - 15% above nominal output voltage - 10% below/above output frequency nominal - */ - - /* Set the frequency limit */ - if (frequency_range_transfer > 0) { - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); - upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); - } else { - /* Set default values if user-defined limits are not available or out of range */ - lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 10); - upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 10); - } - - /* Set the voltage limit */ - if (bypass_low_transfer > 0 && bypass_high_transfer > 0) { - lower_voltage_limit = bypass_low_transfer; - upper_voltage_limit = bypass_high_transfer; + /* Set the frequency limit */ + if (frequency_range_transfer > 0) { + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * frequency_range_transfer); + upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * frequency_range_transfer); } else { - /* Set default values if user-defined limits are not available or out of range */ - lower_voltage_limit = out_voltage_nominal * 0.8; - upper_voltage_limit = out_voltage_nominal * 1.15; + /* Set default values if user-defined limits are not available or out of range */ + lower_frequency_limit = out_frequency_nominal - (out_frequency_nominal / 100 * 10); + upper_frequency_limit = out_frequency_nominal + (out_frequency_nominal / 100 * 10); } - /* Check if limits are within valid range */ - if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) - && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) - ) { + /* Set the voltage limit */ + if (bypass_low_transfer > 0 && bypass_high_transfer > 0) { + lower_voltage_limit = bypass_low_transfer; + upper_voltage_limit = bypass_high_transfer; + } else { + /* Set default values if user-defined limits are not available or out of range */ + lower_voltage_limit = out_voltage_nominal * 0.8; + upper_voltage_limit = out_voltage_nominal * 1.15; + } + + /* Check if limits are within valid range */ + if ((bypass_voltage >= lower_voltage_limit && bypass_voltage <= upper_voltage_limit) + && (bypass_frequency >= lower_frequency_limit && bypass_frequency <= upper_frequency_limit) + ) { upsdebugx(1, "%s: Entering Bypass mode due to input conditions being within the transfer limits.", __func__); - return "on"; /* Enter Bypass mode */ - } else { - /* Condensed debug messages for out of range voltage and frequency */ - if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { - upsdebugx(1, "Input Bypass voltage is outside Bypass transfer limits: %.1f V", bypass_voltage); - } - if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { - upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency); - } + return "on"; /* Enter Bypass mode */ + } else { + /* Condensed debug messages for out of range voltage and frequency */ + if (bypass_voltage < lower_voltage_limit || bypass_voltage > upper_voltage_limit) { + upsdebugx(1, "Input Bypass voltage is outside Bypass transfer limits: %.1f V", bypass_voltage); + } + if (bypass_frequency < lower_frequency_limit || bypass_frequency > upper_frequency_limit) { + upsdebugx(1, "Input Bypass frequency is outside Bypass transfer limits: %.1f Hz", bypass_frequency); + } /* Disable Bypass mode switching, do not enter Bypass mode */ - dstate_setinfo("input.bypass.switch.on", "disabled"); + dstate_setinfo("input.bypass.switch.on", "disabled"); upsdebugx(1, "%s: Disable Bypass mode due to input conditions being outside the transfer limits.", __func__); - return NULL; - } + return NULL; + } } /* Automatic Bypass mode on */ @@ -1105,7 +1111,8 @@ static info_lkp_t eaton_input_bypass_mode_off_info[] = { /* Determine country using UPS.PowerSummary.Country. * If not present: * if PowerConverter.Output.Voltage >= 200 => "Europe" - * else default to "US" */ + * else default to "US" + */ static const char *eaton_check_country_fun(double value) { country_code = value; @@ -1122,13 +1129,13 @@ static info_lkp_t eaton_check_country_info[] = { * compute a realpower approximation using available data */ static const char *eaton_compute_realpower_fun(double value) { - const char *str_ups_load = dstate_getinfo("ups.load"); - const char *str_power_nominal = dstate_getinfo("ups.power.nominal"); - const char *str_powerfactor = dstate_getinfo("output.powerfactor"); - float powerfactor = 0.80; - int power_nominal = 0; - int ups_load = 0; - double realpower = 0; + const char *str_ups_load = dstate_getinfo("ups.load"); + const char *str_power_nominal = dstate_getinfo("ups.power.nominal"); + const char *str_powerfactor = dstate_getinfo("output.powerfactor"); + float powerfactor = 0.80; + int power_nominal = 0; + int ups_load = 0; + double realpower = 0; NUT_UNUSED_VARIABLE(value); if (str_power_nominal && str_ups_load) { @@ -1264,7 +1271,7 @@ static info_lkp_t nominal_output_voltage_info[] = { /* Limit reporting "online / !online" to when "!off" */ static const char *eaton_converter_online_fun(double value) { - unsigned ups_status = ups_status_get(); + unsigned ups_status = ups_status_get(); if (ups_status & STATUS(OFF)) return NULL; @@ -1603,7 +1610,7 @@ static models_name_t mge_model_names [] = /* Eaton 9SX series per discussions in * https://github.com/networkupstools/nut/issues/2685 * https://www.eaton.com/gb/en-gb/site-search.html.searchTerm$9sx.tabs$all.html - */ + */ { "Eaton 9SX", "700i", EATON_9E, "9SX700i" }, { "Eaton 9SX", "1000i", EATON_9E, "9SX1000i" }, { "Eaton 9SX", "1000im", EATON_9E, "9SX1000im" }, @@ -1618,8 +1625,8 @@ static models_name_t mge_model_names [] = /* Eaton 9PX series * https://www.eaton.com/gb/en-gb/site-search.html.searchTerm$9px.tabs$all.html - */ - { "Eaton 9PX", "1000irt2u", EATON_9E, "9px1000irt2u" }, + */ + { "Eaton 9PX", "1000irt2u", EATON_9E, "9px1000irt2u" }, { "Eaton 9PX", "1500irt2u", EATON_9E, "9px1500irt2u" }, { "Eaton 9PX", "1500irtm", EATON_9E, "9px1500irtm" }, { "Eaton 9PX", "2200irt2u", EATON_9E, "9px2200irt2u" }, @@ -1893,7 +1900,7 @@ static hid_info_t mge_hid2nut[] = { "input.transfer.hysteresis", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HysteresisVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.transfer.bypass.forced", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].ForcedTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.bypass.overload", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OverloadTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, - { "input.transfer.bypass.outlimits", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OutOfToleranceTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, + { "input.transfer.bypass.outlimits", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerConverter.Input.[2].OutOfToleranceTransferEnable", NULL, "%.0f", HU_FLAG_SEMI_STATIC, eaton_enable_disable_info }, { "input.transfer.trim.high", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.HighVoltageBuckTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.sensitivity", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerConverter.Output.SensitivityMode", NULL, "%s", HU_FLAG_SEMI_STATIC, mge_sensitivity_info }, { "input.voltage.extended", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.ExtendedVoltageMode", NULL, "%s", HU_FLAG_SEMI_STATIC, yes_no_info }, @@ -2002,8 +2009,8 @@ static hid_info_t mge_hid2nut[] = /* instant commands. */ /* splited into subset while waiting for extradata support - * ie: test.battery.start quick - */ + * ie: test.battery.start quick + */ { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "1", HU_TYPE_CMD, NULL }, { "test.battery.start.deep", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "2", HU_TYPE_CMD, NULL }, { "test.battery.stop", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "3", HU_TYPE_CMD, NULL }, @@ -2090,7 +2097,7 @@ static char *get_model_name(const char *iProduct, const char *iModel) #pragma GCC diagnostic ignored "-Wformat-truncation" #endif /* NOTE: We intentionally limit the amount of bytes reported */ - int len = snprintf(buf, sizeof(buf), "%s %s", iProduct, iModel); + int len = snprintf(buf, sizeof(buf), "%s %s", iProduct, iModel); if (len < 0) { upsdebugx(1, "%s: got an error while extracting iProduct+iModel value", __func__); @@ -2158,7 +2165,7 @@ static int mge_claim(HIDDevice_t *hd) { NUT_UNUSED_VARIABLE(hd); return 1; #else /* !SHUT_MODE => USB */ - int status = is_usb_device_supported(mge_usb_device_table, hd); + int status = is_usb_device_supported(mge_usb_device_table, hd); switch (status) { From e698d58cb8ede0cd707ad302bec872bdabbd3ca6 Mon Sep 17 00:00:00 2001 From: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:53:48 +0200 Subject: [PATCH 35/36] typo space removed Signed-off-by: DaRK AnGeL <28630321+masterwishx@users.noreply.github.com> --- drivers/mge-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 917ec9a1ce..83d18fd073 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -905,7 +905,7 @@ static const char *eaton_input_eco_mode_check_range(double value) bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); - /* Disable ECO mode switching, do not enter ECO mode */ + /* Disable ECO mode switching, do not enter ECO mode */ dstate_setinfo("input.eco.switchable", "normal"); upsdebugx(1, "%s: Disable ECO mode due to missing input/output variables.", __func__); return NULL; From 077c08cea8b2e59076a353ec32e37ebeb19be2cc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 2 Dec 2024 19:47:11 +0100 Subject: [PATCH 36/36] drivers/mge-hid.c: simplify debug printouts with NUT_STRARG() [#2684, #1737] Signed-off-by: Jim Klimov --- drivers/mge-hid.c | 60 +++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index 83d18fd073..987760006f 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -900,11 +900,17 @@ static const char *eaton_input_eco_mode_check_range(double value) if (bypass_voltage_str == NULL || bypass_frequency_str == NULL || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL ) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s", - bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", - bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", - out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", - out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); + upsdebugx(2, "%s: Failed to get values: " + "input.bypass.voltage = %s, " + "input.bypass.frequency = %s, " + "output.voltage.nominal = %s, " + "output.frequency.nominal = %s", + __func__, + NUT_STRARG(bypass_voltage_str), + NUT_STRARG(bypass_frequency_str), + NUT_STRARG(out_voltage_nominal_str), + NUT_STRARG(out_frequency_nominal_str)); + /* Disable ECO mode switching, do not enter ECO mode */ dstate_setinfo("input.eco.switchable", "normal"); upsdebugx(1, "%s: Disable ECO mode due to missing input/output variables.", __func__); @@ -918,11 +924,15 @@ static const char *eaton_input_eco_mode_check_range(double value) if (eco_low_transfer_str == NULL || eco_high_transfer_str == NULL || frequency_range_transfer_str == NULL ) { - upsdebugx(1, "Failed to get values: %s, %s, %s", - eco_low_transfer_str ? eco_low_transfer_str : "input.transfer.eco.low = NULL", - eco_high_transfer_str ? eco_high_transfer_str : "input.transfer.eco.high = NULL", - frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.eco.range = NULL"); - /* Not return NULL, We will use default values for limits */ + upsdebugx(2, "%s: Failed to get values: " + "input.transfer.eco.low = %s, " + "input.transfer.eco.high = %s, " + "input.transfer.frequency.eco.range = %s", + __func__, + NUT_STRARG(eco_low_transfer_str), + NUT_STRARG(eco_high_transfer_str), + NUT_STRARG(frequency_range_transfer_str)); + /* Do not return NULL here, we will use default values for limits */ } str_to_double(bypass_voltage_str, &bypass_voltage, 10); @@ -1017,11 +1027,17 @@ static const char *eaton_input_bypass_check_range(double value) if (bypass_voltage_str == NULL || bypass_frequency_str == NULL || out_voltage_nominal_str == NULL || out_frequency_nominal_str == NULL ) { - upsdebugx(1, "Failed to get values: %s, %s, %s, %s", - bypass_voltage_str ? bypass_voltage_str : "input.bypass.voltage = NULL", - bypass_frequency_str ? bypass_frequency_str : "input.bypass.frequency = NULL", - out_voltage_nominal_str ? out_voltage_nominal_str : "output.voltage.nominal = NULL", - out_frequency_nominal_str ? out_frequency_nominal_str : "output.frequency.nominal = NULL"); + upsdebugx(2, "%s: Failed to get values: " + "input.bypass.voltage = %s, " + "input.bypass.frequency = %s, " + "output.voltage.nominal = %s, " + "output.frequency.nominal = %s", + __func__, + NUT_STRARG(bypass_voltage_str), + NUT_STRARG(bypass_frequency_str), + NUT_STRARG(out_voltage_nominal_str), + NUT_STRARG(out_frequency_nominal_str)); + /* Disable Bypass mode switching, do not enter Bypass mode */ dstate_setinfo("input.bypass.switch.on", "disabled"); upsdebugx(1, "%s: Disable Bypass mode due to missing input/output variables.", __func__); @@ -1032,11 +1048,15 @@ static const char *eaton_input_bypass_check_range(double value) if (bypass_low_transfer_str == NULL || bypass_high_transfer_str == NULL || frequency_range_transfer_str == NULL ) { - upsdebugx(1, "Failed to get values: %s, %s, %s", - bypass_low_transfer_str ? bypass_low_transfer_str : "input.transfer.bypass.low = NULL", - bypass_high_transfer_str ? bypass_high_transfer_str : "input.transfer.bypass.high = NULL", - frequency_range_transfer_str ? frequency_range_transfer_str : "input.transfer.frequency.bypass.range = NULL"); - /* Not return NULL, We will use default values for limits */ + upsdebugx(2, "%s: Failed to get values: " + "input.transfer.bypass.low = %s, " + "input.transfer.bypass.high = %s, " + "input.transfer.frequency.bypass.range = %s", + __func__, + NUT_STRARG(bypass_low_transfer_str), + NUT_STRARG(bypass_high_transfer_str), + NUT_STRARG(frequency_range_transfer_str)); + /* Do not return NULL here, we will use default values for limits */ } str_to_double(bypass_voltage_str, &bypass_voltage, 10);