From 216cd968ffcf5be23c5b51a129adf58c9eca63e8 Mon Sep 17 00:00:00 2001 From: amikot <3470285+amikot@users.noreply.github.com> Date: Sun, 30 Oct 2022 21:00:31 +0000 Subject: [PATCH 001/325] Update riello_usb.c Added driver setting flag `localcalculation`. When enabled, driver will calculate values of battery.runtime and battery.load locally. This is for some Riello models (iPlug and iDialog series) that provides incorrect values. Local calculation is done according to nominal battery capacity, nominal battery voltage, actual battery charge, maximum and actual UPS load. Added condition to filter off situation when battery temperature variable is incorrectly set to variable type maximum (255) - which is typical issue of some Riello models (iPlug and iDialog series). If incorrect value is detected temperature is set to 0. --- drivers/riello_usb.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index cec64f5ae4..7c5b00265a 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -833,7 +833,7 @@ void upsdrv_help(void) void upsdrv_makevartable(void) { - + addvar(VAR_FLAG, "localcalculation", "Calculate battery charge and runtime locally"); } void upsdrv_initups(void) @@ -1045,6 +1045,9 @@ void upsdrv_updateinfo(void) uint8_t getextendedOK; static int countlost = 0; int stat; + int battcharge; + float battruntime; + float upsloadfactor; upsdebugx(1, "countlost %d",countlost); @@ -1079,14 +1082,33 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0); dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); - if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + if (testvar("localcalculation")) { + battcharge = ((DevData.Ubat <= 129) && (DevData.Ubat >=107)) ? (((DevData.Ubat-107)*100)/22) : ((DevData.Ubat < 107) ? 0 : 100); + battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); + upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; + + dstate_setinfo("battery.charge", "%u", battcharge ); + dstate_setinfo("battery.runtime", "%.0f", battruntime/upsloadfactor); + } + else if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," + "try setting \"localcalculation\" flag in \"ups.conf\" " + "options section for this driver!\n"); dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - } - - if (DevData.Tsystem < 0xFF) - dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); - + dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); + } + else { + upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," + "try setting \"localcalculation\" flag in \"ups.conf\" " + "options section for this driver!\n"); + } + + if (DevData.Tsystem == 255) { + dstate_setinfo("ups.temperature", "%u", 0 ); + } + else if (DevData.Tsystem < 0xFF) { + dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + } if (input_monophase) { dstate_setinfo("input.voltage", "%u", DevData.Uinp1); From f2ee6ad6e6d01074b6f43c33678a4aca1ad62f3c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 31 Oct 2022 01:48:31 +0100 Subject: [PATCH 002/325] NEWS: added localcalculation flag for riello_usb --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index c16e1cbce3..5dc9361987 100644 --- a/NEWS +++ b/NEWS @@ -80,6 +80,10 @@ https://github.com/networkupstools/nut/milestone/8 to `battery.mfr.date` (not `battery.date` which is the maintenance replacement date) [#1644] + - riello_usb updates: + * added `localcalculation` option to compute `battery.runtime` and + `battery.load` if the device provides bogus values [#1692, #1685] + - NUT for Windows: * Ability to build NUT for Windows, last tackled with a branch based on NUT v2.6.5 a decade ago, has been revived with the 2.8.x era codebase [#5]. From 72fe9d5fd5b60b754ab671489c3e81aa76c9d0a9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 31 Oct 2022 01:54:00 +0100 Subject: [PATCH 003/325] Update riello_usb.txt Added localcalculation flag description --- docs/man/riello_usb.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index 1c4ffd6e43..92e42743bb 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -25,6 +25,23 @@ riello_usb supports all recent Riello UPS with USB. Older Riello UPS products are not supported. +EXTRA ARGUMENTS +--------------- + +You may need to tweak some settings, depending on the make and model of your UPS +(see linkman:ups.conf[5]): + +*localcalculation*:: +When enabled, driver will calculate values of `battery.runtime` and `battery.load` +locally. This is for some Riello models (iPlug and iDialog series) that provide +incorrect values. Local calculation is done according to nominal battery capacity, +nominal battery voltage, actual battery charge, maximum and actual UPS load. ++ +Lead battery charge graph is not linear, so estimated charge value may not be +perfectly accurate. However it should be good enough to determine battery +actual status and roughly estimate the time it can power the system. + + AUTHOR ------ From 7d7a17855aa455f71f9410123254073740edf06c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 31 Oct 2022 02:21:05 +0100 Subject: [PATCH 004/325] Update nut.dict --- docs/nut.dict | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/nut.dict b/docs/nut.dict index 1670fe4b85..4d19315e93 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3043 utf-8 +personal_ws-1.1 en 3044 utf-8 AAS ABI ACFAIL @@ -2141,6 +2141,7 @@ lk lm ln loadPercentage +localcalculation localhost localtime lockf From f1b69932e3bfbce0a1dcac7ddb31a42146446352 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 31 Oct 2022 08:45:44 +0100 Subject: [PATCH 005/325] Update nut.dict --- docs/nut.dict | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/nut.dict b/docs/nut.dict index 4d19315e93..cdd1ef87d3 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3044 utf-8 +personal_ws-1.1 en 3046 utf-8 AAS ABI ACFAIL @@ -1965,8 +1965,10 @@ hunnox hypervisor hypervisors iBox +iDialog iDowell iManufacturer +iPlug iSerial iUSB ib From 2d78d92cf4e4ce2df961935a14635ff14058b392 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 14:05:17 +0100 Subject: [PATCH 006/325] drivers/riello_usb.c: fix indentation [#1692] --- drivers/riello_usb.c | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 7c5b00265a..4848061182 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -1045,9 +1045,9 @@ void upsdrv_updateinfo(void) uint8_t getextendedOK; static int countlost = 0; int stat; - int battcharge; - float battruntime; - float upsloadfactor; + int battcharge; + float battruntime; + float upsloadfactor; upsdebugx(1, "countlost %d",countlost); @@ -1082,33 +1082,33 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0); dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); - if (testvar("localcalculation")) { - battcharge = ((DevData.Ubat <= 129) && (DevData.Ubat >=107)) ? (((DevData.Ubat-107)*100)/22) : ((DevData.Ubat < 107) ? 0 : 100); - battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); - upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; - - dstate_setinfo("battery.charge", "%u", battcharge ); - dstate_setinfo("battery.runtime", "%.0f", battruntime/upsloadfactor); - } - else if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { - upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," - "try setting \"localcalculation\" flag in \"ups.conf\" " - "options section for this driver!\n"); + if (testvar("localcalculation")) { + battcharge = ((DevData.Ubat <= 129) && (DevData.Ubat >=107)) ? (((DevData.Ubat-107)*100)/22) : ((DevData.Ubat < 107) ? 0 : 100); + battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); + upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; + + dstate_setinfo("battery.charge", "%u", battcharge ); + dstate_setinfo("battery.runtime", "%.0f", battruntime/upsloadfactor); + } + else if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," + "try setting \"localcalculation\" flag in \"ups.conf\" " + "options section for this driver!\n"); dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - } - else { - upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," - "try setting \"localcalculation\" flag in \"ups.conf\" " - "options section for this driver!\n"); - } + dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); + } + else { + upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," + "try setting \"localcalculation\" flag in \"ups.conf\" " + "options section for this driver!\n"); + } if (DevData.Tsystem == 255) { - dstate_setinfo("ups.temperature", "%u", 0 ); - } - else if (DevData.Tsystem < 0xFF) { - dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); - } + dstate_setinfo("ups.temperature", "%u", 0 ); + } + else if (DevData.Tsystem < 0xFF) { + dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + } if (input_monophase) { dstate_setinfo("input.voltage", "%u", DevData.Uinp1); From 2b2a886f74dd914ef76851302715b43e2b166f50 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 14:08:09 +0100 Subject: [PATCH 007/325] drivers/riello_usb.c: deduplicate message about possibly missing battery.charge and battery.runtime [#1692] --- drivers/riello_usb.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 4848061182..15df617e1e 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -1087,20 +1087,18 @@ void upsdrv_updateinfo(void) battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; - dstate_setinfo("battery.charge", "%u", battcharge ); + dstate_setinfo("battery.charge", "%u", battcharge); dstate_setinfo("battery.runtime", "%.0f", battruntime/upsloadfactor); } - else if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { - upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," - "try setting \"localcalculation\" flag in \"ups.conf\" " - "options section for this driver!\n"); - dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - } else { - upsdebugx(0, "\n If you don't see values for battery.charge and battery.runtime or values are incorrect," + upsdebugx(0, "\n If you don't see values for battery.charge and " + "battery.runtime or values are incorrect," "try setting \"localcalculation\" flag in \"ups.conf\" " "options section for this driver!\n"); + if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + dstate_setinfo("battery.charge", "%u", DevData.BatCap); + dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); + } } if (DevData.Tsystem == 255) { From 8aaea69e0183d8714412a1afbfe34014fd298b41 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 14:22:09 +0100 Subject: [PATCH 008/325] NEWS, docs/man/riello_usb.txt: fix "docs/man/riello_usb.txt" description [#1692] --- NEWS | 2 +- docs/man/riello_usb.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 5dc9361987..6893f43698 100644 --- a/NEWS +++ b/NEWS @@ -82,7 +82,7 @@ https://github.com/networkupstools/nut/milestone/8 - riello_usb updates: * added `localcalculation` option to compute `battery.runtime` and - `battery.load` if the device provides bogus values [#1692, #1685] + `battery.charge` if the device provides bogus values [#1692, #1685] - NUT for Windows: * Ability to build NUT for Windows, last tackled with a branch based on diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index 92e42743bb..3ac3b796a6 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -32,7 +32,7 @@ You may need to tweak some settings, depending on the make and model of your UPS (see linkman:ups.conf[5]): *localcalculation*:: -When enabled, driver will calculate values of `battery.runtime` and `battery.load` +When enabled, driver will calculate values of `battery.runtime` and `battery.charge` locally. This is for some Riello models (iPlug and iDialog series) that provide incorrect values. Local calculation is done according to nominal battery capacity, nominal battery voltage, actual battery charge, maximum and actual UPS load. From 73d2530508ae134734fddc7bb7ecb6f79a0ae86c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 14:23:20 +0100 Subject: [PATCH 009/325] drivers/riello_usb.c: only log once about possibly missing battery.charge and battery.runtime [#1692] --- drivers/riello_usb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 15df617e1e..fe3cd7f4cd 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -70,6 +70,8 @@ static USBDevice_t usbdevice; static USBDeviceMatcher_t *reopen_matcher = NULL; static USBDeviceMatcher_t *regex_matcher = NULL; +static int localcalculation_logged = 0; + static int (*subdriver_command)(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) = NULL; static void ussleep(useconds_t usec) @@ -1091,10 +1093,13 @@ void upsdrv_updateinfo(void) dstate_setinfo("battery.runtime", "%.0f", battruntime/upsloadfactor); } else { - upsdebugx(0, "\n If you don't see values for battery.charge and " + if (!localcalculation_logged) { + upsdebugx(0, "\nIf you don't see values for battery.charge and " "battery.runtime or values are incorrect," "try setting \"localcalculation\" flag in \"ups.conf\" " "options section for this driver!\n"); + localcalculation_logged = 1; + } if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { dstate_setinfo("battery.charge", "%u", DevData.BatCap); dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); From 786b5aeffe014f94e8994e70b0f0cd0fe0a821fb Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 14:24:11 +0100 Subject: [PATCH 010/325] drivers/riello_usb.c: do not set bogus "ups.temperature" as 0, log low-prio message instead [#1692] --- drivers/riello_usb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index fe3cd7f4cd..cecf12600d 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -1107,7 +1107,10 @@ void upsdrv_updateinfo(void) } if (DevData.Tsystem == 255) { - dstate_setinfo("ups.temperature", "%u", 0 ); + /*dstate_setinfo("ups.temperature", "%u", 0);*/ + upsdebugx(4, "Reported temperature value is 0xFF, " + "probably meaning \"-1\" for error or " + "missing sensor - ignored"); } else if (DevData.Tsystem < 0xFF) { dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); From 5372bce7fb8510b3519d79832072e14467e282f1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 14:31:19 +0100 Subject: [PATCH 011/325] drivers/riello_usb.c: testvar("localcalculation") only once, use cached int in the loop [#1692] --- drivers/riello_usb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index cecf12600d..e2c4694d8b 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -70,6 +70,8 @@ static USBDevice_t usbdevice; static USBDeviceMatcher_t *reopen_matcher = NULL; static USBDeviceMatcher_t *regex_matcher = NULL; +/* Flag for estimation of battery.runtime and battery.charge */ +static int localcalculation = 0; static int localcalculation_logged = 0; static int (*subdriver_command)(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) = NULL; @@ -941,6 +943,11 @@ void upsdrv_initinfo(void) else upsdebugx(2, "Communication with UPS established"); + if (testvar("localcalculation")) { + localcalculation = 1; + } + dstate_setinfo("driver.parameter.localcalculation", "%d", localcalculation); + riello_parse_gi(&bufIn[0], &DevData); gpser_error_control = DevData.Identif_bytes[4]-0x30; @@ -1084,7 +1091,7 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0); dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); - if (testvar("localcalculation")) { + if (localcalculation) { battcharge = ((DevData.Ubat <= 129) && (DevData.Ubat >=107)) ? (((DevData.Ubat-107)*100)/22) : ((DevData.Ubat < 107) ? 0 : 100); battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; From 6c405af2d9b425590f3433937e92edc6ff9b052f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 18:35:54 +0100 Subject: [PATCH 012/325] Update riello_usb.txt Use "guesstimate" as common NUT term for future searches --- docs/man/riello_usb.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index 3ac3b796a6..d3123d912c 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -37,7 +37,7 @@ locally. This is for some Riello models (iPlug and iDialog series) that provide incorrect values. Local calculation is done according to nominal battery capacity, nominal battery voltage, actual battery charge, maximum and actual UPS load. + -Lead battery charge graph is not linear, so estimated charge value may not be +Lead battery charge graph is not linear, so guesstimated charge value may not be perfectly accurate. However it should be good enough to determine battery actual status and roughly estimate the time it can power the system. From cc122106cad7ba543b16023b713355f7aebb8bc0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 3 Nov 2022 18:38:07 +0100 Subject: [PATCH 013/325] Update riello_usb.c Log that guesstimation will be used instead of device readings (if any) --- drivers/riello_usb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index e2c4694d8b..019feae62b 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -945,6 +945,8 @@ void upsdrv_initinfo(void) if (testvar("localcalculation")) { localcalculation = 1; + upsdebugx(1, "Will guesstimate battery charge and runtime " + "instead of trusting device readings (if any)"); } dstate_setinfo("driver.parameter.localcalculation", "%d", localcalculation); From f494b25ebff8eadaf56da3e7172dc977b748902b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 28 Jan 2023 15:31:26 +0100 Subject: [PATCH 014/325] Update riello_usb.txt --- docs/man/riello_usb.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index 73037bf8a3..b5328bfeb8 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -44,7 +44,10 @@ nominal battery voltage, actual battery charge, maximum and actual UPS load. Lead battery charge graph is not linear, so guesstimated charge value may not be perfectly accurate. However it should be good enough to determine battery actual status and roughly estimate the time it can power the system. - ++ +NOTE: This keyword may be deprecated in future releases of the driver, in favor of +`runtimecal` and other settings which it requires (as seen in linkman:nutdrv_qx[8], +linkman:blazer_ser[8] and linkman:blazer_usb[8] drivers). AUTHOR ------ From bfc93479b2f05561ef5859a78f8cf0b2fae64792 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 28 Jan 2023 15:32:43 +0100 Subject: [PATCH 015/325] Update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 65fae6f7c2..853f832dac 100644 --- a/NEWS +++ b/NEWS @@ -101,6 +101,8 @@ https://github.com/networkupstools/nut/milestone/8 - riello_usb updates: * added `localcalculation` option to compute `battery.runtime` and `battery.charge` if the device provides bogus values [#1692, #1685] + (similar to `runtimecal` in some other drivers, may be refactored + to that configuration and logic model in later NUT releases) - powercom driver should now try harder to refresh data from device [#356] From 3c5c0019f7afc1adcc71809dfc1c3b151bf3aac5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 28 Jan 2023 15:46:23 +0100 Subject: [PATCH 016/325] Update riello_usb.txt --- docs/man/riello_usb.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index b5328bfeb8..3b35bc6053 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -45,9 +45,12 @@ Lead battery charge graph is not linear, so guesstimated charge value may not be perfectly accurate. However it should be good enough to determine battery actual status and roughly estimate the time it can power the system. + -NOTE: This keyword may be deprecated in future releases of the driver, in favor of +WARNING: This keyword may be deprecated in future releases of the driver, in favor of `runtimecal` and other settings which it requires (as seen in linkman:nutdrv_qx[8], linkman:blazer_ser[8] and linkman:blazer_usb[8] drivers). ++ +NOTE: In this release, such an option is not offered for the sibling +linkman:riello_ser[8] driver. AUTHOR ------ @@ -57,8 +60,13 @@ Massimo Zampieri SEE ALSO -------- +Related drivers +~~~~~~~~~~~~~~~ + +linkman:riello_ser[8] + The core driver -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~ linkman:nutupsdrv[8] From de79db37f62a42015a2d1e423eeb68c466492bdc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 16:33:41 +0100 Subject: [PATCH 017/325] .github/workflows/codeql.yml: extend with python Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2438bd0555..e61833bb1e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp' ] + language: [ 'cpp', 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support # TODO: Want to find Python sources to test like with LGTM, see https://github.com/networkupstools/nut/issues/1726 From e7266d25280b1aeaa7bdf34abf36d234b2a9834f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 4 Mar 2024 21:52:12 +0100 Subject: [PATCH 018/325] Jenkinsfile-dynamatrix: add a TODO about "completely out-of-tree" builds Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 11e14f15bf..85c42d0110 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -726,7 +726,11 @@ set | sort -n """ dynamatrixAxesCommonEnv: [ ['LANG=C','LC_ALL=C','TZ=UTC', // Build in a subdirectory to check that out-of-dir - // builds are healthy too + // builds are healthy too. + // NOTE: It would be useful to also have a recipe to build + // "completely out-of-tree", in a different filesystem (to + // make sure we do not rely on hard-links, relative paths, + // etc.) 'CI_BUILDDIR=obj', 'BUILD_WARNFATAL=yes','BUILD_WARNOPT=minimal' ] From 452a2b5c51ac9b16d30c793df08adefcdaf4b8d9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 4 Mar 2024 21:52:45 +0100 Subject: [PATCH 019/325] Jenkinsfile-dynamatrix: fix naming for cross-Windows builds ("Strict C" part is optional) Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 85c42d0110..8a9c661ff7 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -1217,7 +1217,7 @@ set | sort -n """ 'bodyParStages': dynacfgPipeline.slowBuildDefaultBody_ci_build ] // one slowBuild filter configuration - ,[name: 'Strict C and GNU standard builds on cross-Windows platforms (Linux+mingw), without distcheck and docs (allowed to fail)', + ,[name: (dynacfgPipeline.disableStrictCIBuild_CrossWindows ? '' : 'Strict C and ') + 'GNU standard builds on cross-Windows platforms (Linux+mingw), without distcheck and docs (allowed to fail)', disabled: dynacfgPipeline.disableSlowBuildCIBuild, //branchRegexSource: ~/^(PR-.+|.*fightwarn.*|.*Windows.*)$/, //branchRegexTarget: ~/fightwarn|Windows-.*/, From 64b5f6804805b53a7c5a6a6588b6bab5b2dfa728 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 16:43:45 +0100 Subject: [PATCH 020/325] Jenkinsfile-dynamatrix: fiddle with BUILD_WARNFATAL settings Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 8a9c661ff7..0dbcb21abc 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -478,8 +478,8 @@ set | sort -n """ // BUILD_TYPE=default-tgt:distcheck-light + NO_PKG_CONFIG=true ? ], dynamatrixAxesCommonEnv: [ - ['LANG=C','LC_ALL=C','TZ=UTC' - //,'BUILD_WARNFATAL=yes','BUILD_WARNOPT=hard' + ['LANG=C','LC_ALL=C','TZ=UTC','BUILD_WARNFATAL=yes' + //,'BUILD_WARNOPT=hard' ] ], allowedFailure: [ @@ -527,8 +527,8 @@ set | sort -n """ 'BUILD_TYPE': ['default-tgt:cppcheck'] ], dynamatrixAxesCommonEnv: [ - ['LANG=C','LC_ALL=C','TZ=UTC', 'DO_CLEAN_CHECK=no' - //,'BUILD_WARNFATAL=yes','BUILD_WARNOPT=hard' + ['LANG=C','LC_ALL=C','TZ=UTC', 'DO_CLEAN_CHECK=no', 'BUILD_WARNFATAL=yes' + //,'BUILD_WARNOPT=hard' ] ], allowedFailure: [ @@ -685,7 +685,8 @@ set | sort -n """ ], dynamatrixAxesCommonEnv: [ ['LANG=C','LC_ALL=C','TZ=UTC', - 'BUILD_WARNFATAL=yes','BUILD_WARNOPT=minimal' + 'BUILD_WARNFATAL=yes' + //,'BUILD_WARNOPT=medium' ] ], allowedFailure: [ @@ -732,7 +733,8 @@ set | sort -n """ // make sure we do not rely on hard-links, relative paths, // etc.) 'CI_BUILDDIR=obj', - 'BUILD_WARNFATAL=yes','BUILD_WARNOPT=minimal' + 'BUILD_WARNFATAL=yes' + //,'BUILD_WARNOPT=minimal' ] ], allowedFailure: [ @@ -771,7 +773,8 @@ set | sort -n """ ], dynamatrixAxesCommonEnv: [ ['LANG=C','LC_ALL=C','TZ=UTC', - 'BUILD_WARNFATAL=yes','BUILD_WARNOPT=minimal' + 'BUILD_WARNFATAL=yes' + //,'BUILD_WARNOPT=minimal' ] ], allowedFailure: [ From 9ddf48f89c5f51a9da590de9dd34bb8c7b51d0bc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 16:55:54 +0100 Subject: [PATCH 021/325] .github/workflows/codeql.yml, .github/codeql/codeql-config.yml: add "paths" for Python scripts Signed-off-by: Jim Klimov --- .github/codeql/codeql-config.yml | 4 ++++ .github/workflows/codeql.yml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .github/codeql/codeql-config.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000000..28eaa5d8a1 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +# For interpreted languages: +paths: + - scripts/python/module + - scripts/python/app diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index e61833bb1e..de590ee96a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -52,7 +52,7 @@ jobs: # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - + config-file: ./.github/codeql/codeql-config.yml # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) From 2c48b53f9f2777691cfe14a80f724744f1acf53d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 17:31:45 +0100 Subject: [PATCH 022/325] .github/workflows/codeql.yml: non-default C/C++ "Autobuild" implementation Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index de590ee96a..07a0a0c848 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -56,8 +56,16 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + #- name: Autobuild + # uses: github/codeql-action/autobuild@v3 + + # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + - if: matrix.language == 'c-cpp' + name: NUT CI Build + run: | + ./autogen.sh + ./configure --with-all=auto --with-dev --without-docs + make -j 8 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun From 6a526e43a6e917b0b5f5328a876d7add255a1d2d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 17:41:47 +0100 Subject: [PATCH 023/325] .github/workflows/codeql.yml: install prerequisite packages and ensure a "BUILD_TYPE=fightwarn-all ./ci_build.sh" loop for C/C++ "Autobuild" implementation Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 07a0a0c848..44fd44dc6a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -54,18 +54,31 @@ jobs: # queries: security-extended,security-and-quality config-file: ./.github/codeql/codeql-config.yml + # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + - if: matrix.language == 'cpp' + name: NUT CI Prerequisite packages (Ubuntu) + run: | + sudo apt update + sudo apt install libltdl-dev libtool libtool-bin cppcheck gcc g++ clang ccache + sudo apt install libgd-dev libcppunit-dev libsystemd-dev libssl-dev libnss3-dev augeas-tools libaugeas-dev augeas-lenses libusb-dev libusb-1.0-0-dev libi2c-dev libmodbus-dev libsnmp-dev libpowerman0-dev libfreeipmi-dev libipmimonitoring-dev libavahi-common-dev libavahi-core-dev libavahi-client-dev libgpiod-dev + sudo apt install libi2c-dev i2c-tools lm-sensors || true + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) #- name: Autobuild # uses: github/codeql-action/autobuild@v3 - # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages - - if: matrix.language == 'c-cpp' - name: NUT CI Build + - if: matrix.language == 'cpp' + name: NUT CI Build (fightwarn-all) run: | - ./autogen.sh - ./configure --with-all=auto --with-dev --without-docs - make -j 8 + BUILD_TYPE=fightwarn-all ./ci_build.sh + + #- if: matrix.language == 'x-cpp' + # name: NUT CI Build + # run: | + # ./autogen.sh + # ./configure --with-all=auto --with-dev --without-docs + # make -j 8 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun From 5e2f905d9acfca7156eeccd69a8c0cf55c81fb43 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 19:02:18 +0100 Subject: [PATCH 024/325] .github/workflows/codeql.yml: make "ubuntu-latest" formally a part of "matrix.os" for "if" clause Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 44fd44dc6a..3cee261d2a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -23,7 +23,7 @@ on: jobs: analyze: name: Analyze - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} permissions: actions: read contents: read @@ -35,7 +35,8 @@ jobs: language: [ 'cpp', 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - # TODO: Want to find Python sources to test like with LGTM, see https://github.com/networkupstools/nut/issues/1726 + os: [ubuntu-latest] + # TOTHINK: windows-latest, macos-latest steps: - name: Checkout repository @@ -55,7 +56,7 @@ jobs: config-file: ./.github/codeql/codeql-config.yml # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages - - if: matrix.language == 'cpp' + - if: matrix.language == 'cpp' && matrix.os == "ubuntu-latest" name: NUT CI Prerequisite packages (Ubuntu) run: | sudo apt update From 893409fcc641e90a438699259bbd6e53133b33e5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 22:08:07 +0100 Subject: [PATCH 025/325] .github/workflows/codeql.yml: fix stringification of "ubuntu-latest" Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3cee261d2a..376f9f2345 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -35,7 +35,7 @@ jobs: language: [ 'cpp', 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - os: [ubuntu-latest] + os: ['ubuntu-latest'] # TOTHINK: windows-latest, macos-latest steps: @@ -56,7 +56,7 @@ jobs: config-file: ./.github/codeql/codeql-config.yml # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages - - if: matrix.language == 'cpp' && matrix.os == "ubuntu-latest" + - if: matrix.language == 'cpp' && matrix.os == 'ubuntu-latest' name: NUT CI Prerequisite packages (Ubuntu) run: | sudo apt update From f9adab82ea1daa175759e0509280af36e5378b73 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 22:24:28 +0100 Subject: [PATCH 026/325] .github/workflows/codeql.yml: make a CodeQL matrix of compiler/NUT_SSL_VARIANTS/NUT_USB_VARIANTS instead of single fightwarn-all Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 376f9f2345..0cedfc5e25 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -37,6 +37,9 @@ jobs: # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support os: ['ubuntu-latest'] # TOTHINK: windows-latest, macos-latest + compiler: ['CC=gcc CXX=g++', 'CC=clang CXX=clang++'] + NUT_SSL_VARIANTS: ['no', 'nss', 'openssl'] + NUT_USB_VARIANTS: ['no', '1.0', '0.1'] steps: - name: Checkout repository @@ -70,9 +73,14 @@ jobs: # uses: github/codeql-action/autobuild@v3 - if: matrix.language == 'cpp' - name: NUT CI Build (fightwarn-all) + name: NUT CI Build (default-all-errors matrix) run: | - BUILD_TYPE=fightwarn-all ./ci_build.sh + BUILD_TYPE=default-all-errors ${{ matrix.compiler }} NUT_SSL_VARIANTS=${{ matrix.NUT_SSL_VARIANTS }} NUT_USB_VARIANTS=${{ matrix.NUT_USB_VARIANTS }} ./ci_build.sh + + #- if: matrix.language == 'cpp' + # name: NUT CI Build (fightwarn-all) + # run: | + # BUILD_TYPE=fightwarn-all ./ci_build.sh #- if: matrix.language == 'x-cpp' # name: NUT CI Build From f5c022a7709d9fc6015cab03438b4be3cd3462ff Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 6 Mar 2024 23:40:29 +0100 Subject: [PATCH 027/325] .github/workflows/codeql.yml: add ./ci_build.sh options to constrain build/check scenario workload sprawl Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0cedfc5e25..e7d91e07a1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -75,7 +75,7 @@ jobs: - if: matrix.language == 'cpp' name: NUT CI Build (default-all-errors matrix) run: | - BUILD_TYPE=default-all-errors ${{ matrix.compiler }} NUT_SSL_VARIANTS=${{ matrix.NUT_SSL_VARIANTS }} NUT_USB_VARIANTS=${{ matrix.NUT_USB_VARIANTS }} ./ci_build.sh + BUILD_TYPE=default-all-errors BUILD_SSL_ONCE=true DO_DISTCHECK=no CI_SKIP_CHECK=true CANBUILD_DOCS_ALL=no ${{ matrix.compiler }} NUT_SSL_VARIANTS=${{ matrix.NUT_SSL_VARIANTS }} NUT_USB_VARIANTS=${{ matrix.NUT_USB_VARIANTS }} ./ci_build.sh #- if: matrix.language == 'cpp' # name: NUT CI Build (fightwarn-all) From b855ff9b3566bc2f1c51ec2fcb4886501c7cf8df Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 7 Mar 2024 10:43:52 +0100 Subject: [PATCH 028/325] .github/workflows/codeql.yml: exile "python" analysis into one "included" matrix cell Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index e7d91e07a1..9b97b02a95 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,7 +32,8 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'python' ] + # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs + language: [ 'cpp' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support os: ['ubuntu-latest'] @@ -40,6 +41,13 @@ jobs: compiler: ['CC=gcc CXX=g++', 'CC=clang CXX=clang++'] NUT_SSL_VARIANTS: ['no', 'nss', 'openssl'] NUT_USB_VARIANTS: ['no', '1.0', '0.1'] + include: + # Add cell(s) to the matrix, beside the combinatorics made above + - language: 'python' + os: 'ubuntu-latest' + compiler: 'PYTHON=python3' + NUT_SSL_VARIANTS: 'no' + NUT_USB_VARIANTS: 'no' steps: - name: Checkout repository From 933c16f674fb3adc545cec89fb9f7710326c0365 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 7 Mar 2024 10:53:21 +0100 Subject: [PATCH 029/325] .github/workflows/codeql.yml: use C/C++ buids with "native" autogen+configure (and a single run for each config combo) Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9b97b02a95..5ba1163b50 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -40,7 +40,7 @@ jobs: # TOTHINK: windows-latest, macos-latest compiler: ['CC=gcc CXX=g++', 'CC=clang CXX=clang++'] NUT_SSL_VARIANTS: ['no', 'nss', 'openssl'] - NUT_USB_VARIANTS: ['no', '1.0', '0.1'] + NUT_USB_VARIANTS: ['no', 'libusb-1.0', 'libusb-0.1'] include: # Add cell(s) to the matrix, beside the combinatorics made above - language: 'python' @@ -80,22 +80,25 @@ jobs: #- name: Autobuild # uses: github/codeql-action/autobuild@v3 - - if: matrix.language == 'cpp' - name: NUT CI Build (default-all-errors matrix) - run: | - BUILD_TYPE=default-all-errors BUILD_SSL_ONCE=true DO_DISTCHECK=no CI_SKIP_CHECK=true CANBUILD_DOCS_ALL=no ${{ matrix.compiler }} NUT_SSL_VARIANTS=${{ matrix.NUT_SSL_VARIANTS }} NUT_USB_VARIANTS=${{ matrix.NUT_USB_VARIANTS }} ./ci_build.sh + #- if: matrix.language == 'cpp' + # name: NUT CI Build (default-all-errors matrix) + # run: | + # BUILD_TYPE=default-all-errors BUILD_SSL_ONCE=true DO_DISTCHECK=no CI_SKIP_CHECK=true CANBUILD_DOCS_ALL=no ${{ matrix.compiler }} NUT_SSL_VARIANTS=${{ matrix.NUT_SSL_VARIANTS }} NUT_USB_VARIANTS=${{ matrix.NUT_USB_VARIANTS }} ./ci_build.sh #- if: matrix.language == 'cpp' # name: NUT CI Build (fightwarn-all) # run: | # BUILD_TYPE=fightwarn-all ./ci_build.sh - #- if: matrix.language == 'x-cpp' - # name: NUT CI Build - # run: | - # ./autogen.sh - # ./configure --with-all=auto --with-dev --without-docs - # make -j 8 + # TOTHINK: Can we prepare the working area once (apt, autogen => containers?) + # and then spread it out for builds and analyses? + # Can ccache be used across builds? + - if: matrix.language == 'cpp' + name: NUT CI Build + run: | + ./autogen.sh + ./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all=auto --with-dev --without-docs ${{matrix.compiler}} --with-ssl=${{matrix.NUT_SSL_VARIANTS}} --with-usb=${{matrix.NUT_USB_VARIANTS}} + make -s -j 8 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun From 516b30022e53e3c7725183d554064e397ce14cad Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 7 Mar 2024 11:09:29 +0100 Subject: [PATCH 030/325] .github/workflows/codeql.yml: revise APT preinstallation * clang or gcc/g++ depending on matrix.compiler * collapse other pkgs into one call * add libneon*-dev Signed-off-by: Jim Klimov --- .github/workflows/codeql.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5ba1163b50..edb55bd86f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -71,9 +71,8 @@ jobs: name: NUT CI Prerequisite packages (Ubuntu) run: | sudo apt update - sudo apt install libltdl-dev libtool libtool-bin cppcheck gcc g++ clang ccache - sudo apt install libgd-dev libcppunit-dev libsystemd-dev libssl-dev libnss3-dev augeas-tools libaugeas-dev augeas-lenses libusb-dev libusb-1.0-0-dev libi2c-dev libmodbus-dev libsnmp-dev libpowerman0-dev libfreeipmi-dev libipmimonitoring-dev libavahi-common-dev libavahi-core-dev libavahi-client-dev libgpiod-dev - sudo apt install libi2c-dev i2c-tools lm-sensors || true + case x"${{matrix.compiler}}" in x*clang*) sudo apt install clang ;; x*) sudo apt install gcc g++ ;; esac + sudo apt install libltdl-dev libtool libtool-bin cppcheck ccache libgd-dev libcppunit-dev libsystemd-dev libssl-dev libnss3-dev augeas-tools libaugeas-dev augeas-lenses libusb-dev libusb-1.0-0-dev libmodbus-dev libsnmp-dev libpowerman0-dev libfreeipmi-dev libipmimonitoring-dev libavahi-common-dev libavahi-core-dev libavahi-client-dev libgpiod-dev libneon27-dev libi2c-dev i2c-tools lm-sensors # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) From 05629f0adc203906befb97a97f4c4682c213dd66 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 09:40:16 +0000 Subject: [PATCH 031/325] configure.ac, *.am: wherever we export CCACHE_* envvars for convenience - avoid doing so if they were not set at configure time [#2256] Signed-off-by: Jim Klimov --- Makefile.am | 10 +++++----- clients/Makefile.am | 10 +++++----- common/Makefile.am | 10 +++++----- configure.ac | 13 +++++++++++++ drivers/Makefile.am | 10 +++++----- include/Makefile.am | 10 +++++----- lib/Makefile.am | 10 +++++----- server/Makefile.am | 10 +++++----- tests/Makefile.am | 10 +++++----- tests/NIT/Makefile.am | 10 +++++----- tools/Makefile.am | 10 +++++----- tools/nut-scanner/Makefile.am | 10 +++++----- 12 files changed, 68 insertions(+), 55 deletions(-) diff --git a/Makefile.am b/Makefile.am index e1c62d90c6..989240aa1d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ # include directory for aclocal ACLOCAL_AMFLAGS = -I m4 diff --git a/clients/Makefile.am b/clients/Makefile.am index b873046cc0..6c7e9b914e 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ EXTRA_DIST = diff --git a/common/Makefile.am b/common/Makefile.am index 569ad9c6ec..7957fd170f 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ AM_CFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include AM_CXXFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include diff --git a/configure.ac b/configure.ac index 88b7be472e..38d85520c3 100644 --- a/configure.ac +++ b/configure.ac @@ -4784,6 +4784,19 @@ AC_ARG_VAR(CCACHE_BASEDIR) AC_ARG_VAR(CCACHE_DIR) AC_ARG_VAR(CCACHE_PATH) +dnl Some versions of ccache take poorly to an exported empty CCACHE_DIR etc. +dnl Avoid exporting them if not set at the configure time (assuming ci_build.sh +dnl integration or user's shell profile sets them persistently) +AS_IF([test x"${CCACHE_NAMESPACE-}" = x], [NUT_AM_EXPORT_CCACHE_NAMESPACE="#"], [NUT_AM_EXPORT_CCACHE_NAMESPACE=""]) +AC_SUBST(NUT_AM_EXPORT_CCACHE_NAMESPACE) +AS_IF([test x"${CCACHE_BASEDIR-}" = x], [NUT_AM_EXPORT_CCACHE_BASEDIR="#"], [NUT_AM_EXPORT_CCACHE_BASEDIR=""]) +AC_SUBST(NUT_AM_EXPORT_CCACHE_BASEDIR) +AS_IF([test x"${CCACHE_DIR-}" = x], [NUT_AM_EXPORT_CCACHE_DIR="#"], [NUT_AM_EXPORT_CCACHE_DIR=""]) +AC_SUBST(NUT_AM_EXPORT_CCACHE_DIR) + +dnl Application of PATH_DURING_CONFIGURE is also fenced by NUT_AM_EXPORT_CCACHE_PATH: +AS_IF([test x"${CCACHE_PATH-}" = x], [NUT_AM_EXPORT_CCACHE_PATH="#"], [NUT_AM_EXPORT_CCACHE_PATH=""]) +AC_SUBST(NUT_AM_EXPORT_CCACHE_PATH) PATH_DURING_CONFIGURE="$PATH" AC_SUBST(PATH_DURING_CONFIGURE) diff --git a/drivers/Makefile.am b/drivers/Makefile.am index c7477ae512..e3a60fdf87 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ # Make sure out-of-dir dependencies exist (especially when dev-building parts): $(top_builddir)/common/libcommon.la \ diff --git a/include/Makefile.am b/include/Makefile.am index 90c2dbc54b..2a2109c895 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ dist_noinst_HEADERS = attribute.h common.h extstate.h proto.h \ state.h str.h timehead.h upsconf.h nut_float.h nut_stdint.h nut_platform.h \ diff --git a/lib/Makefile.am b/lib/Makefile.am index 7d272d8de6..63a0427104 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ EXTRA_DIST = README.adoc diff --git a/server/Makefile.am b/server/Makefile.am index 878f16f588..f3dcf60ac2 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ # Make sure out-of-dir dependencies exist (especially when dev-building parts): $(top_builddir)/common/libcommon.la \ diff --git a/tests/Makefile.am b/tests/Makefile.am index d7a1cd9ccc..f328d3029c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ SUBDIRS = . NIT diff --git a/tests/NIT/Makefile.am b/tests/NIT/Makefile.am index f251fa7b1f..38206a53a3 100644 --- a/tests/NIT/Makefile.am +++ b/tests/NIT/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ EXTRA_DIST = nit.sh README.adoc diff --git a/tools/Makefile.am b/tools/Makefile.am index 97cdccf0f1..5a5f9d6840 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ # SUBDIRS are explicitly a listing of all the directories that make # must recurse into BEFORE processing the current directory. diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am index 4ed34f7214..db2e645b09 100644 --- a/tools/nut-scanner/Makefile.am +++ b/tools/nut-scanner/Makefile.am @@ -3,11 +3,11 @@ # Export certain values for ccache which NUT ci_build.sh can customize, # to facilitate developer iteration re-runs of "make" later. # At least GNU and BSD make implementations are okay with this syntax. -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@ -@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@ -@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ # Generally, list headers and/or sources which are re-generated # for nut-scanner in the parent dir From 4b07e8b2f94c130c5c78775c277040e7c0f53132 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 09:43:29 +0000 Subject: [PATCH 032/325] tools/nutconf/Makefile.am: apply convenience CCACHE exports like for other compiled sources [#2256] Signed-off-by: Jim Klimov --- tools/nutconf/Makefile.am | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/nutconf/Makefile.am b/tools/nutconf/Makefile.am index 53663e4a53..885ddc7c25 100644 --- a/tools/nutconf/Makefile.am +++ b/tools/nutconf/Makefile.am @@ -1,5 +1,14 @@ # Network UPS Tools: NUT configuration tool +# Export certain values for ccache which NUT ci_build.sh can customize, +# to facilitate developer iteration re-runs of "make" later. +# At least GNU and BSD make implementations are okay with this syntax. +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ +@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ + all: $(bin_PROGRAMS) bin_PROGRAMS = From b5acf59547841e061044072fbdb087ea15cfdca0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 10:41:32 +0000 Subject: [PATCH 033/325] common/nutstream.cpp: avoid pedantic warning about a const/static variable Signed-off-by: Jim Klimov --- common/nutstream.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/nutstream.cpp b/common/nutstream.cpp index 555cc44f15..3c8a773831 100644 --- a/common/nutstream.cpp +++ b/common/nutstream.cpp @@ -299,7 +299,23 @@ static const char* getTmpDirPath() { return "/tmp"; } +/* Pedantic builds complain about the static variable below... + * It is assumed safe to ignore since it is a std::string with + * no complex teardown at program exit. + */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic push +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS +# pragma GCC diagnostic ignored "-Wglobal-constructors" +# endif +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS +# pragma GCC diagnostic ignored "-Wexit-time-destructors" +# endif +#endif const std::string NutFile::m_tmp_dir(getTmpDirPath()); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic pop +#endif NutFile::NutFile(anonymous_t): m_name(""), From 59508c63d81e4e3822a29bad789369a09da79d0f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 10:26:37 +0000 Subject: [PATCH 034/325] Jenkinsfile-dynamatrix: add a section for direct use of autotools (once per platform) in all stable-branch builds In fallout of PR #2256 we had situations "caused" by tighter integration for NUT CI builds (and developer convenience via ./ci_build.sh) which were not seen on the NUT CI farm but could bite the common approach of `./autogen.sh && ./configure && make` on some (not all) platforms. Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 0dbcb21abc..9d06163fa1 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -421,6 +421,51 @@ set | sort -n """ //'bodyParStages': {} ] // one slowBuild filter configuration, autotools-Wall + ,[name: 'Default autotools driven build with default configuration, bitness and warning levels on each NUT CI farm platform (but with fatal warnings as of gnu99/gnu++11)', + disabled: dynacfgPipeline.disableSlowBuildAutotools, + branchRegexSource: ~/^(PR-.+|fightwarn.*)$/, + branchRegexTarget: dynacfgPipeline.branchStableRegex, + //branchRegexTarget: ~/fightwarn/, + appliesToChangedFilesRegex: dynacfgPipeline.appliesToChangedFilesRegex_C, + 'getParStages': { def dynamatrix, Closure body -> + return dynamatrix.generateBuild([ + //commonLabelExpr: dynacfgBase.commonLabelExpr, + //defaultDynamatrixConfig: dynacfgBase.defaultDynamatrixConfig, + requiredNodelabels: [], + excludedNodelabels: [], + + dynamatrixAxesVirtualLabelsMap: [ + //'BITS': [32, 64], + // 'CSTDVERSION': ['03', '2a'], + //'CSTDVERSION_${KEY}': [ ['c': '03', 'cxx': '03'], ['c': '99', 'cxx': '98'], ['c': '17', 'cxx': '2a'], 'ansi' ], + //'CSTDVERSION_${KEY}': [ ['c': '03', 'cxx': '03'], ['c': '99', 'cxx': '98'], ['c': '17', 'cxx': '2a'] ], + 'CSTDVERSION_${KEY}': [ ['c': '99', 'cxx': '11'] ], + 'CSTDVARIANT': ['gnu'] + ], + dynamatrixAxesCommonEnv: [ + ['LANG=C','LC_ALL=C','TZ=UTC', + // TODO: Find a way to pass space-separated tokens through withEnv() + //'CONFIG_OPTS=\"--with-all=auto\\ --with-docs=auto\\ --with-ssl=auto\\ --enable-Werror\\ --enable-warnings\\ --disable-Wcolor\\ --enable-silent-rules\"' + 'CONFIG_OPTS=--enable-Werror' + ] + ], + + mergeMode: [ 'dynamatrixAxesVirtualLabelsMap': 'replace', 'excludeCombos': 'merge' ], + allowedFailure: [ + dynacfgPipeline.axisCombos_WINDOWS, + dynacfgPipeline.axisCombos_STRICT_C + ], + runAllowedFailure: true, + //dynamatrixAxesLabels: ['OS_FAMILY', 'OS_DISTRO', '${COMPILER}VER', 'ARCH${ARCH_BITS}'], + //dynamatrixAxesLabels: [~/^OS/, '${COMPILER}VER', 'ARCH${ARCH_BITS}'], + dynamatrixAxesLabels: [~/^OS/, 'COMPILER'], + excludeCombos: dynacfgPipeline.excludeCombos_DEFAULT_STRICT_C + + [dynacfgPipeline.axisCombos_WINDOWS_CROSS] + ], body) + }, // getParStages + //'bodyParStages': {} + ] // one slowBuild filter configuration, autotools-everywhere + ,[name: 'Various non-docs distchecked target builds with main and ~newest supported C/C++ revisions (must pass on all platforms)', disabled: dynacfgPipeline.disableSlowBuildCIBuild, //branchRegexSource: ~/^(PR-.+|fightwarn.*)$/, From ec8d8811229e13d1773a7503c491dadaaa5494f9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 10:39:21 +0000 Subject: [PATCH 035/325] Jenkinsfile-dynamatrix: fix passing of (multi-token) DISTCHECK_FLAGS to autotools build/test variants Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 9d06163fa1..faa8dbdba6 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -254,7 +254,7 @@ import org.nut.dynamatrix.*; // Imported from jenkins-dynamatrix JSL vars/autotools.groovy: // a workaround for the cases of curiously missing MAKE envvar... - dynacfgPipeline.buildPhases['distcheck'] = """( if [ x"\${MAKE-}" = x ]; then echo "WARNING: MAKE is somehow unset, defaulting!" >&2; MAKE=make; fi; eval \${CONFIG_ENVVARS} time \${MAKE} \${MAKE_OPTS} distcheck DISTCHECK_FLAGS="\${CONFIG_OPTS}" )""" + dynacfgPipeline.buildPhases['distcheck'] = """( if [ x"\${MAKE-}" = x ]; then echo "WARNING: MAKE is somehow unset, defaulting!" >&2; MAKE=make; fi; eval \${CONFIG_ENVVARS} time \${MAKE} \${MAKE_OPTS} distcheck DISTCHECK_FLAGS=\${CONFIG_OPTS:+\\"\$CONFIG_OPTS\\"} )""" // Note: shellcheck/spellcheck/... require autotools currently // or need to be redefined with respective BUILD_TYPE From bc31ba21062123632c4e09a6b28dbd4b6852a96f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 10:42:16 +0000 Subject: [PATCH 036/325] Jenkinsfile-dynamatrix: wrap unstashing of sources into their own pipeline sub-stage Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index faa8dbdba6..b82e98bae1 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -285,7 +285,10 @@ set | sort -n """ } withEnvOptional(dynacfgPipeline.defaultTools) { - unstashCleanSrc(dynacfgPipeline.stashnameSrc) + stage('Unstash sources') { + unstashCleanSrc(dynacfgPipeline.stashnameSrc) + } + buildMatrixCellCI(dynacfgPipeline, dsbcClone, stageNameClone) //buildMatrixCellCI(dynacfgPipeline, dsbc, stageName) } @@ -315,7 +318,10 @@ set | sort -n """ } withEnvOptional(dynacfgPipeline.defaultTools) { - unstashCleanSrc(dynacfgPipeline.stashnameSrc) + stage('Unstash sources') { + unstashCleanSrc(dynacfgPipeline.stashnameSrc) + } + def dynacfgPipeline_ciBuild = dynacfgPipeline.clone() dynacfgPipeline_ciBuild.buildSystem = 'ci_build.sh' dynacfgPipeline_ciBuild.buildPhases = [:] From 44b1943f2bdbf227edc5ea538984cd8a73bbfc6f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 21:07:10 +0100 Subject: [PATCH 037/325] nutconf-related C++ sources: add new UPSMON-style notification keywords to vocabulary Signed-off-by: Jim Klimov --- common/nutconf.cpp | 13 +++++++++++++ common/nutwriter.cpp | 7 +++++++ include/nutconf.hpp | 7 +++++++ tools/nutconf/nutconf-cli.cpp | 7 +++++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/common/nutconf.cpp b/common/nutconf.cpp index 33adb3c47c..86cabda19f 100644 --- a/common/nutconf.cpp +++ b/common/nutconf.cpp @@ -3,6 +3,7 @@ Copyright (C) 2012 Emilien Kia + 2024 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1075,6 +1076,18 @@ UpsmonConfiguration::NotifyType UpsmonConfiguration::NotifyTypeFromString(const return NOTIFY_NOCOMM; else if(str=="NOPARENT") return NOTIFY_NOPARENT; + else if(str=="CAL") + return NOTIFY_CAL; + else if(str=="NOTCAL") + return NOTIFY_NOTCAL; + else if(str=="OFF") + return NOTIFY_OFF; + else if(str=="NOTOFF") + return NOTIFY_NOTOFF; + else if(str=="BYPASS") + return NOTIFY_BYPASS; + else if(str=="NOTBYPASS") + return NOTIFY_NOTBYPASS; else return NOTIFY_TYPE_MAX; } diff --git a/common/nutwriter.cpp b/common/nutwriter.cpp index 8cc232bcdc..5a07478885 100644 --- a/common/nutwriter.cpp +++ b/common/nutwriter.cpp @@ -3,6 +3,7 @@ Copyright (C) 2012 Vaclav Krpec + 2024 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -240,6 +241,12 @@ const NotifyFlagsStrings::TypeStrings NotifyFlagsStrings::type_str = { "REPLBATT", // NOTIFY_REPLBATT "NOCOMM", // NOTIFY_NOCOMM "NOPARENT", // NOTIFY_NOPARENT + "CAL\t", // NOTIFY_CAL (including padding) + "NOTCAL", // NOTIFY_NOTCAL + "OFF\t", // NOTIFY_OFF (including padding) + "NOTOFF", // NOTIFY_NOTOFF + "BYPASS", // NOTIFY_BYPASS + "NOTBYPASS", // NOTIFY_NOTBYPASS }; diff --git a/include/nutconf.hpp b/include/nutconf.hpp index 086db17e23..c23101db12 100644 --- a/include/nutconf.hpp +++ b/include/nutconf.hpp @@ -3,6 +3,7 @@ Copyright (C) 2012 Emilien Kia + 2024 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -658,6 +659,12 @@ class UpsmonConfiguration : public Serialisable NOTIFY_REPLBATT, NOTIFY_NOCOMM, NOTIFY_NOPARENT, + NOTIFY_CAL, + NOTIFY_NOTCAL, + NOTIFY_OFF, + NOTIFY_NOTOFF, + NOTIFY_BYPASS, + NOTIFY_NOTBYPASS, NOTIFY_TYPE_MAX }; diff --git a/tools/nutconf/nutconf-cli.cpp b/tools/nutconf/nutconf-cli.cpp index f20a3eb724..0f27d0d6ef 100644 --- a/tools/nutconf/nutconf-cli.cpp +++ b/tools/nutconf/nutconf-cli.cpp @@ -1,5 +1,7 @@ /* - * Copyright (C) 2013 - EATON + * Copyright (C) + * 2013 - EATON + * 2024 - Jim Klimov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,7 +132,8 @@ const char * Usage::s_text[] = { "UPS device is specified by the following sequence:", " [=]*", "Notification types:", - " ONLINE, ONBATT, LOWBATT, FSD, COMMOK, COMMBAD, SHUTDOWN, REPLBATT, NOCOMM, NOPARENT", + " ONLINE, ONBATT, LOWBATT, FSD, COMMOK, COMMBAD, SHUTDOWN, REPLBATT, NOCOMM, NOPARENT,", + " CAL, NOTCAL, OFF, NOTOFF, BYPASS, NOTBYPASS", "Notification flags:", " SYSLOG, WALL, EXEC, IGNORE", "User specification:", From 082a8b304d6cc77a5e281cb1fc70b5f44d1dcdb4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 21:08:43 +0100 Subject: [PATCH 038/325] nutconf-related C++ sources: fix typo in source var names: hotSync => hostSync Signed-off-by: Jim Klimov --- common/nutconf.cpp | 2 +- common/nutwriter.cpp | 2 +- include/nutconf.hpp | 2 +- tests/nutconf_parser_ut.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/nutconf.cpp b/common/nutconf.cpp index 86cabda19f..4efd831a44 100644 --- a/common/nutconf.cpp +++ b/common/nutconf.cpp @@ -1233,7 +1233,7 @@ void UpsmonConfigParser::onParseDirective(const std::string& directiveName, char { if(values.size()>0) { - _config->hotSync = StringToSettableNumber(values.front()); + _config->hostSync = StringToSettableNumber(values.front()); } } else if(directiveName == "DEADTIME") diff --git a/common/nutwriter.cpp b/common/nutwriter.cpp index 5a07478885..2e105e4b53 100644 --- a/common/nutwriter.cpp +++ b/common/nutwriter.cpp @@ -445,7 +445,7 @@ NutWriter::status_t UpsmonConfigWriter::writeConfig(const UpsmonConfiguration & UPSMON_DIRECTIVEX("MINSUPPLIES", unsigned int, config.minSupplies, false); UPSMON_DIRECTIVEX("POLLFREQ", unsigned int, config.poolFreq, false); UPSMON_DIRECTIVEX("POLLFREQALERT", unsigned int, config.poolFreqAlert, false); - UPSMON_DIRECTIVEX("HOSTSYNC", unsigned int, config.hotSync, false); + UPSMON_DIRECTIVEX("HOSTSYNC", unsigned int, config.hostSync, false); UPSMON_DIRECTIVEX("DEADTIME", unsigned int, config.deadTime, false); UPSMON_DIRECTIVEX("RBWARNTIME", unsigned int, config.rbWarnTime, false); UPSMON_DIRECTIVEX("NOCOMMWARNTIME", unsigned int, config.noCommWarnTime, false); diff --git a/include/nutconf.hpp b/include/nutconf.hpp index c23101db12..bd8eac18a0 100644 --- a/include/nutconf.hpp +++ b/include/nutconf.hpp @@ -638,7 +638,7 @@ class UpsmonConfiguration : public Serialisable void parseFromString(const std::string& str); Settable runAsUser, shutdownCmd, notifyCmd, powerDownFlag; - Settable minSupplies, poolFreq, poolFreqAlert, hotSync; + Settable minSupplies, poolFreq, poolFreqAlert, hostSync; Settable deadTime, rbWarnTime, noCommWarnTime, finalDelay; enum NotifyFlag { diff --git a/tests/nutconf_parser_ut.cpp b/tests/nutconf_parser_ut.cpp index f429b28cc9..4b182e3c16 100644 --- a/tests/nutconf_parser_ut.cpp +++ b/tests/nutconf_parser_ut.cpp @@ -278,7 +278,7 @@ void NutConfTest::testUpsmonConfigParser() CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find POWERDOWNFLAG '/etc/killpower'", string("/etc/killpower"), *conf.powerDownFlag); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find POLLFREQ 30", 30u, *conf.poolFreq); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find POLLFREQALERT 5", 5u, *conf.poolFreqAlert); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find HOSTSYNC 15", 15u, *conf.hotSync); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find HOSTSYNC 15", 15u, *conf.hostSync); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find DEADTIME 15", 15u, *conf.deadTime); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find RBWARNTIME 43200", 43200u, *conf.rbWarnTime); CPPUNIT_ASSERT_EQUAL_MESSAGE("Cannot find NOCOMMWARNTIME 300", 300u, *conf.noCommWarnTime); From e20a8698ec627d266ef6a3cc3b08a396da93c77c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 14 Mar 2024 11:22:56 +0000 Subject: [PATCH 039/325] Jenkinsfile-dynamatrix: rectify passing of CONFIG_OPTS [relies on nut/jenkins-dynamatrix#34] Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index b82e98bae1..9e82ba6e2f 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -449,10 +449,13 @@ set | sort -n """ 'CSTDVARIANT': ['gnu'] ], dynamatrixAxesCommonEnv: [ + // One set of several simultaneously exported envvars! + // CONFIG_OPTS are picked up by our dynamatrix configuration + // and substituted into shell "as is" for normal builds + // (so splitting into many tokens), or quoted as a single + // token DISTCHECK_FLAGS in its stage (split by make later). ['LANG=C','LC_ALL=C','TZ=UTC', - // TODO: Find a way to pass space-separated tokens through withEnv() - //'CONFIG_OPTS=\"--with-all=auto\\ --with-docs=auto\\ --with-ssl=auto\\ --enable-Werror\\ --enable-warnings\\ --disable-Wcolor\\ --enable-silent-rules\"' - 'CONFIG_OPTS=--enable-Werror' + 'CONFIG_OPTS=--with-all=auto --with-docs=auto --with-ssl=auto --enable-Werror --enable-warnings --disable-Wcolor --enable-silent-rules' ] ], From a760767fab7ba75248f0e0ccb0a60264f0c1695b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 21:17:24 +0100 Subject: [PATCH 040/325] nutconf-related C++ sources: deprecate certain terminology and keywords [#840] Signed-off-by: Jim Klimov --- common/nutconf.cpp | 13 +++++++------ common/nutwriter.cpp | 5 +++-- include/nutconf.hpp | 4 ++-- tests/nutconf_ut.cpp | 5 +++-- tools/nutconf/nutconf-cli.cpp | 12 ++++++------ 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/common/nutconf.cpp b/common/nutconf.cpp index 4efd831a44..19ae9afd5b 100644 --- a/common/nutconf.cpp +++ b/common/nutconf.cpp @@ -1190,7 +1190,7 @@ void UpsmonConfigParser::onParseDirective(const std::string& directiveName, char monitor.powerValue = StringToSettableNumber(*it++); monitor.username = *it++; monitor.password = *it++; - monitor.isMaster = (*it) == "master"; + monitor.isMaster = (*it) == "primary"; // master for NUT v2.7.4 and older _config->monitors.push_back(monitor); } } @@ -1583,11 +1583,11 @@ UpsdUsersConfiguration::upsmon_mode_t UpsdUsersConfiguration::getUpsmonMode() co { std::string mode_str = getStr("upsmon", "upsmon"); - if ("master" == mode_str) - return UPSMON_MASTER; + if ("primary" == mode_str || "master" == mode_str) + return UPSMON_PRIMARY; - if ("slave" == mode_str) - return UPSMON_SLAVE; + if ("secondary" == mode_str || "slave" == mode_str) + return UPSMON_SECONDARY; return UPSMON_UNDEF; } @@ -1597,7 +1597,8 @@ void UpsdUsersConfiguration::setUpsmonMode(upsmon_mode_t mode) { assert(UPSMON_UNDEF != mode); - setStr("upsmon", "upsmon", (UPSMON_MASTER == mode ? "master" : "slave")); + setStr("upsmon", "upsmon", (UPSMON_PRIMARY == mode ? "primary" : "secondary")); + /* NUT v2.7.4 and older: setStr("upsmon", "upsmon", (UPSMON_PRIMARY == mode ? "master" : "slave")); */ } diff --git a/common/nutwriter.cpp b/common/nutwriter.cpp index 2e105e4b53..a5c0c64e93 100644 --- a/common/nutwriter.cpp +++ b/common/nutwriter.cpp @@ -398,8 +398,9 @@ static std::string serializeMonitor(const UpsmonConfiguration::Monitor & monitor // Username & password directive << monitor.username << ' ' << monitor.password << ' '; - // Master/slave - directive << (monitor.isMaster ? "master" : "slave"); + // Primary/secondary (legacy master/slave) + directive << (monitor.isMaster ? "primary" : "secondary"); + /* NUT v2.7.4 and older: directive << (monitor.isMaster ? "master" : "slave");*/ return directive.str(); } diff --git a/include/nutconf.hpp b/include/nutconf.hpp index bd8eac18a0..af03a1b5e7 100644 --- a/include/nutconf.hpp +++ b/include/nutconf.hpp @@ -1084,8 +1084,8 @@ class UpsdUsersConfiguration : public GenericConfiguration /** upsmon mode */ typedef enum { UPSMON_UNDEF = 0, /**< Unknown mode */ - UPSMON_MASTER, /**< Master mode */ - UPSMON_SLAVE, /**< Slave mode */ + UPSMON_PRIMARY, /**< Primary (legacy "Master") mode */ + UPSMON_SECONDARY, /**< Secondary (legacy "Slave") mode */ } upsmon_mode_t; /** User-specific configuration attributes getters and setters \{ */ diff --git a/tests/nutconf_ut.cpp b/tests/nutconf_ut.cpp index ba8c8947d1..612a772c6a 100644 --- a/tests/nutconf_ut.cpp +++ b/tests/nutconf_ut.cpp @@ -3,6 +3,7 @@ Copyright (C) 2012 Vaclav Krpec + 2024 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -211,7 +212,7 @@ void NutConfigUnitTest::testUpsdUsersConfiguration() { load(static_cast(&config), ABS_TOP_SRCDIR "/conf/upsd.users.sample"); config.setPassword("upsmon", "ytrewq"); - config.setUpsmonMode(nut::UpsdUsersConfiguration::UPSMON_MASTER); + config.setUpsmonMode(nut::UpsdUsersConfiguration::UPSMON_PRIMARY); config.setPassword("admin", "qwerty=ui"); config.setActions("admin", nut::ConfigParamList(1, "SET")); @@ -225,7 +226,7 @@ void NutConfigUnitTest::testUpsdUsersConfiguration() { "\n" "[upsmon]\n" "\tpassword = ytrewq\n" - "\tupsmon master\n" + "\tupsmon primary\n" "\n" ); } diff --git a/tools/nutconf/nutconf-cli.cpp b/tools/nutconf/nutconf-cli.cpp index 0f27d0d6ef..8f32fe4ff8 100644 --- a/tools/nutconf/nutconf-cli.cpp +++ b/tools/nutconf/nutconf-cli.cpp @@ -128,7 +128,7 @@ const char * Usage::s_text[] = { "", "NUT modes: standalone, netserver, netclient, controlled, manual, none", "Monitor is specified by the following sequence:", - " [:] (\"master\"|\"slave\")", + " [:] (\"primary\"|\"secondary\")", "UPS device is specified by the following sequence:", " [=]*", "Notification types:", @@ -2090,7 +2090,7 @@ static nut::UpsmonConfiguration::Monitor monitor( monitor.hostname = host_port.substr(0, colon_idx); monitor.port = port; monitor.powerValue = power_value; - monitor.isMaster = "master" == mode; + monitor.isMaster = ("primary" == mode || "master" == mode); return monitor; } @@ -2594,11 +2594,11 @@ static void setUsers( nut::UpsdUsersConfiguration::upsmon_mode_t mode = nut::UpsdUsersConfiguration::UPSMON_UNDEF; - if ("master" == upsmon_user->mode) - mode = nut::UpsdUsersConfiguration::UPSMON_MASTER; + if ("primary" == upsmon_user->mode || "master" == upsmon_user->mode) + mode = nut::UpsdUsersConfiguration::UPSMON_PRIMARY; - else if ("slave" == upsmon_user->mode) - mode = nut::UpsdUsersConfiguration::UPSMON_SLAVE; + else if ("secondary" == upsmon_user->mode || "slave" == upsmon_user->mode) + mode = nut::UpsdUsersConfiguration::UPSMON_SECONDARY; else { std::cerr From 1bf62e569cf6dad0cecc5ad9f4c7aa4e53aa864b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 09:19:11 +0000 Subject: [PATCH 041/325] Makefile.am: make sure that "make all" ends up making all types of docs Signed-off-by: Jim Klimov --- Makefile.am | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile.am b/Makefile.am index 989240aa1d..24e3ad7a83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,6 +9,13 @@ @NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ @NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ +# First target defines default behavior: all +# We follow up with another pass to `make doc` because our wild recipes +# sometimes preclude generating all of them on the first pass (FIXME!) +# missing e.g. PDF and HTML which then pop up in `make check` footprint. +all: all-recursive + +@$(MAKE) $(AM_MAKEFLAGS) doc + # include directory for aclocal ACLOCAL_AMFLAGS = -I m4 From 2157cd2c639aa24bc5b1fd8c43924e6bfc25b619 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 12:18:41 +0000 Subject: [PATCH 042/325] tools/gitlog2changelog.py.in: trivialize author names into plain ASCII Older asciidoc/a2x/dblatex stack fails with non-ASCII characters in section titles (date and commit author become ChangeLog sections). Inspired by: * http://aerostitch.github.io/misc/asciidoc/asciidoc-title_uft8.html * https://stackoverflow.com/questions/51710082/what-does-unicodedata-normalize-do-in-python * https://stackoverflow.com/questions/38697037/how-to-convert-python-2-unicode-function-into-correct-python-3-x-syntax Signed-off-by: Jim Klimov --- tools/gitlog2changelog.py.in | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/gitlog2changelog.py.in b/tools/gitlog2changelog.py.in index a5e4d78660..3bed9bfa93 100755 --- a/tools/gitlog2changelog.py.in +++ b/tools/gitlog2changelog.py.in @@ -10,6 +10,17 @@ from textwrap import TextWrapper import sys import subprocess +# Python 3 compatibility hack +try: + unicode('') +except NameError: + unicode = str + +try: + import unicodedata +except: + pass + rev_range = "HEAD" if len(sys.argv) > 1: @@ -104,6 +115,13 @@ for line in fin: try: author = authorList[1] author = author[0 : len(author) - fin_chop] + try: + if isinstance(author, str): + author = unicodedata.normalize(u'NFKD', unicode(author, "UTF=8")).encode('ascii', 'ignore').decode('utf8') + else: + author = unicodedata.normalize(u'NFKD', author).encode('ascii', 'ignore').decode('utf8') + except Exception as e: + print("Could not unicodedata.normalize() author '%s': %s" % (author, str(e))) authorFound = True except: print("Could not parse authorList = '%s'" % (line)) From 0876daefd0ce9b3a546bbd7438de750d4c7187a6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 12:37:16 +0000 Subject: [PATCH 043/325] docs/Makefile.am: hint to asciidoc/dblatex to trivialize section names into ASCII themselves Inspired by http://aerostitch.github.io/misc/asciidoc/asciidoc-title_uft8.html but did not directly help at least for Ubuntu 14.04 worker NOTE: Fallback suggestion to add --dblatex-opts="--param=latex.encoding=utf8" actually broke the PDF doc builds, not only for ChangeLog. Signed-off-by: Jim Klimov --- docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index ee4560246b..e82323e757 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -244,7 +244,7 @@ $(top_builddir)/ChangeLog.adoc: $(top_builddir)/ChangeLog exit ; \ } ; \ echo " DOC-CHANGELOG-ASCIIDOC $${INPUT} => $@" \ - && printf "ifdef::txt[]\n== Very detailed Change Log\nendif::txt[]\n\n" > "$@.tmp" \ + && printf "ifdef::txt[]\n== Very detailed Change Log\n:ascii-ids:\nendif::txt[]\n\n" > "$@.tmp" \ && TABCHAR="`printf '\t'`" \ && $(SED) \ -e 's,^\([0-9a-zA-Z]\),=== \1,' \ From 1d768d41779e7faf98da825ab68e873c2c2fb73a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 14:35:43 +0000 Subject: [PATCH 044/325] configure.ac, Makefile.am, docs/Makefile.am, tools/gitlog2changelog.py.in: detect if we should mangle ChangeLog.pdf section titles with non-ASCII contributor names Signed-off-by: Jim Klimov --- Makefile.am | 8 +++++++- configure.ac | 7 +++++++ docs/Makefile.am | 8 +++++++- tools/gitlog2changelog.py.in | 23 ++++++++++++++++------- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 24e3ad7a83..0453994435 100644 --- a/Makefile.am +++ b/Makefile.am @@ -331,11 +331,17 @@ dummy-stamp: ChangeLog: dummy-stamp +@$(MAKE) $(AM_MAKEFLAGS) $(abs_top_builddir)/ChangeLog +if WITH_PDF_NONASCII_TITLES +WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=yes +else +WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=no +endif + # Be sure to not confuse with a DIST'ed file (and so try to overwrite it): $(abs_top_builddir)/ChangeLog: tools/gitlog2changelog.py dummy-stamp @cd $(abs_top_srcdir) && \ if test -e .git ; then \ - CHANGELOG_FILE="$@" $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ + CHANGELOG_FILE="$@" $(WITH_PDF_NONASCII_TITLES_ENVVAR) $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ { printf "gitlog2changelog.py failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; } ; \ else \ if test x"$(abs_top_srcdir)" != x"$(abs_top_builddir)" -a -s ./ChangeLog ; then \ diff --git a/configure.ac b/configure.ac index 38d85520c3..40b3ca9286 100644 --- a/configure.ac +++ b/configure.ac @@ -2722,6 +2722,7 @@ dnl not fail if we have no tools to generate it (so add to SKIP list). pdf*) AC_MSG_CHECKING([if dblatex version can build ${nut_doc_build_target_base} (minimum required ${DBLATEX_MIN_VERSION})]) can_build_doc_pdf=no + can_build_doc_pdf_nonascii_titles=no AX_COMPARE_VERSION([${DBLATEX_VERSION}], [ge], [${DBLATEX_MIN_VERSION}], [ ( cd "$DOCTESTDIR" && ${A2X} --format=pdf --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.pdf ) && can_build_doc_pdf=yes rm -f "${DOCTESTDIR}"/asciidoc.pdf @@ -2729,6 +2730,10 @@ dnl not fail if we have no tools to generate it (so add to SKIP list). if test "${can_build_doc_pdf}" = yes ; then AC_MSG_RESULT(yes) DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + AC_MSG_CHECKING([if dblatex can process non-ASCII section titles for PDF]) + ( cd "$DOCTESTDIR" && sed -e 's/^Intro/'"`printf '\303\215'`"'ntro/' -e 's/Works in Progress/Works '"`printf '\303\255'`"'n Progress/' < "${abs_srcdir}"/docs/asciidoc.txt > asciidoc.tmp.txt && ${A2X} --format=pdf --destination-dir=. asciidoc.tmp.txt && test -s asciidoc.tmp.pdf ) && can_build_doc_pdf_nonascii_titles=yes + rm -f "${DOCTESTDIR}"/asciidoc.tmp.pdf + AC_MSG_RESULT(${can_build_doc_pdf_nonascii_titles}) else AC_MSG_RESULT(no) if test "${nut_doc_build_target_flag}" = "yes" ; then @@ -2804,6 +2809,8 @@ no) ;; esac +AM_CONDITIONAL(WITH_PDF_NONASCII_TITLES, [test x"$can_build_doc_pdf_nonascii_titles" = xyes]) + NUT_REPORT_FEATURE([build specific documentation format(s)], [${nut_with_doc}], [${DOC_BUILD_LIST}], [WITH_DOCS], [Define to enable overall documentation generation]) diff --git a/docs/Makefile.am b/docs/Makefile.am index e82323e757..a49ec8ff57 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -233,6 +233,12 @@ $(top_builddir)/ChangeLog: # (and claims why: "Using $< in a non-suffix rule context is a GNUmake idiom"), # but it has a "$?" for "list of dependencies that are newer than the target". # For more details see https://man.freebsd.org/cgi/man.cgi +if WITH_PDF_NONASCII_TITLES +A2X_ASCII_IDS = +else !WITH_PDF_NONASCII_TITLES +A2X_ASCII_IDS = ":ascii-ids:\n" +endif !WITH_PDF_NONASCII_TITLES + $(top_builddir)/ChangeLog.adoc: $(top_builddir)/ChangeLog @INPUT="$?"; \ test -n "$${INPUT}" || INPUT="$$(top_builddir)/ChangeLog" ; \ @@ -244,7 +250,7 @@ $(top_builddir)/ChangeLog.adoc: $(top_builddir)/ChangeLog exit ; \ } ; \ echo " DOC-CHANGELOG-ASCIIDOC $${INPUT} => $@" \ - && printf "ifdef::txt[]\n== Very detailed Change Log\n:ascii-ids:\nendif::txt[]\n\n" > "$@.tmp" \ + && printf "ifdef::txt[]\n== Very detailed Change Log\n"$(A2X_ASCII_IDS)"endif::txt[]\n\n" > "$@.tmp" \ && TABCHAR="`printf '\t'`" \ && $(SED) \ -e 's,^\([0-9a-zA-Z]\),=== \1,' \ diff --git a/tools/gitlog2changelog.py.in b/tools/gitlog2changelog.py.in index 3bed9bfa93..7518f6a5a8 100755 --- a/tools/gitlog2changelog.py.in +++ b/tools/gitlog2changelog.py.in @@ -92,6 +92,14 @@ messageNL = False files = "" prevAuthorLine = "" +# Legacy default: keep as is +authorMustBeASCII = False +authorMustBeASCII_inverse_setting = str(os.environ.get("WITH_PDF_NONASCII_TITLES", "")).upper() +if authorMustBeASCII_inverse_setting in ["YES", "TRUE"]: + authorMustBeASCII = False +elif authorMustBeASCII_inverse_setting in ["NO", "FALSE"]: + authorMustBeASCII = True + # See also: https://github.com/python/cpython/blob/main/Lib/textwrap.py wrapper = TextWrapper(initial_indent="\t", subsequent_indent="\t ", break_on_hyphens=False, break_long_words=False) @@ -115,13 +123,14 @@ for line in fin: try: author = authorList[1] author = author[0 : len(author) - fin_chop] - try: - if isinstance(author, str): - author = unicodedata.normalize(u'NFKD', unicode(author, "UTF=8")).encode('ascii', 'ignore').decode('utf8') - else: - author = unicodedata.normalize(u'NFKD', author).encode('ascii', 'ignore').decode('utf8') - except Exception as e: - print("Could not unicodedata.normalize() author '%s': %s" % (author, str(e))) + if authorMustBeASCII: + try: + if isinstance(author, str): + author = unicodedata.normalize(u'NFKD', unicode(author, "UTF=8")).encode('ascii', 'ignore').decode('utf8') + else: + author = unicodedata.normalize(u'NFKD', author).encode('ascii', 'ignore').decode('utf8') + except Exception as e: + print("Could not unicodedata.normalize() author '%s': %s" % (author, str(e))) authorFound = True except: print("Could not parse authorList = '%s'" % (line)) From c2e859f55b26731c6a2f074dacdf3b82cb980161 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 19:51:20 +0100 Subject: [PATCH 045/325] Jenkinsfile-dynamatrix: exclude GCC on OpenBSD 6.5 from autotools CI builds Old compiler that won't hush about warnings, pollutes CI dashboard. Equivalent builds handled by `ci_build.sh` are in quiet mode for the first compilation attempt (usually the only one, if all is OK) so these warnings are just not seen by build-log analysis parser. Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 9e82ba6e2f..5a9f61972e 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -470,6 +470,11 @@ set | sort -n """ dynamatrixAxesLabels: [~/^OS/, 'COMPILER'], excludeCombos: dynacfgPipeline.excludeCombos_DEFAULT_STRICT_C + [dynacfgPipeline.axisCombos_WINDOWS_CROSS] + + [[~/OS_DISTRO=openbsd-6\./, ~/COMPILER=GCC/]] + // Here we picked just OSes and compilers (gcc or clang), + // so exclude systems which have e.g. gcc-4.2.1 which claims + // type range comparison warnings despite pragma fencing. + // gcc-4.8.x on CentOS 7 and Ubuntu 14.04 looks already okay. ], body) }, // getParStages //'bodyParStages': {} From 6a874f11fd05872b8f0298f57571bb8bf2440184 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 18 Mar 2024 20:45:42 +0100 Subject: [PATCH 046/325] Jenkinsfile-dynamatrix: for autotools-only builds, select by OS_DISTRO (avoide duplicates with OS_FAMILY) Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 5a9f61972e..69bc55d321 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -467,7 +467,7 @@ set | sort -n """ runAllowedFailure: true, //dynamatrixAxesLabels: ['OS_FAMILY', 'OS_DISTRO', '${COMPILER}VER', 'ARCH${ARCH_BITS}'], //dynamatrixAxesLabels: [~/^OS/, '${COMPILER}VER', 'ARCH${ARCH_BITS}'], - dynamatrixAxesLabels: [~/^OS/, 'COMPILER'], + dynamatrixAxesLabels: [~/^OS_DISTRO/, 'COMPILER'], excludeCombos: dynacfgPipeline.excludeCombos_DEFAULT_STRICT_C + [dynacfgPipeline.axisCombos_WINDOWS_CROSS] + [[~/OS_DISTRO=openbsd-6\./, ~/COMPILER=GCC/]] From 056d00886fa712dd0557e579b420b577ff6d983d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 19 Mar 2024 12:39:10 +0000 Subject: [PATCH 047/325] scripts/installer: avoid SCM-tracking a symlink to NUT source root Signed-off-by: Jim Klimov --- scripts/installer/Makefile.am | 8 ++++++++ scripts/installer/README.adoc | 12 ++++++------ scripts/installer/nut | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) delete mode 120000 scripts/installer/nut diff --git a/scripts/installer/Makefile.am b/scripts/installer/Makefile.am index 10a67121cb..27da718516 100644 --- a/scripts/installer/Makefile.am +++ b/scripts/installer/Makefile.am @@ -32,6 +32,10 @@ EXTRA_DIST = \ SPELLCHECK_SRC = README.adoc common/README_ipp-os-shutdown.adoc +nut: + rm -f "$@" + $(LN_S) $(top_srcdir) "$@" + # NOTE: Due to portability, we do not use a GNU percent-wildcard extension. # We also have to export some variables that may be tainted by relative # paths when parsing the other makefile (e.g. MKDIR_P that may be defined @@ -54,4 +58,8 @@ spellcheck spellcheck-interactive spellcheck-sortdict: CLEANFILES = *-spellchecked +# Remove "nut" if it is a symlink to the source tree +clean-local: + if test -L nut || test -h nut ; then rm -f nut ; fi + MAINTAINERCLEANFILES = Makefile.in .dirstamp diff --git a/scripts/installer/README.adoc b/scripts/installer/README.adoc index 7c94a8be24..1cda6d7b32 100644 --- a/scripts/installer/README.adoc +++ b/scripts/installer/README.adoc @@ -8,13 +8,13 @@ of Eaton by Frederic Bohe, Vaclav Krpec, Arnaud Quette and Jim Klimov. This includes the package (tarball) creation script which relies on presence of third-party library binaries in a `$ARCH/libs` directory, -and init-scripts from NUT source tree (originally expected as a "nut" -subdirectory), as well as an interactive installer script to set up -the package on a target deployment covering package (re-)installation, -initial device discovery, password setup, etc., and helper scripts -for status overview and shutdown handling. +and init-scripts from NUT source tree (originally expected as a `nut` +subdirectory, can be a symlink to `../..`), as well as an interactive +installer script to set up the package on a target deployment covering +package (re-)installation, initial device discovery, password setup, +etc., and helper scripts for status overview and shutdown handling. -The installer relies on "nutconf" tool (emulating dummy script for +The installer relies on `nutconf` tool (emulating dummy script for tests provided here), which is part of NUT sources. Note that heavy use of `LD_LIBRARY_PATH` in these scripts may become diff --git a/scripts/installer/nut b/scripts/installer/nut deleted file mode 120000 index c25bddb6dd..0000000000 --- a/scripts/installer/nut +++ /dev/null @@ -1 +0,0 @@ -../.. \ No newline at end of file From 346071653adaad3ff5cbbd4848535773bbb5f56d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 19 Mar 2024 13:10:16 +0000 Subject: [PATCH 048/325] scripts/installer/README.adoc, docs/nut.dict: update about directory layout and contents expected by make_package.sh Signed-off-by: Jim Klimov --- docs/nut.dict | 9 +++++++- scripts/installer/README.adoc | 43 ++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/docs/nut.dict b/docs/nut.dict index 9695f1816e..c79045136b 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3470 utf-8 +personal_ws-1.1 en 3478 utf-8 AAC AAS ABI @@ -1570,6 +1570,7 @@ aec af aggregator ai +aix al ala alarmcenables @@ -2198,6 +2199,7 @@ hotplug hotplugging hovercharge hpe +hpux href htaccess html @@ -2365,6 +2367,7 @@ libdir libdummy libexec libexecdir +libexpat libfreeipmi libgd libgpgme @@ -3023,6 +3026,7 @@ sitop sizeof ske skel +sl slackpkg slaveid slavesync @@ -3045,8 +3049,11 @@ socat sockdebug socketname socomec +solari solaris +solcmn solibs +solint solis somename somepass diff --git a/scripts/installer/README.adoc b/scripts/installer/README.adoc index 1cda6d7b32..e6656b736d 100644 --- a/scripts/installer/README.adoc +++ b/scripts/installer/README.adoc @@ -8,12 +8,53 @@ of Eaton by Frederic Bohe, Vaclav Krpec, Arnaud Quette and Jim Klimov. This includes the package (tarball) creation script which relies on presence of third-party library binaries in a `$ARCH/libs` directory, +pre-built package files (courtesy of NUT `make package` recipes), and init-scripts from NUT source tree (originally expected as a `nut` -subdirectory, can be a symlink to `../..`), as well as an interactive +subdirectory, can be a symlink to `../..`; currently copies stored in +the `$ARCH` subdirectories; eventually should be taken from NUT sources +during build, or from packages), as well as an interactive text-mode installer script to set up the package on a target deployment covering package (re-)installation, initial device discovery, password setup, etc., and helper scripts for status overview and shutdown handling. +Example `$ARCH` related directory layout in original posting (binary +files mentioned below are not provided into NUT Git source code base); +these are the contents `make_package.sh` script expects to work with +(you can see the names mentioned in `find ... | grep -v ...` filters): + +* `aix/` example for AIX 6 and 7 based IPSS Unix releases: + * `libs/`: `libcrypto.a`, `libcrypto.so`, etc... + * `nut-2.6.5-1.aix6.1.ppc.rpm` and `nut-client-2.6.5-1.aix6.1.ppc.rpm` + package files + * `nutconf` binary for the platform + * `aix_init` script + * `ipp-os-shutdown.conf.sample` + +* `hpux/` for PA-RISC: + * `libs/`: `libcrypto.sl`, `libexpat.sl`, `libiconv.sl`, `libintl.sl`, + `libltdl.sl`, `libneon.sl`, `libnetsnmp.sl.30`, `libssl.sl`, `libz.sl` + * Notably, `libnutscan.sl.1` (other platforms did not carry a copy) + * `nut.depot.tar.gz` package file + * `nutconf` binary for the platform + * `ipp-os-shutdown.conf.sample` + +* Solaris (SPARC and X86) spread across 3 directories: + * `solcmn/` with common platform-independent files: + * `ipp-os-shutdown.conf.sample` + * `solaris_init` script + + * `solari` with SPARC binaries: + * `libs/`: `libcrypto.so.0.9.8`, `libz.so`, etc. + * `NUT_solaris_sparc_package2.6.5.local` package file + * `nutconf` binary for the platform + + * `solint` with X86 binaries: + * `libs/`: `libcrypto.so.1.0.0`, `libgcc_s.so.1`, `libltdl.so.7`, + `libneon.so.27`, `libnetsnmp.so.15`, `libproxy.so.0`, + `libssl.so.1.0.0`, `libstdc++.so.6`, `libwrap.so.1` + * `NUT_solaris_i386_package2.6.5.local` package file + * `nutconf` binary for the platform + The installer relies on `nutconf` tool (emulating dummy script for tests provided here), which is part of NUT sources. From 9005cde004ddeb48cab30e86a4b45e8fcb6c80f2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 19 Mar 2024 13:14:46 +0000 Subject: [PATCH 049/325] scripts/installer/make_package.sh: update comments Signed-off-by: Jim Klimov --- scripts/installer/make_package.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/installer/make_package.sh b/scripts/installer/make_package.sh index 2ebc08bf77..6c3aa66e81 100755 --- a/scripts/installer/make_package.sh +++ b/scripts/installer/make_package.sh @@ -12,9 +12,14 @@ rm -Rf package mkdir package -git pull --all +# NOTE: Originally this pulled installer sources (separate from NUT code base) +# If this script were to be modernized, it could be prudent to `make package` +# in NUT sources for each platform, to create the package file(s) tarballed +# below for end-user along with the interactive installer delivery. +#git pull --all # [ $? = 0 ] && git merge upstream/master || exit $? +# NOTE: See README.adoc about expected subdirectory contents with binary files NAME="ipp-solaris-$IPP_VERSION.sparc" mkdir "package/$NAME" FILE_LIST="`find . -type f -name '*' | egrep -v '.svn|.git|./nutconf-dummy|./make_package.sh|nut/|(un|)install.log|package/|aix|hpux|solint'`" From 9ef87271781beed6626126ad3e81f13dac3e0362 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 21 Mar 2024 19:21:15 +0100 Subject: [PATCH 050/325] m4/nut_check_libmodbus.m4: make it visible when some libmodbus is found, but does not support libusb while we want it (and will fail NUT configure later) [#2063] Signed-off-by: Jim Klimov --- m4/nut_check_libmodbus.m4 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/m4/nut_check_libmodbus.m4 b/m4/nut_check_libmodbus.m4 index dbaae4968e..c596bb1edc 100644 --- a/m4/nut_check_libmodbus.m4 +++ b/m4/nut_check_libmodbus.m4 @@ -72,7 +72,12 @@ if test -z "${nut_have_libmodbus_seen}"; then AC_CHECK_FUNCS(modbus_set_byte_timeout, [], [nut_have_libmodbus=no]) AC_CHECK_FUNCS(modbus_set_response_timeout, [], [nut_have_libmodbus=no]) - AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [nut_have_libmodbus_usb=no]) + AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [ + AS_IF([test x"${nut_with_usb}" = xyes && test x"${nut_with_modbus}" = xyes && test x"${nut_have_libmodbus}" = xyes ], [ + AC_MSG_WARN([Both --with-modbus and --with-usb were requested, and a libmodbus was found, but it seems to not support USB. You may require a custom build per https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol]) + ]) + nut_have_libmodbus_usb=no + ]) dnl modbus_set_byte_timeout() and modbus_set_response_timeout() dnl in 3.0.x and 3.1.x have different args (since ~2013): the From 3e34c920b39f34ec3bed4b5782f3c610146abda2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 21 Mar 2024 19:40:26 +0100 Subject: [PATCH 051/325] docs/man/apc_modbus.txt, docs/nut.dict: update manpage with instructions for USB-capable builds [#2063] Signed-off-by: Jim Klimov --- docs/man/apc_modbus.txt | 40 ++++++++++++++++++++++++++++++++++++++++ docs/nut.dict | 4 +++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/man/apc_modbus.txt b/docs/man/apc_modbus.txt index 07cac400f6..4e5c98eb91 100644 --- a/docs/man/apc_modbus.txt +++ b/docs/man/apc_modbus.txt @@ -83,6 +83,46 @@ Set the Modbus slave id. The default slave id is 1. Set the Modbus response timeout. The default timeout is set by libmodbus. It can be good to set a higher timeout on TCP connections with high latency. +BUGS +---- + +This driver relies on advanced features of `libmodbus` to talk Modbus protocol +over USB specifically (Serial and TCP are part of common library codebase). +At the time of this writing, the common library project is just expecting a +merge of the pull request with this ability. + +For the time being, if your OS distribution does not ship the required feature +set, you may have to build your own `libmodbus` and subsequently (re-)build NUT +against this library, as detailed in the NUT GitHub Wiki at +https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol + +The short sequence may be like follows: +------ +cd ~/ +git clone -b rtu_usb https://github.com/networkupstools/libmodbus +cd libmodbus +./autogen.sh +./configure --with-libusb --prefix=/path/to/prefix +make install + +cd ~/ +git clone https://github.com/networkupstools/nut +cd nut +./autogen.sh +./configure --with-drivers=apc_modbus --with-usb --with-modbus \ + --with-modbus-includes=-I/path/to/prefix/include/modbus \ + --with-modbus-libs="-L/path/to/prefix/lib -lmodbus" +make +------ + +NOTE: Other `configure` options may be needed for proper behavior, such as +`--prefix`, `--with-sysconfdir`, `--with-user` and `--with-group` to match +your packaged or otherwise preceding NUT installation. + +The `./configure --enable-inplace-runtime` may be a good start to inherit +build configuration from an existing NUT deployment, as further detailed at +https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests + AUTHORS ------- diff --git a/docs/nut.dict b/docs/nut.dict index c79045136b..2e8118680d 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3478 utf-8 +personal_ws-1.1 en 3480 utf-8 AAC AAS ABI @@ -2431,6 +2431,7 @@ lk lldb llvm lm +lmodbus ln lnetsnmp loadPercentage @@ -2940,6 +2941,7 @@ rqt rsa rsync rts +rtu ru rubygem runlevel From 1a498d167183a1fdd5cb4aac22eafe334934103c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 13:24:53 +0100 Subject: [PATCH 052/325] tools/nut-scanner/scan_xml_http.c, tools/nut-scanner/scan_snmp.c: ignore potentially unreachable code in platforms-dependent range checks Same as 34056dd43261c92e9230e2d18ddf5e8f498d98e9 earlier. Signed-off-by: Jim Klimov --- tools/nut-scanner/scan_snmp.c | 17 +++++++++++++++++ tools/nut-scanner/scan_xml_http.c | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tools/nut-scanner/scan_snmp.c b/tools/nut-scanner/scan_snmp.c index 89597382e3..cfe6c53c90 100644 --- a/tools/nut-scanner/scan_snmp.c +++ b/tools/nut-scanner/scan_snmp.c @@ -1033,7 +1033,24 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip # ifdef HAVE_SEMAPHORE if (max_threads_scantype > 0) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* Different platforms, different sizes, none fits all... */ if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) { +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif upsdebugx(1, "WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()", __func__); diff --git a/tools/nut-scanner/scan_xml_http.c b/tools/nut-scanner/scan_xml_http.c index 490d2b9b21..0aa9ccc897 100644 --- a/tools/nut-scanner/scan_xml_http.c +++ b/tools/nut-scanner/scan_xml_http.c @@ -454,7 +454,24 @@ nutscan_device_t * nutscan_scan_xml_http_range(const char * start_ip, const char # ifdef HAVE_SEMAPHORE if (max_threads_scantype > 0) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* Different platforms, different sizes, none fits all... */ if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) { +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif upsdebugx(1, "WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()", __func__); From 61edcb40f13b28e15ddfbc6a7b9a00821badc825 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 13:35:13 +0100 Subject: [PATCH 053/325] Jenkinsfile-dynamatrix: enable "autotools driven build with default configuration ... with fatal warnings" for all branch types Earlier enabled for fightwarn and PRs against stable branches, but not for master-branch builds themselves. Signed-off-by: Jim Klimov --- Jenkinsfile-dynamatrix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile-dynamatrix b/Jenkinsfile-dynamatrix index 69bc55d321..923b5658ce 100644 --- a/Jenkinsfile-dynamatrix +++ b/Jenkinsfile-dynamatrix @@ -25,7 +25,8 @@ import org.nut.dynamatrix.*; def dynacfgPipeline = [:] // NOTE: These can be further disabled or active in different combo specs - // below based on branch names + // below based on branch names. Also note that the values are somewhat + // "inversed" -- e.g. that "disabledSomething = false" means "enable it". dynacfgPipeline.disableSlowBuildAutotools = false dynacfgPipeline.disableSlowBuildCIBuild = false dynacfgPipeline.disableSlowBuildCIBuildExperimental = false @@ -427,12 +428,12 @@ set | sort -n """ //'bodyParStages': {} ] // one slowBuild filter configuration, autotools-Wall - ,[name: 'Default autotools driven build with default configuration, bitness and warning levels on each NUT CI farm platform (but with fatal warnings as of gnu99/gnu++11)', + ,[name: 'Default autotools driven build with default configuration, bitness and warning levels on each NUT CI farm platform (but with fatal warnings as of gnu99/gnu++11, must pass where enabled)', disabled: dynacfgPipeline.disableSlowBuildAutotools, - branchRegexSource: ~/^(PR-.+|fightwarn.*)$/, - branchRegexTarget: dynacfgPipeline.branchStableRegex, + //branchRegexSource: ~/^(PR-.+|fightwarn.*)$/, + //branchRegexTarget: dynacfgPipeline.branchStableRegex, //branchRegexTarget: ~/fightwarn/, - appliesToChangedFilesRegex: dynacfgPipeline.appliesToChangedFilesRegex_C, + //appliesToChangedFilesRegex: dynacfgPipeline.appliesToChangedFilesRegex_C, 'getParStages': { def dynamatrix, Closure body -> return dynamatrix.generateBuild([ //commonLabelExpr: dynacfgBase.commonLabelExpr, From 14a3b40bf97916a29928567df1d3d5e0c593e826 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 16:02:19 +0100 Subject: [PATCH 054/325] docs/man/apc_modbus.txt: update comments for libmodbus+rtu_usb builds - with a static library suggestion [#2063] Signed-off-by: Jim Klimov --- docs/man/apc_modbus.txt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/man/apc_modbus.txt b/docs/man/apc_modbus.txt index 4e5c98eb91..4deb74b4e1 100644 --- a/docs/man/apc_modbus.txt +++ b/docs/man/apc_modbus.txt @@ -104,7 +104,24 @@ cd libmodbus ./autogen.sh ./configure --with-libusb --prefix=/path/to/prefix make install +------ + +[NOTE] +====== +* you may need to `make && sudo make install` if you want to place this library + files' variant into a system path (like `--prefix=/usr/local/ups` to match + NUT defaults -- this activity would need privilege elevation via `sudo`), + and not into your home directory or some `/tmp` location. +* conversely, you may want to + `./configure --with-libusb --enable-static --disable-shared --prefix=/path/to/prefix` + and only build and install a static `libmodbus.a` (can well be installed into + `/tmp` or similarly short-lived location), so that the customized Modbus+USB + logic gets built directly into `apc_modbus` binary program and there would be + no potential run-time conflict with a dynamic library file available elsewhere + in the system. +====== +------ cd ~/ git clone https://github.com/networkupstools/nut cd nut @@ -115,9 +132,12 @@ cd nut make ------ -NOTE: Other `configure` options may be needed for proper behavior, such as +[NOTE] +====== +* Other NUT `configure` options may be needed for proper behavior, such as `--prefix`, `--with-sysconfdir`, `--with-user` and `--with-group` to match your packaged or otherwise preceding NUT installation. +====== The `./configure --enable-inplace-runtime` may be a good start to inherit build configuration from an existing NUT deployment, as further detailed at From 6641b2a761bc8cfd7522ac30c3d08663aa464cd6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 16:36:14 +0100 Subject: [PATCH 055/325] docs/man/Makefile.am: typo fix in comments Signed-off-by: Jim Klimov --- docs/man/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am index 2f096b7889..dbd3aff360 100644 --- a/docs/man/Makefile.am +++ b/docs/man/Makefile.am @@ -950,7 +950,7 @@ CLEANFILES = *-spellchecked .prep-src-docs *-prepped SUFFIXES = .txt-prepped .txt .html .1 .3 .5 .8 -# For builds with allowed installation of prebuild man pages, check that +# For builds with allowed installation of prebuilt man pages, check that # they exist in sources (make would pull them automatically as a fallback # from failed lookup in build products). For builds that require rebuild # of man pages, abort with error if build product is missing. From 31e9979343d9435e581089de34661d87a19cf58a Mon Sep 17 00:00:00 2001 From: "James R. Parks" Date: Fri, 22 Mar 2024 22:51:54 -0700 Subject: [PATCH 056/325] feat: Add support for Liebert PSI5 Adding support for the Liebert PSI5 model of UPS. Signed-off-by: James R. Parks --- drivers/belkin-hid.c | 35 ++++++++++++++++++++++++++++++++++- drivers/usbhid-ups.c | 18 +++++++++++++++++- drivers/usbhid-ups.h | 1 + 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index f1d4083afa..ad32335b45 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -31,7 +31,7 @@ #include /* for fabs() */ -#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.19" +#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.20" /* Belkin */ #define BELKIN_VENDORID 0x050d @@ -90,6 +90,7 @@ static const char *liebert_replacebatt_fun(double value); static const char *liebert_shutdownimm_fun(double value); static const char *liebert_config_voltage_fun(double value); static const char *liebert_line_voltage_fun(double value); +static const char *liebert_psi5_line_voltage_fun(double value); static info_lkp_t liebert_online_info[] = { { 0, NULL, liebert_online_fun, NULL } @@ -123,6 +124,10 @@ static info_lkp_t liebert_line_voltage_info[] = { { 0, NULL, liebert_line_voltage_fun, NULL }, }; +static info_lkp_t liebert_psi5_line_voltage_info[] = { + { 0, NULL, liebert_psi5_line_voltage_fun, NULL }, +}; + static double liebert_config_voltage_mult = 1.0; static double liebert_line_voltage_mult = 1.0; static char liebert_conversion_buf[10]; @@ -199,6 +204,23 @@ static const char *liebert_line_voltage_fun(double value) return liebert_conversion_buf; } +static const char *liebert_psi5_line_voltage_fun(double value) +{ + if( value < 1 ) { + if( fabs(value - 1e-3) < 1e-3 ) { + liebert_line_voltage_mult = 1e5; + upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", + value, liebert_line_voltage_mult); + } else { + upslogx(LOG_NOTICE, "LineVoltage exponent looks wrong, but not correcting."); + } + } + + snprintf(liebert_conversion_buf, sizeof(liebert_conversion_buf), "%.1f", + value * liebert_line_voltage_mult); + return liebert_conversion_buf; +} + /* some conversion functions specific to Belkin */ /* returns statically allocated string - must not use it again before @@ -482,6 +504,17 @@ static hid_info_t belkin_hid2nut[] = { { "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%s", 0, liebert_line_voltage_info }, { "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, "%s", HU_FLAG_STATIC, liebert_config_voltage_info }, { "ups.load", 0, 0, "UPS.Output.PercentLoad", NULL, "%.0f", 0, NULL }, + /* Liebert PSI5 */ + { "input.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%s", 0, divide_by_100_conversion }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%s", 0, liebert_psi5_line_voltage_info }, + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%s", 0, divide_by_100_conversion }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%s", 0, liebert_psi5_line_voltage_info }, + { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.0f", 0, NULL }, + { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%s", 0, liebert_psi5_line_voltage_info }, + { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "battery.capacity", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, /* status */ { "BOOL", 0, 0, "UPS.PowerSummary.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_discharging_info }, /* might not need to be liebert_* version */ { "BOOL", 0, 0, "UPS.PowerSummary.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_charging_info }, diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index 4775d38fe8..97a66150eb 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -553,6 +553,22 @@ info_lkp_t divide_by_10_conversion[] = { { 0, NULL, divide_by_10_conversion_fun, NULL } }; +/* returns statically allocated string - must not use it again before + done with result! */ +static const char *divide_by_100_conversion_fun(double value) +{ + static char buf[20]; + + snprintf(buf, sizeof(buf), "%0.1f", value * 0.01); + + return buf; +} + +/* FIXME? Do we need an inverse "nuf()" here? */ +info_lkp_t divide_by_100_conversion[] = { + { 0, NULL, divide_by_100_conversion_fun, NULL } +}; + /* returns statically allocated string - must not use it again before done with result! */ static const char *kelvin_celsius_conversion_fun(double value) @@ -997,7 +1013,7 @@ void upsdrv_makevartable(void) addvar(VAR_VALUE, "onlinedischarge_log_throttle_hovercharge", "Set to throttle log messages about discharging while online (only if battery.charge is under this value)"); - + addvar(VAR_FLAG, "disable_fix_report_desc", "Set to disable fix-ups for broken USB encoding, etc. which we apply by default on certain vendors/products"); diff --git a/drivers/usbhid-ups.h b/drivers/usbhid-ups.h index 679ea7de7c..f6f67fea72 100644 --- a/drivers/usbhid-ups.h +++ b/drivers/usbhid-ups.h @@ -122,6 +122,7 @@ extern info_lkp_t date_conversion[]; extern info_lkp_t hex_conversion[]; extern info_lkp_t stringid_conversion[]; extern info_lkp_t divide_by_10_conversion[]; +extern info_lkp_t divide_by_100_conversion[]; extern info_lkp_t kelvin_celsius_conversion[]; /* ---------------------------------------------------------------------- */ From c3d7ee6e3c3e0084a7da920112f5f68106c0a389 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 23 Mar 2024 15:54:50 +0100 Subject: [PATCH 057/325] NEWS.adoc: Add Liebert PSI5 [#2369] Signed-off-by: Jim Klimov --- NEWS.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.adoc b/NEWS.adoc index bb940c62ef..64e3af295a 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -180,6 +180,9 @@ https://github.com/networkupstools/nut/milestone/10 useful as an UPS driver, not just a controller developer sandbox. [#2188] * `cps-hid` subdriver now supports devices branded as Cyber Energy and built by cooperation with Cyber Power Systems. [#2312] + * `belkin-hid` subdriver now supports Liebert PSI5 devices which have a + different numeric reading scale than earlier handled models. [issue #2271, + PR #2272, PR #2369] * The `onlinedischarge` configuration flag name was too ambiguous and got deprecated (will be supported but no longer promoted by documentation), introducing `onlinedischarge_onbattery` as the meaningful alias. [#2213] From accfd812df98719cf8c9485830e55f6224f9a1c8 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 16:33:39 +0100 Subject: [PATCH 058/325] Makefile.am: clarify default "all" target variants Signed-off-by: Jim Klimov --- Makefile.am | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0453994435..9484e120ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,11 +9,13 @@ @NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@ @NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@ -# First target defines default behavior: all +# First target often defines default behavior: all # We follow up with another pass to `make doc` because our wild recipes # sometimes preclude generating all of them on the first pass (FIXME!) -# missing e.g. PDF and HTML which then pop up in `make check` footprint. -all: all-recursive +# missing e.g. PDF and HTML which then pop up in `make check` footprint, +# or misses a .prep-src-docs stage needed to pattern-make man page files +# with some "make" implementations... +all all-am-local all-local: doc all-recursive +@$(MAKE) $(AM_MAKEFLAGS) doc # include directory for aclocal From c86cded4db4ca77564764086305c764bb1693843 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 16:34:12 +0100 Subject: [PATCH 059/325] Makefile.am: fix typo for "docs/man" prep for spellcheck target Signed-off-by: Jim Klimov --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 9484e120ce..b99db53a16 100644 --- a/Makefile.am +++ b/Makefile.am @@ -150,7 +150,7 @@ distclean-local: spellcheck spellcheck-interactive: +@RES=0; \ (cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs) || RES=$$? ; \ - (cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs) || RES=$$? ; \ + (cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/man/.prep-src-docs) || RES=$$? ; \ (cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $@) || RES=$$? ; \ (cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $@) || RES=$$? ; \ (cd $(builddir)/conf && $(MAKE) $(AM_MAKEFLAGS) -s $@) || RES=$$? ; \ From c64adb30533e14a52cda8b5c26bcaabbc815d8ff Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 16:34:46 +0100 Subject: [PATCH 060/325] Makefile.am: be sure to prep before the many docs-related targets Signed-off-by: Jim Klimov --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index b99db53a16..9e66b28179 100644 --- a/Makefile.am +++ b/Makefile.am @@ -177,6 +177,8 @@ spellcheck spellcheck-interactive: doc spellcheck-sortdict \ all-docs check-docs \ man all-man man-man check-man man-html all-html: + +cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs + +cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/man/.prep-src-docs +cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) $@ INSTALL.nut UPGRADING NEWS README: From 7de34edc4037d758d9c6937e68030914839517a4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 16:35:24 +0100 Subject: [PATCH 061/325] docs/Makefile.am, docs/man/Makefile.am: clarify default "all" target variants as requiring a prep Signed-off-by: Jim Klimov --- docs/Makefile.am | 1 + docs/man/Makefile.am | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/Makefile.am b/docs/Makefile.am index a49ec8ff57..3442b58833 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -131,6 +131,7 @@ endif WITH_SPELLCHECK check-local: $(CHECK_LOCAL_TARGETS) # Make sure sources are there for out-of-tree builds: +all-local all-am-local \ @DOC_BUILD_LIST@ $(ASCIIDOC_PDF) $(ASCIIDOC_HTML_SINGLE) $(ASCIIDOC_HTML_CHUNKED): $(abs_top_builddir)/docs/.prep-src-docs # This list is defined by configure script choices and options: diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am index dbd3aff360..49db9b036e 100644 --- a/docs/man/Makefile.am +++ b/docs/man/Makefile.am @@ -22,6 +22,8 @@ EGREP = grep -E all: +all-am-local all-local: $(abs_top_builddir)/docs/man/.prep-src-docs + # Base configuration and client manpages, always installed SRC_CONF_PAGES = \ nut.conf.txt \ From 535e0f671269d9e970f53456856911284ba14f78 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 22 Mar 2024 21:01:20 +0100 Subject: [PATCH 062/325] Makefile.am, docs/Makefile.am: use abs_top_builddir for wrapper rules Signed-off-by: Jim Klimov --- Makefile.am | 8 ++++---- docs/Makefile.am | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9e66b28179..08de3eb46a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -177,12 +177,12 @@ spellcheck spellcheck-interactive: doc spellcheck-sortdict \ all-docs check-docs \ man all-man man-man check-man man-html all-html: - +cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs - +cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/man/.prep-src-docs - +cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) $@ + +cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs + +cd $(abs_top_builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/man/.prep-src-docs + +cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) $@ INSTALL.nut UPGRADING NEWS README: - +cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) ../$(@F).adoc-parsed && cp -f ../$(@F).adoc-parsed ../$(@F) + +cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) ../$(@F).adoc-parsed && cp -f ../$(@F).adoc-parsed ../$(@F) # Workarounds for https://github.com/github/markup/issues/1095 # require direct definition of our attributes in each source diff --git a/docs/Makefile.am b/docs/Makefile.am index 3442b58833..36f1dbb34d 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -186,10 +186,10 @@ check-html-chunked: $(ASCIIDOC_HTML_CHUNKED) # chosen during configure script execution. The "all-man" and "all-html" # rules build everything documented. check-man all-man man-man all-html html-man: - +cd $(top_builddir)/docs/man/ && $(MAKE) $(AM_MAKEFLAGS) -f Makefile $@ + +cd $(abs_top_builddir)/docs/man/ && $(MAKE) $(AM_MAKEFLAGS) -f Makefile $@ man: - +cd $(top_builddir)/docs/man/ && $(MAKE) $(AM_MAKEFLAGS) -f Makefile all + +cd $(abs_top_builddir)/docs/man/ && $(MAKE) $(AM_MAKEFLAGS) -f Makefile all CLEANFILES = *.xml *.html *.pdf *-spellchecked docbook-xsl.css docinfo.xml.in.tmp CLEANFILES += $(top_builddir)/INSTALL.nut $(top_builddir)/UPGRADING $(top_builddir)/NEWS $(top_builddir)/ChangeLog.adoc $(top_builddir)/README From 0b38251f50ae9e3511e4be274fdb49830985b039 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 23 Mar 2024 18:15:31 +0100 Subject: [PATCH 063/325] tools/gitlog2changelog.py.in: trace absence of "unicode" type in some python bundles Signed-off-by: Jim Klimov --- tools/gitlog2changelog.py.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/gitlog2changelog.py.in b/tools/gitlog2changelog.py.in index 7518f6a5a8..2f4468dbf4 100755 --- a/tools/gitlog2changelog.py.in +++ b/tools/gitlog2changelog.py.in @@ -12,8 +12,15 @@ import subprocess # Python 3 compatibility hack try: + try: + import unicode + except: + # Maybe built-in? + pass unicode('') -except NameError: +except NameError as ex: + #DEBUG# sys.stderr.write("Using 'str' as 'unicode': %s\n" % str(ex)) + #DEBUG# sys.stderr.flush() unicode = str try: From 7dc1020c5321b15b4f62f094f5ab3a5d6f1c638d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 23 Mar 2024 18:16:39 +0100 Subject: [PATCH 064/325] tools/gitlog2changelog.py.in: when authorMustBeASCII, only parse str via unicode() if we did not shortcut it earlier, and fix a typo in encoding value Signed-off-by: Jim Klimov --- tools/gitlog2changelog.py.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gitlog2changelog.py.in b/tools/gitlog2changelog.py.in index 2f4468dbf4..889bf3793e 100755 --- a/tools/gitlog2changelog.py.in +++ b/tools/gitlog2changelog.py.in @@ -132,8 +132,8 @@ for line in fin: author = author[0 : len(author) - fin_chop] if authorMustBeASCII: try: - if isinstance(author, str): - author = unicodedata.normalize(u'NFKD', unicode(author, "UTF=8")).encode('ascii', 'ignore').decode('utf8') + if isinstance(author, str) and unicode != str: + author = unicodedata.normalize(u'NFKD', unicode(author, "utf-8")).encode('ascii', 'ignore').decode('utf8') else: author = unicodedata.normalize(u'NFKD', author).encode('ascii', 'ignore').decode('utf8') except Exception as e: From 69e7faef5efb9b6ed925ad5e0516ac17a3d58fa0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 23 Mar 2024 18:29:12 +0100 Subject: [PATCH 065/325] UPGRADING.adoc, NEWS.adoc: mention changes in tools/gitlog2changelog.py.in [#2360, #2366] Signed-off-by: Jim Klimov --- NEWS.adoc | 6 ++++++ UPGRADING.adoc | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/NEWS.adoc b/NEWS.adoc index bb940c62ef..c96914f6b0 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -221,6 +221,12 @@ https://github.com/networkupstools/nut/milestone/10 known deficiencies in Windows platform support, as well as some un-awareness about configuration key words which appeared in NUT since 2013. [#2290] + - The `tools/gitlog2changelog.py.in` script was revised, in particular to + convert section titles (with contributor names coming from Git metadata) + into plain ASCII character set, for `dblatex` versions which do not allow + diacritics and other kinds of non-trivial characters in sections. This can + cause successful builds of `ChangeLog.pdf` file on more platforms, but at + expense of a semi-cosmetic difference in those names. [PR #2360, PR #2366] Release notes for NUT 2.8.1 - what's new since 2.8.0 ---------------------------------------------------- diff --git a/UPGRADING.adoc b/UPGRADING.adoc index cb89c907dd..fbbac8b3df 100644 --- a/UPGRADING.adoc +++ b/UPGRADING.adoc @@ -44,6 +44,13 @@ Changes from 2.8.1 to 2.8.2 appear as comments, or enabled by specifying the `-U` command-line option several times. [#2221] +- The `tools/gitlog2changelog.py.in` script was revised, in particular to + convert section titles (with contributor names) into plain ASCII character + set, for `dblatex` versions which do not allow diacritics and other kinds + of non-trivial characters in sections. A number of other projects seem to + use the NUT version of the script, and are encouraged to look at related + changes in `configure.ac` and `Makefile.am` recipes. [PR #2360, PR #2366] + Changes from 2.8.0 to 2.8.1 --------------------------- From a75a1d5f9e508e43f2941e62498c8e7c1a104537 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 24 Mar 2024 14:37:22 +0100 Subject: [PATCH 066/325] drivers/riello_usb.c: comment the meaning of logical blocks changed by PR #1692 Signed-off-by: Jim Klimov --- drivers/riello_usb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 58b995724e..3551c916fc 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -1107,6 +1107,9 @@ void upsdrv_updateinfo(void) dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); if (localcalculation) { + /* NOTE: at this time "localcalculation" is a configuration toggle. + * Maybe later it can be replaced by a common "runtimecal" setting. */ + /* Considered "Ubat" physical range here is 10.7V to 12.9V: */ battcharge = ((DevData.Ubat <= 129) && (DevData.Ubat >=107)) ? (((DevData.Ubat-107)*100)/22) : ((DevData.Ubat < 107) ? 0 : 100); battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; @@ -1123,12 +1126,18 @@ void upsdrv_updateinfo(void) localcalculation_logged = 1; } if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + /* Use values reported by the driver unless they are marked + * invalid/unknown by HW/FW (all bits in the word are set). + */ dstate_setinfo("battery.charge", "%u", DevData.BatCap); dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); } } if (DevData.Tsystem == 255) { + /* Use values reported by the driver unless they are marked + * invalid/unknown by HW/FW (all bits in the word are set). + */ /*dstate_setinfo("ups.temperature", "%u", 0);*/ upsdebugx(4, "Reported temperature value is 0xFF, " "probably meaning \"-1\" for error or " From 0d84d795c0d5cc55bf5ba0e463e5a7bfbba6578f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 24 Mar 2024 14:49:15 +0100 Subject: [PATCH 067/325] drivers/riello_usb.c: bump (C) and DRIVER_VERSION for "localcalculation" related support [#1692] Signed-off-by: Jim Klimov --- drivers/riello_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 3551c916fc..cb81a6477e 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -8,6 +8,8 @@ * * Copyright (C) 2012 - Elio Parisi * Copyright (C) 2016 Eaton + * Copyright (C) 2022-2024 "amikot" + * Copyright (C) 2022-2024 Jim Klimov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,7 +36,7 @@ #include "riello.h" #define DRIVER_NAME "Riello USB driver" -#define DRIVER_VERSION "0.11" +#define DRIVER_VERSION "0.12" #define DEFAULT_OFFDELAY 5 /*!< seconds (max 0xFF) */ #define DEFAULT_BOOTDELAY 5 /*!< seconds (max 0xFF) */ From 648010c213c689a06acdd3af83e5ea54766f21c2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 24 Mar 2024 15:13:34 +0100 Subject: [PATCH 068/325] drivers/riello_usb.c, docs/man/riello_usb.txt: allow configurable battery.voltage.low/.high for localcalculation guesstimates [#1692] Signed-off-by: Jim Klimov --- docs/man/riello_usb.txt | 21 +++++++++++++-------- drivers/riello_usb.c | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index 71bfb95ed3..5bd2f30309 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -32,17 +32,22 @@ include::nut_usb_addvars.txt[] EXTRA ARGUMENTS --------------- -You may need to tweak some settings, depending on the make and model of your UPS -(see linkman:ups.conf[5]): +You may need to tweak some settings, depending on the make and model of your +UPS (see linkman:ups.conf[5]): *localcalculation*:: -When enabled, driver will calculate values of `battery.runtime` and `battery.charge` -locally. This is for some Riello models (iPlug and iDialog series) that provide -incorrect values. Local calculation is done according to nominal battery capacity, -nominal battery voltage, actual battery charge, maximum and actual UPS load. +When enabled, driver will calculate values of `battery.runtime` and +`battery.charge` "locally" in the driver. This is for some Riello models +(iPlug and iDialog series) which provide incorrect values in hardware readings. +This "local calculation" is done according to nominal battery capacity, nominal +battery voltage, actual battery charge, maximum and actual UPS load. + -Lead battery charge graph is not linear, so guesstimated charge value may not be -perfectly accurate. However it should be good enough to determine battery +You may want to also configure 'default.battery.voltage.low' and +'default.battery.voltage.high' in case the built-in default range +(from 10.7V to 12.9V) does not match your hardware. ++ +NOTE: Lead (PbAc) battery charge graph is not linear, so guesstimated charge value may +not be perfectly accurate. However it should be good enough to determine battery actual status and roughly estimate the time it can power the system. + WARNING: This keyword may be deprecated in future releases of the driver, in favor of diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index cb81a6477e..528d251158 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -73,6 +73,8 @@ static USBDeviceMatcher_t *regex_matcher = NULL; /* Flag for estimation of battery.runtime and battery.charge */ static int localcalculation = 0; static int localcalculation_logged = 0; +static double batt_volt_low = 10.7; +static double batt_volt_high = 12.9; static int (*subdriver_command)(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) = NULL; @@ -961,7 +963,9 @@ void upsdrv_initinfo(void) if (testvar("localcalculation")) { localcalculation = 1; upsdebugx(1, "Will guesstimate battery charge and runtime " - "instead of trusting device readings (if any)"); + "instead of trusting device readings (if any); " + "consider also setting default.battery.voltage.low " + "and default.battery.voltage.high for this device"); } dstate_setinfo("driver.parameter.localcalculation", "%d", localcalculation); @@ -1074,6 +1078,7 @@ void upsdrv_updateinfo(void) int battcharge; float battruntime; float upsloadfactor; + const char *val = NULL; upsdebugx(1, "countlost %d",countlost); @@ -1108,11 +1113,39 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0); dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); + + /* Can be set via default.* or override.* driver options + * if not served by the device HW/FW */ + val = dstate_getinfo("battery.voltage.low"); + if (val) { + batt_volt_low = strtod(val, NULL); + } + + val = dstate_getinfo("battery.voltage.high"); + if (val) { + batt_volt_high = strtod(val, NULL); + } + if (localcalculation) { /* NOTE: at this time "localcalculation" is a configuration toggle. - * Maybe later it can be replaced by a common "runtimecal" setting. */ - /* Considered "Ubat" physical range here is 10.7V to 12.9V: */ - battcharge = ((DevData.Ubat <= 129) && (DevData.Ubat >=107)) ? (((DevData.Ubat-107)*100)/22) : ((DevData.Ubat < 107) ? 0 : 100); + * Maybe later it can be replaced by a common "runtimecal" setting. */ + /* Considered "Ubat" physical range here is e.g. 10.7V to 12.9V + * seen as "107" or "129" integers in the DevData properties: */ + uint16_t Ubat_low = batt_volt_low * 10; /* e.g. 107 */ + uint16_t Ubat_high = batt_volt_high * 10; /* e.g. 129 */ + static int batt_volt_logged = 0; + + if (!batt_volt_logged) { + upsdebugx(0, "\nUsing battery.voltage.low=%.1f and " + "battery.voltage.high=%.1f for \"localcalculation\" " + "guesstimates of battery.charge and battery.runtime", + batt_volt_low, batt_volt_high); + batt_volt_logged = 1; + } + + battcharge = ((DevData.Ubat <= Ubat_high) && (DevData.Ubat >= Ubat_low)) + ? (((DevData.Ubat - Ubat_low)*100) / (Ubat_high - Ubat_low)) + : ((DevData.Ubat < Ubat_low) ? 0 : 100); battruntime = (DevData.NomBatCap * DevData.NomUbat * 3600.0/DevData.NomPowerKW) * (battcharge/100.0); upsloadfactor = (DevData.Pout1 > 0) ? (DevData.Pout1/100.0) : 1; From 68e4c83240601bc517e8b25b570abcf6a1bda861 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 24 Mar 2024 16:08:20 +0100 Subject: [PATCH 069/325] drivers/riello_usb.c, docs/man/riello_usb.txt: pick battery low/high range via known or configured battery.voltage.nominal [#1692] Signed-off-by: Jim Klimov --- docs/man/riello_usb.txt | 4 +- drivers/riello_usb.c | 84 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index 5bd2f30309..8e6e282c24 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -44,7 +44,9 @@ battery voltage, actual battery charge, maximum and actual UPS load. + You may want to also configure 'default.battery.voltage.low' and 'default.battery.voltage.high' in case the built-in default range -(from 10.7V to 12.9V) does not match your hardware. +(from 10.7V to 12.9V) does not match your hardware, or give a shot +to 'default.battery.voltage.nominal' (e.g. '24') if your device does +not serve that either. + NOTE: Lead (PbAc) battery charge graph is not linear, so guesstimated charge value may not be perfectly accurate. However it should be good enough to determine battery diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 528d251158..a30075ec25 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -73,6 +73,9 @@ static USBDeviceMatcher_t *regex_matcher = NULL; /* Flag for estimation of battery.runtime and battery.charge */ static int localcalculation = 0; static int localcalculation_logged = 0; +/* NOTE: Do not change these default, they refer to battery.voltage.nominal=12.0 + * and used in related maths later */ +static double batt_volt_nom = 12.0; static double batt_volt_low = 10.7; static double batt_volt_high = 12.9; @@ -950,6 +953,7 @@ void upsdrv_initups(void) void upsdrv_initinfo(void) { int ret; + const char *valN = NULL, *valL = NULL, *valH = NULL; ret = start_ups_comm(); @@ -997,15 +1001,87 @@ void upsdrv_initinfo(void) dstate_setinfo("ups.serial", "%s", (unsigned char*) DevData.Identification); dstate_setinfo("ups.firmware", "%s", (unsigned char*) DevData.Version); + /* Is it set by user default/override configuration? + * NOTE: "valN" is also used for a check just below. + */ + valN = dstate_getinfo("battery.voltage.nominal"); + if (valN) { + batt_volt_nom = strtod(valN, NULL); + upsdebugx(1, "Using battery.voltage.nominal=%.1f " + "likely coming from user configuration", + batt_volt_nom); + } + if (get_ups_nominal() == 0) { dstate_setinfo("ups.realpower.nominal", "%u", DevData.NomPowerKW); dstate_setinfo("ups.power.nominal", "%u", DevData.NomPowerKVA); dstate_setinfo("output.voltage.nominal", "%u", DevData.NominalUout); dstate_setinfo("output.frequency.nominal", "%.1f", DevData.NomFout/10.0); - dstate_setinfo("battery.voltage.nominal", "%u", DevData.NomUbat); + + /* Is it set by user default/override configuration (see just above)? */ + if (valN) { + upsdebugx(1, "...instead of battery.voltage.nominal=%u " + "reported by the device", DevData.NomUbat); + } else { + dstate_setinfo("battery.voltage.nominal", "%u", DevData.NomUbat); + batt_volt_nom = (double)DevData.NomUbat; + } + dstate_setinfo("battery.capacity", "%u", DevData.NomBatCap); + } else { + /* TOTHINK: Check the momentary reading of battery.voltage + * or would it be too confusing (especially if it is above + * 12V and might correspond to a discharged UPS when the + * driver starts up after an outage?) + * NOTE: DevData.Ubat would be scaled by 10! + */ + if (!valN) { + /* The nominal was not already set by user configuration... */ + upsdebugx(1, "Using built-in default battery.voltage.nominal=%.1f", + batt_volt_nom); + dstate_setinfo("battery.voltage.nominal", "%.1f", batt_volt_nom); + } } + /* We have a nominal voltage by now - either from user configuration + * or from the device itself (or initial defaults for 12V). Do we have + * any low/high range from HW/FW or defaults from ups.conf? */ + valL = dstate_getinfo("battery.voltage.low"); + valH = dstate_getinfo("battery.voltage.high"); + + if (!valL && !valH) { + /* Both not set (NULL) => pick by nominal (X times 12V). + * Pick a suitable low/high range (or keep built-in default). + */ + int times12 = batt_volt_nom / 12; + if (times12 > 1) { + /* Scale up the range for 24V (X=2) etc. */ + upsdebugx(1, "Using %i times the voltage range of 12V PbAc battery", times12); + batt_volt_low *= times12; + batt_volt_high *= times12; + } + } else { + /* If just one of those is set, then what? */ + if (valL || valH) { + upsdebugx(1, "WARNING: Only one of battery.voltage.low=%.1f " + "or battery.voltage.high=%.1f is set via " + "driver configuration; keeping the other " + "at built-in default value (and not aligning " + "with battery.voltage.nominal=%.1f)", + batt_volt_low, batt_volt_high, batt_volt_nom); + } else { + upsdebugx(1, "Both of battery.voltage.low=%.1f " + "or battery.voltage.high=%.1f are set via " + "driver configuration; not aligning " + "with battery.voltage.nominal=%.1f", + batt_volt_low, batt_volt_high, batt_volt_nom); + } + } + + /* Whatever the origin, make the values known via dstate */ + dstate_setinfo("battery.voltage.low", "%.1f", batt_volt_low); + dstate_setinfo("battery.voltage.high", "%.1f", batt_volt_high); + /* commands ----------------------------------------------- */ dstate_addcmd("load.off"); dstate_addcmd("load.on"); @@ -1078,7 +1154,9 @@ void upsdrv_updateinfo(void) int battcharge; float battruntime; float upsloadfactor; +#ifdef RIELLO_DYNAMIC_BATTVOLT_INFO const char *val = NULL; +#endif upsdebugx(1, "countlost %d",countlost); @@ -1114,6 +1192,7 @@ void upsdrv_updateinfo(void) dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); +#ifdef RIELLO_DYNAMIC_BATTVOLT_INFO /* Can be set via default.* or override.* driver options * if not served by the device HW/FW */ val = dstate_getinfo("battery.voltage.low"); @@ -1125,11 +1204,12 @@ void upsdrv_updateinfo(void) if (val) { batt_volt_high = strtod(val, NULL); } +#endif if (localcalculation) { /* NOTE: at this time "localcalculation" is a configuration toggle. * Maybe later it can be replaced by a common "runtimecal" setting. */ - /* Considered "Ubat" physical range here is e.g. 10.7V to 12.9V + /* Considered "Ubat" physical range here (e.g. 10.7V to 12.9V) is * seen as "107" or "129" integers in the DevData properties: */ uint16_t Ubat_low = batt_volt_low * 10; /* e.g. 107 */ uint16_t Ubat_high = batt_volt_high * 10; /* e.g. 129 */ From 9bb7a0c6cb0309768ad1a965b261bcbf88aeb3f6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 24 Mar 2024 16:12:48 +0100 Subject: [PATCH 070/325] drivers/riello_usb.c: extend built-in default battery low/high range to match nutdrv_qx data for PbAc batteries [#1692] Signed-off-by: Jim Klimov --- drivers/riello_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index a30075ec25..4d321d0d28 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -76,8 +76,8 @@ static int localcalculation_logged = 0; /* NOTE: Do not change these default, they refer to battery.voltage.nominal=12.0 * and used in related maths later */ static double batt_volt_nom = 12.0; -static double batt_volt_low = 10.7; -static double batt_volt_high = 12.9; +static double batt_volt_low = 10.4; +static double batt_volt_high = 13.0; static int (*subdriver_command)(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) = NULL; From d6f69345bf8832a5b255c0f1abf5d5beb818a30f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 14:00:04 +0100 Subject: [PATCH 071/325] drivers/belkin-hid.c: update (C) heading [#2369 follow-up] Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index ad32335b45..5da14d896d 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -3,7 +3,8 @@ * Copyright (C) * 2003 - 2008 Arnaud Quette * 2005 Peter Selinger - * 2011, 2014 Charles Lepple + * 2011, 2014 Charles Lepple + * 2024 James R. Parks * * Sponsored by MGE UPS SYSTEMS * From a2d112d46e3cfea82288aa2acbab72c715d97f27 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 14:04:25 +0100 Subject: [PATCH 072/325] drivers/belkin-hid.c: whitespace fix Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index 5da14d896d..7c45bab95f 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -98,23 +98,23 @@ static info_lkp_t liebert_online_info[] = { }; static info_lkp_t liebert_discharging_info[] = { - { 0, NULL, liebert_discharging_fun, NULL } + { 0, NULL, liebert_discharging_fun, NULL } }; static info_lkp_t liebert_charging_info[] = { - { 0, NULL, liebert_charging_fun, NULL } + { 0, NULL, liebert_charging_fun, NULL } }; static info_lkp_t liebert_lowbatt_info[] = { - { 0, NULL, liebert_lowbatt_fun, NULL } + { 0, NULL, liebert_lowbatt_fun, NULL } }; static info_lkp_t liebert_replacebatt_info[] = { - { 0, NULL, liebert_replacebatt_fun, NULL } + { 0, NULL, liebert_replacebatt_fun, NULL } }; static info_lkp_t liebert_shutdownimm_info[] = { - { 0, NULL, liebert_shutdownimm_fun, NULL } + { 0, NULL, liebert_shutdownimm_fun, NULL } }; static info_lkp_t liebert_config_voltage_info[] = { From c0d0bdf0ca40067a796ac30f47f5a4770fce9c82 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 11:56:00 +0100 Subject: [PATCH 073/325] Add unit tests for belkin-hid liebert_line_voltage_fun() and related methods [#2370] Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 32 ++++--- tests/.gitignore | 4 + tests/Makefile.am | 22 ++++- tests/driver-stub-usb.c | 67 +++++++++++++ tests/getexponenttest.c | 207 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 315 insertions(+), 17 deletions(-) create mode 100644 tests/driver-stub-usb.c create mode 100644 tests/getexponenttest.c diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index 7c45bab95f..857cf58c1f 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -5,6 +5,7 @@ * 2005 Peter Selinger * 2011, 2014 Charles Lepple * 2024 James R. Parks + * 2024 Jim Klimov * * Sponsored by MGE UPS SYSTEMS * @@ -32,7 +33,7 @@ #include /* for fabs() */ -#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.20" +#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.21" /* Belkin */ #define BELKIN_VENDORID 0x050d @@ -89,9 +90,19 @@ static const char *liebert_charging_fun(double value); static const char *liebert_lowbatt_fun(double value); static const char *liebert_replacebatt_fun(double value); static const char *liebert_shutdownimm_fun(double value); -static const char *liebert_config_voltage_fun(double value); -static const char *liebert_line_voltage_fun(double value); -static const char *liebert_psi5_line_voltage_fun(double value); + +/* These lookup functions also cover the 1e-7 factor which seems to + * be due to a broken report descriptor in certain Liebert units. + * Exposed for unit testing - not "static" */ +const char *liebert_config_voltage_fun(double value); +const char *liebert_line_voltage_fun(double value); +const char *liebert_psi5_line_voltage_fun(double value); + +extern double liebert_config_voltage_mult, liebert_line_voltage_mult; +double liebert_config_voltage_mult = 1.0; +double liebert_line_voltage_mult = 1.0; +static char liebert_conversion_buf[10]; + static info_lkp_t liebert_online_info[] = { { 0, NULL, liebert_online_fun, NULL } @@ -129,13 +140,6 @@ static info_lkp_t liebert_psi5_line_voltage_info[] = { { 0, NULL, liebert_psi5_line_voltage_fun, NULL }, }; -static double liebert_config_voltage_mult = 1.0; -static double liebert_line_voltage_mult = 1.0; -static char liebert_conversion_buf[10]; - -/* These lookup functions also cover the 1e-7 factor which seems to be due to a - * broken report descriptor in certain Liebert units. - */ static const char *liebert_online_fun(double value) { return value ? "online" : "!online"; @@ -170,7 +174,7 @@ static const char *liebert_shutdownimm_fun(double value) * Logic is weird since the ConfigVoltage item comes after InputVoltage and * OutputVoltage. */ -static const char *liebert_config_voltage_fun(double value) +const char *liebert_config_voltage_fun(double value) { if( value < 1 ) { if( fabs(value - 1e-7) < 1e-9 ) { @@ -188,7 +192,7 @@ static const char *liebert_config_voltage_fun(double value) return liebert_conversion_buf; } -static const char *liebert_line_voltage_fun(double value) +const char *liebert_line_voltage_fun(double value) { if( value < 1 ) { if( fabs(value - 1e-7) < 1e-9 ) { @@ -205,7 +209,7 @@ static const char *liebert_line_voltage_fun(double value) return liebert_conversion_buf; } -static const char *liebert_psi5_line_voltage_fun(double value) +const char *liebert_psi5_line_voltage_fun(double value) { if( value < 1 ) { if( fabs(value - 1e-3) < 1e-3 ) { diff --git a/tests/.gitignore b/tests/.gitignore index 876e375e29..1036cac317 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -16,6 +16,10 @@ /nuttimetest /nuttimetest.log /nuttimetest.trs +/getexponenttest +/getexponenttest.log +/getexponenttest.trs +/belkin-hid.c /getvaluetest /getvaluetest.log /getvaluetest.trs diff --git a/tests/Makefile.am b/tests/Makefile.am index f328d3029c..94588ce202 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -16,6 +16,7 @@ all: $(TESTS) EXTRA_DIST = nut-driver-enumerator-test.sh nut-driver-enumerator-test--ups.conf TESTS = +noinst_LTLIBRARIES = CLEANFILES = *.trs *.log AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/drivers @@ -57,15 +58,29 @@ nuttimetest_SOURCES = nuttimetest.c nuttimetest_LDADD = $(top_builddir)/common/libcommon.la # Separate the .deps of other dirs from this one -LINKED_SOURCE_FILES = hidparser.c +LINKED_SOURCE_FILES = hidparser.c belkin-hid.c # NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver # of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS hidparser.c: $(top_srcdir)/drivers/hidparser.c test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@" +belkin-hid.c: $(top_srcdir)/drivers/belkin-hid.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/belkin-hid.c" "$@" + if WITH_USB -TESTS += getvaluetest +TESTS += getvaluetest getexponenttest + +# We only need to call a few methods, not use the whole source - so +# not linking it as a getvaluetest_SOURCE file (has too many deps): +noinst_LTLIBRARIES += libbelkin.la +nodist_libbelkin_la_SOURCES = belkin-hid.c driver-stub-usb.c +libbelkin_la_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +libbelkin_la_LIBADD = $(top_builddir)/common/libcommon.la + +getexponenttest_SOURCES = getexponenttest.c +#getexponenttest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +getexponenttest_LDADD = $(top_builddir)/common/libcommon.la libbelkin.la getvaluetest_SOURCES = getvaluetest.c nodist_getvaluetest_SOURCES = hidparser.c @@ -73,7 +88,7 @@ nodist_getvaluetest_SOURCES = hidparser.c getvaluetest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) getvaluetest_LDADD = $(top_builddir)/common/libcommon.la else !WITH_USB -EXTRA_DIST += getvaluetest.c hidparser.c +EXTRA_DIST += getvaluetest.c hidparser.c belkin-hid.c endif !WITH_USB if WITH_GPIO @@ -101,6 +116,7 @@ EXTRA_DIST += generic_gpio_utest.h generic_gpio_test.txt # Make sure out-of-dir dependencies exist (especially when dev-building parts): $(top_builddir)/drivers/libdummy_mockdrv.la \ $(top_builddir)/common/libnutconf.la \ +$(top_builddir)/common/libcommonclient.la \ $(top_builddir)/common/libcommon.la: dummy +@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) diff --git a/tests/driver-stub-usb.c b/tests/driver-stub-usb.c new file mode 100644 index 0000000000..e483eea41d --- /dev/null +++ b/tests/driver-stub-usb.c @@ -0,0 +1,67 @@ +/* placeholder method implementations to just link the libbelkin stub + * and eventually similar code by directly using driver source code + * for almost-in-vivo testing (and minimal intrusion to that codebase). + * See also: getexponenttest.c + * + * Copyright (C) + * 2024 Jim Klimov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "common.h" + +#include "usb-common.h" +int is_usb_device_supported(usb_device_id_t *usb_device_id_list, USBDevice_t *device) { + NUT_UNUSED_VARIABLE(usb_device_id_list); + NUT_UNUSED_VARIABLE(device); + return -1; +} + +#include "usbhid-ups.h" +hid_dev_handle_t udev = HID_DEV_HANDLE_CLOSED; +info_lkp_t beeper_info[] = { { 0, NULL, NULL, NULL } }; +info_lkp_t date_conversion[] = { { 0, NULL, NULL, NULL } }; +info_lkp_t stringid_conversion[] = { { 0, NULL, NULL, NULL } }; +info_lkp_t divide_by_10_conversion[] = { { 0, NULL, NULL, NULL } }; +info_lkp_t divide_by_100_conversion[] = { { 0, NULL, NULL, NULL } }; + +void possibly_supported(const char *mfr, HIDDevice_t *hd) { + NUT_UNUSED_VARIABLE(mfr); + NUT_UNUSED_VARIABLE(hd); +} + +int fix_report_desc(HIDDevice_t *arg_pDev, HIDDesc_t *arg_pDesc) { + NUT_UNUSED_VARIABLE(arg_pDev); + NUT_UNUSED_VARIABLE(arg_pDesc); + return -1; +} + +#include "libhid.h" +usage_lkp_t hid_usage_lkp[] = { {NULL, 0} }; +char *HIDGetItemString(hid_dev_handle_t arg_udev, const char *hidpath, char *buf, size_t buflen, usage_tables_t *utab) { + NUT_UNUSED_VARIABLE(arg_udev); + NUT_UNUSED_VARIABLE(hidpath); + NUT_UNUSED_VARIABLE(buf); + NUT_UNUSED_VARIABLE(buflen); + NUT_UNUSED_VARIABLE(utab); + return NULL; +} + +#include "main.h" +char *getval(const char *var) { + NUT_UNUSED_VARIABLE(var); + return NULL; +} diff --git a/tests/getexponenttest.c b/tests/getexponenttest.c new file mode 100644 index 0000000000..94d082ac31 --- /dev/null +++ b/tests/getexponenttest.c @@ -0,0 +1,207 @@ +/* getexponenttest - check detection of correct multiplication exponent value + * for miniscule readings from USB HID (as used in e.g. drivers/belkin-hid.c + * subdriver). Eventually may be extended to similar tests for other driver + * methods. + * + * See also: + * https://github.com/networkupstools/nut/issues/2370 + * + * Copyright (C) + * 2024 Jim Klimov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include "nut_stdint.h" +#include +#include +#include +#include "common.h" + +/* from drivers/belkin-hid.c: */ +extern double liebert_config_voltage_mult, liebert_line_voltage_mult; +const char *liebert_config_voltage_fun(double value); +const char *liebert_line_voltage_fun(double value); +const char *liebert_psi5_line_voltage_fun(double value); + +static void Usage(char *name) { +/* + printf("%s {-c | -l | -p } \n", name); + printf("\n"); + printf("%s -c 12\n", name); + printf("%s -p 0.001212\n", name); + printf("%s -l 1.39e-06\n", name); +*/ + printf("%s\nIf no arguments are given a builtin set of tests are run.\n", name); +} + +static int RunBuiltInTests(char *argv[]) { + int exitStatus = 0; + size_t i; + + double rawValue, value, mult; + const char *valueStr; + + static char* methodName[3] = { + "liebert_config_voltage_mult() ", + "liebert_line_voltage_mult() ", + "liebert_psi5_line_voltage_mult()" + }; + + static struct { + char *buf; /* raw voltage as a string (from CLI input, e.g. NUT driver log trace) */ + double expectedRawValue; /* parsed raw voltage (as seen in USB HID reports) */ + char type; /* 1 = config, 2 = line, 3 = PSI5 line */ + double expectedMult; /* expected liebert_config_voltage_mult or liebert_line_voltage_mult */ + double expectedValue; /* the expected result of decoding the value in the buffer */ + } testData[] = { + {.buf = "0.000273", .expectedRawValue = 0.000273, .type = 3, .expectedMult = 1e5, .expectedValue = 27.3 }, + {.buf = "0.001212", .expectedRawValue = 0.001212, .type = 3, .expectedMult = 1e5, .expectedValue = 121.2 }, + + {.buf = "1.39e-06", .expectedRawValue = 0.00000139, .type = 2, .expectedMult = 1e7, .expectedValue = 13.9 }, + {.buf = "2.201e-05", .expectedRawValue = 0.00002201, .type = 2, .expectedMult = 1e7, .expectedValue = 220.1 }, + + /* Edge cases - what should not be converted (good enough already) */ + {.buf = "12", .expectedRawValue = 12.0, .type = 3, .expectedMult = 1, .expectedValue = 12.0 }, + {.buf = "12.3", .expectedRawValue = 12.3, .type = 3, .expectedMult = 1, .expectedValue = 12.3 }, + {.buf = "232.1", .expectedRawValue = 232.1, .type = 3, .expectedMult = 1, .expectedValue = 232.1 }, + {.buf = "240", .expectedRawValue = 240.0, .type = 3, .expectedMult = 1, .expectedValue = 240.0 }, + + {.buf = "12", .expectedRawValue = 12.0, .type = 2, .expectedMult = 1, .expectedValue = 12.0 }, + {.buf = "12.3", .expectedRawValue = 12.3, .type = 2, .expectedMult = 1, .expectedValue = 12.3 }, + {.buf = "232.1", .expectedRawValue = 232.1, .type = 2, .expectedMult = 1, .expectedValue = 232.1 }, + {.buf = "240", .expectedRawValue = 240.0, .type = 2, .expectedMult = 1, .expectedValue = 240.0 }, + + /* Config values (nominal battery/input/... voltage) are often integers: */ + {.buf = "24", .expectedRawValue = 24.0, .type = 1, .expectedMult = 1, .expectedValue = 24.0 }, + {.buf = "120", .expectedRawValue = 120.0, .type = 1, .expectedMult = 1, .expectedValue = 120.0 } + }; + + NUT_UNUSED_VARIABLE(argv); + + for (i = 0; i < SIZEOF_ARRAY(testData); i++) { + liebert_line_voltage_mult = 1.0; + liebert_config_voltage_mult = 1.0; + + rawValue = strtod(testData[i].buf, NULL); + if (rawValue != testData[i].expectedRawValue) { + printf(" value '%s' parsing FAIL: got %g expected %g\n", + testData[i].buf, rawValue, testData[i].expectedRawValue); + /* Fix testData definition! */ + exitStatus = 1; + } + + switch (testData[i].type) { + case 1: + valueStr = liebert_config_voltage_fun(rawValue); + mult = liebert_config_voltage_mult; + /* NOTE: The method does also set a default + * liebert_line_voltage_mult if config voltage + * is miniscule and not a plain integer */ + break; + + case 2: + valueStr = liebert_line_voltage_fun(rawValue); + mult = liebert_line_voltage_mult; + break; + + case 3: + valueStr = liebert_psi5_line_voltage_fun(rawValue); + mult = liebert_line_voltage_mult; + break; + + default: + printf(" invalid entry\n"); + continue; + } + + printf("Test #%" PRIiSIZE " \t", i + 1); + value = strtod(valueStr, NULL); + if (value == testData[i].expectedValue && mult == testData[i].expectedMult) { + printf("%s\tGOT value %9g\tmult %6g PASS\n", + (testData[i].type < 1 || testData[i].type > 3 ? "" : methodName[testData[i].type - 1]), + value, mult); + } else { + printf("%s\tGOT value %9g\tmult %6g FAIL" + "\tEXPECTED v=%7g\tm=%7g" + "\tORIGINAL (string)'%s'\t=> (double)%g\n", + (testData[i].type < 1 || testData[i].type > 3 ? "" : methodName[testData[i].type - 1]), + value, mult, + testData[i].expectedValue, + testData[i].expectedMult, + testData[i].buf, rawValue); + exitStatus = 1; + } + } + + return (exitStatus); +} + +/* +static int RunCommandLineTest(char *argv[]) { + uint8_t reportBuf[64]; + size_t bufSize; + char *start, *end; + HIDData_t data; + long value, expectedValue; + + start = argv[1]; + end = NULL; + for (bufSize = 0; *start != 0; bufSize++) { + reportBuf[bufSize] = (uint8_t) strtol(start, (char **)&end, 16); + if (start == end) break; + start = end; + } + memset((void *)&data, 0, sizeof(data)); + data.Offset = (uint8_t) atoi(argv[2]); + data.Size = (uint8_t) atoi(argv[3]); + data.LogMin = strtol(argv[4], 0, 0); + data.LogMax = strtol(argv[5], 0, 0); + expectedValue = strtol(argv[6], 0, 0); + + GetValue(reportBuf, &data, &value); + + printf("Test #0 "); + PrintBufAndData(reportBuf, bufSize, &data); + if (value == expectedValue) { + printf(" value %ld PASS\n", value); + return (0); + } else { + printf(" value %ld FAIL expected %ld\n", value, expectedValue); + return (1); + } +} +*/ + +int main (int argc, char *argv[]) { + int status; + + switch (argc) { + case 1: + status = RunBuiltInTests(argv); + break; +/* + case 7: + status = RunCommandLineTest(argv); + break; +*/ + default: + Usage(argv[0]); + status = 2; + } + return(status); +} From 6fc102468f162c85a92e7cb450817ed4bb3be631 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 17:18:27 +0100 Subject: [PATCH 074/325] drivers/belkin-hid.c: Revert modifications for unit-testing, arrange its build differently [#2371] Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 20 +++++++++----------- tests/Makefile.am | 13 +++++++------ tests/driver-stub-usb.c | 4 ++-- tests/getexponenttest.c | 4 +++- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index 857cf58c1f..552ad400a2 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -33,7 +33,7 @@ #include /* for fabs() */ -#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.21" +#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.20" /* Belkin */ #define BELKIN_VENDORID 0x050d @@ -94,16 +94,14 @@ static const char *liebert_shutdownimm_fun(double value); /* These lookup functions also cover the 1e-7 factor which seems to * be due to a broken report descriptor in certain Liebert units. * Exposed for unit testing - not "static" */ -const char *liebert_config_voltage_fun(double value); -const char *liebert_line_voltage_fun(double value); -const char *liebert_psi5_line_voltage_fun(double value); +static const char *liebert_config_voltage_fun(double value); +static const char *liebert_line_voltage_fun(double value); +static const char *liebert_psi5_line_voltage_fun(double value); -extern double liebert_config_voltage_mult, liebert_line_voltage_mult; -double liebert_config_voltage_mult = 1.0; -double liebert_line_voltage_mult = 1.0; +static double liebert_config_voltage_mult = 1.0; +static double liebert_line_voltage_mult = 1.0; static char liebert_conversion_buf[10]; - static info_lkp_t liebert_online_info[] = { { 0, NULL, liebert_online_fun, NULL } }; @@ -174,7 +172,7 @@ static const char *liebert_shutdownimm_fun(double value) * Logic is weird since the ConfigVoltage item comes after InputVoltage and * OutputVoltage. */ -const char *liebert_config_voltage_fun(double value) +static const char *liebert_config_voltage_fun(double value) { if( value < 1 ) { if( fabs(value - 1e-7) < 1e-9 ) { @@ -192,7 +190,7 @@ const char *liebert_config_voltage_fun(double value) return liebert_conversion_buf; } -const char *liebert_line_voltage_fun(double value) +static const char *liebert_line_voltage_fun(double value) { if( value < 1 ) { if( fabs(value - 1e-7) < 1e-9 ) { @@ -209,7 +207,7 @@ const char *liebert_line_voltage_fun(double value) return liebert_conversion_buf; } -const char *liebert_psi5_line_voltage_fun(double value) +static const char *liebert_psi5_line_voltage_fun(double value) { if( value < 1 ) { if( fabs(value - 1e-3) < 1e-3 ) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 94588ce202..d5f6ab0be6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -73,14 +73,15 @@ TESTS += getvaluetest getexponenttest # We only need to call a few methods, not use the whole source - so # not linking it as a getvaluetest_SOURCE file (has too many deps): -noinst_LTLIBRARIES += libbelkin.la -nodist_libbelkin_la_SOURCES = belkin-hid.c driver-stub-usb.c -libbelkin_la_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) -libbelkin_la_LIBADD = $(top_builddir)/common/libcommon.la +noinst_LTLIBRARIES += libdriverstubusb.la +nodist_libdriverstubusb_la_SOURCES = driver-stub-usb.c +libdriverstubusb_la_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +#libdriverstubusb_la_LIBADD = $(top_builddir)/common/libcommon.la +getexponenttest.c: belkin-hid.c getexponenttest_SOURCES = getexponenttest.c -#getexponenttest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) -getexponenttest_LDADD = $(top_builddir)/common/libcommon.la libbelkin.la +getexponenttest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +getexponenttest_LDADD = $(top_builddir)/common/libcommon.la libdriverstubusb.la getvaluetest_SOURCES = getvaluetest.c nodist_getvaluetest_SOURCES = hidparser.c diff --git a/tests/driver-stub-usb.c b/tests/driver-stub-usb.c index e483eea41d..0ddedbd91f 100644 --- a/tests/driver-stub-usb.c +++ b/tests/driver-stub-usb.c @@ -1,5 +1,5 @@ -/* placeholder method implementations to just link the libbelkin stub - * and eventually similar code by directly using driver source code +/* placeholder/mock method implementations to just directly use driver + * source code as done for belkin-hid.c (and eventually similar code) * for almost-in-vivo testing (and minimal intrusion to that codebase). * See also: getexponenttest.c * diff --git a/tests/getexponenttest.c b/tests/getexponenttest.c index 94d082ac31..df3bd21ed4 100644 --- a/tests/getexponenttest.c +++ b/tests/getexponenttest.c @@ -32,11 +32,13 @@ #include #include "common.h" -/* from drivers/belkin-hid.c: */ +#include "belkin-hid.c" +/* from drivers/belkin-hid.c we test: extern double liebert_config_voltage_mult, liebert_line_voltage_mult; const char *liebert_config_voltage_fun(double value); const char *liebert_line_voltage_fun(double value); const char *liebert_psi5_line_voltage_fun(double value); + */ static void Usage(char *name) { /* From 7a31f1dafb02ede9aa6c2efb18aab3db1965b463 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 17:24:50 +0100 Subject: [PATCH 075/325] tests/getexponenttest.c: use our macros to avoid "comparing floating point with == or != is unsafe [-Werror,-Wfloat-equal]" [#2371] Signed-off-by: Jim Klimov --- tests/getexponenttest.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/getexponenttest.c b/tests/getexponenttest.c index df3bd21ed4..b5d5c5b669 100644 --- a/tests/getexponenttest.c +++ b/tests/getexponenttest.c @@ -27,6 +27,7 @@ #include "config.h" #include "nut_stdint.h" +#include "nut_float.h" #include #include #include @@ -100,7 +101,7 @@ static int RunBuiltInTests(char *argv[]) { liebert_config_voltage_mult = 1.0; rawValue = strtod(testData[i].buf, NULL); - if (rawValue != testData[i].expectedRawValue) { + if (!d_equal(rawValue, testData[i].expectedRawValue)) { printf(" value '%s' parsing FAIL: got %g expected %g\n", testData[i].buf, rawValue, testData[i].expectedRawValue); /* Fix testData definition! */ @@ -133,7 +134,7 @@ static int RunBuiltInTests(char *argv[]) { printf("Test #%" PRIiSIZE " \t", i + 1); value = strtod(valueStr, NULL); - if (value == testData[i].expectedValue && mult == testData[i].expectedMult) { + if (d_equal(value, testData[i].expectedValue) && d_equal(mult, testData[i].expectedMult)) { printf("%s\tGOT value %9g\tmult %6g PASS\n", (testData[i].type < 1 || testData[i].type > 3 ? "" : methodName[testData[i].type - 1]), value, mult); From 2a0f33ac858a32cdf73a7e2d0cb8f7931d32339c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 17:30:24 +0100 Subject: [PATCH 076/325] tests: rename getexponenttest => getexponenttest-belkin-hid since it became quite specific to that subdriver source Still, can serve as an example/blueprint for other drivers' tests. Signed-off-by: Jim Klimov --- tests/.gitignore | 6 +++--- tests/Makefile.am | 10 +++++----- tests/driver-stub-usb.c | 2 +- ...{getexponenttest.c => getexponenttest-belkin-hid.c} | 9 +++++---- 4 files changed, 14 insertions(+), 13 deletions(-) rename tests/{getexponenttest.c => getexponenttest-belkin-hid.c} (95%) diff --git a/tests/.gitignore b/tests/.gitignore index 1036cac317..1648d7c1de 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -16,9 +16,9 @@ /nuttimetest /nuttimetest.log /nuttimetest.trs -/getexponenttest -/getexponenttest.log -/getexponenttest.trs +/getexponenttest-belkin-hid +/getexponenttest-belkin-hid.log +/getexponenttest-belkin-hid.trs /belkin-hid.c /getvaluetest /getvaluetest.log diff --git a/tests/Makefile.am b/tests/Makefile.am index d5f6ab0be6..bc0f231e28 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -69,7 +69,7 @@ belkin-hid.c: $(top_srcdir)/drivers/belkin-hid.c test -s "$@" || ln -s -f "$(top_srcdir)/drivers/belkin-hid.c" "$@" if WITH_USB -TESTS += getvaluetest getexponenttest +TESTS += getvaluetest getexponenttest-belkin-hid # We only need to call a few methods, not use the whole source - so # not linking it as a getvaluetest_SOURCE file (has too many deps): @@ -78,10 +78,10 @@ nodist_libdriverstubusb_la_SOURCES = driver-stub-usb.c libdriverstubusb_la_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) #libdriverstubusb_la_LIBADD = $(top_builddir)/common/libcommon.la -getexponenttest.c: belkin-hid.c -getexponenttest_SOURCES = getexponenttest.c -getexponenttest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) -getexponenttest_LDADD = $(top_builddir)/common/libcommon.la libdriverstubusb.la +getexponenttest-belkin-hid.c: belkin-hid.c +getexponenttest_belkin_hid_SOURCES = getexponenttest-belkin-hid.c +getexponenttest_belkin_hid_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +getexponenttest_belkin_hid_LDADD = $(top_builddir)/common/libcommon.la libdriverstubusb.la getvaluetest_SOURCES = getvaluetest.c nodist_getvaluetest_SOURCES = hidparser.c diff --git a/tests/driver-stub-usb.c b/tests/driver-stub-usb.c index 0ddedbd91f..6cb557a75c 100644 --- a/tests/driver-stub-usb.c +++ b/tests/driver-stub-usb.c @@ -1,7 +1,7 @@ /* placeholder/mock method implementations to just directly use driver * source code as done for belkin-hid.c (and eventually similar code) * for almost-in-vivo testing (and minimal intrusion to that codebase). - * See also: getexponenttest.c + * See also: getexponenttest-belkin-hid.c * * Copyright (C) * 2024 Jim Klimov diff --git a/tests/getexponenttest.c b/tests/getexponenttest-belkin-hid.c similarity index 95% rename from tests/getexponenttest.c rename to tests/getexponenttest-belkin-hid.c index b5d5c5b669..21256ebb5a 100644 --- a/tests/getexponenttest.c +++ b/tests/getexponenttest-belkin-hid.c @@ -1,7 +1,8 @@ -/* getexponenttest - check detection of correct multiplication exponent value - * for miniscule readings from USB HID (as used in e.g. drivers/belkin-hid.c - * subdriver). Eventually may be extended to similar tests for other driver - * methods. +/* getexponenttest-belkin-hid - check detection of correct multiplication + * exponent value for miniscule readings from USB HID (as used in the + * drivers/belkin-hid.c subdriver of usbhid-ups). + * Eventually may be extended to similar tests for other drivers' methods, + * or more likely cloned to #include them in similar fashion. * * See also: * https://github.com/networkupstools/nut/issues/2370 From 2d71eb9a8276b26fccc6335d4fec8215fe6a63dd Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 17:40:41 +0100 Subject: [PATCH 077/325] tests: no longer need a replica of belkin-hid.c in tests/ to build getexponenttest-belkin-hid Suffices that we #include it in the test source, and drivers/ are among include dirs Signed-off-by: Jim Klimov --- tests/.gitignore | 1 - tests/Makefile.am | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/.gitignore b/tests/.gitignore index 1648d7c1de..97af77e45d 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -19,7 +19,6 @@ /getexponenttest-belkin-hid /getexponenttest-belkin-hid.log /getexponenttest-belkin-hid.trs -/belkin-hid.c /getvaluetest /getvaluetest.log /getvaluetest.trs diff --git a/tests/Makefile.am b/tests/Makefile.am index bc0f231e28..036948359f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -58,16 +58,13 @@ nuttimetest_SOURCES = nuttimetest.c nuttimetest_LDADD = $(top_builddir)/common/libcommon.la # Separate the .deps of other dirs from this one -LINKED_SOURCE_FILES = hidparser.c belkin-hid.c +LINKED_SOURCE_FILES = hidparser.c # NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver # of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS hidparser.c: $(top_srcdir)/drivers/hidparser.c test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@" -belkin-hid.c: $(top_srcdir)/drivers/belkin-hid.c - test -s "$@" || ln -s -f "$(top_srcdir)/drivers/belkin-hid.c" "$@" - if WITH_USB TESTS += getvaluetest getexponenttest-belkin-hid @@ -78,7 +75,7 @@ nodist_libdriverstubusb_la_SOURCES = driver-stub-usb.c libdriverstubusb_la_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) #libdriverstubusb_la_LIBADD = $(top_builddir)/common/libcommon.la -getexponenttest-belkin-hid.c: belkin-hid.c +getexponenttest-belkin-hid.c: $(top_srcdir)/drivers/belkin-hid.c getexponenttest_belkin_hid_SOURCES = getexponenttest-belkin-hid.c getexponenttest_belkin_hid_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) getexponenttest_belkin_hid_LDADD = $(top_builddir)/common/libcommon.la libdriverstubusb.la @@ -89,7 +86,7 @@ nodist_getvaluetest_SOURCES = hidparser.c getvaluetest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) getvaluetest_LDADD = $(top_builddir)/common/libcommon.la else !WITH_USB -EXTRA_DIST += getvaluetest.c hidparser.c belkin-hid.c +EXTRA_DIST += getvaluetest.c hidparser.c endif !WITH_USB if WITH_GPIO From 5356387d96bebe5732b357d5101373705bbf27d5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 17:49:57 +0100 Subject: [PATCH 078/325] drivers/belkin-hid.c: comment expectations for liebert_line_voltage_fun() and friends Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index 552ad400a2..b14d36d18e 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -174,8 +174,13 @@ static const char *liebert_shutdownimm_fun(double value) */ static const char *liebert_config_voltage_fun(double value) { - if( value < 1 ) { - if( fabs(value - 1e-7) < 1e-9 ) { + /* Does not fire with devices seen diring investigation for + * https://github.com/networkupstools/nut/issues/2370 + * as the ones seen serve nominal "config" values as integers + * (e.g. "230" for line and "24" for battery). + */ + if (value < 1) { + if (fabs(value - 1e-7) < 1e-9) { liebert_config_voltage_mult = 1e8; liebert_line_voltage_mult = 1e7; /* stomp this in case input voltage was low */ upsdebugx(2, "ConfigVoltage = %g -> assuming correction factor = %g", @@ -192,8 +197,17 @@ static const char *liebert_config_voltage_fun(double value) static const char *liebert_line_voltage_fun(double value) { - if( value < 1 ) { - if( fabs(value - 1e-7) < 1e-9 ) { + /* Keep large readings like "230" or "24" as is */ + if (value < 1) { + /* Practical use-case for mult=1e7: + * 1.39e-06 => 13.9 + * 2.201e-05 => 220.1 + * NOTE: The clause below is in fact broken for this use-case, + * but was present in sources for ages (worked wrongly with an + * integer-oriented abs() so collapsed into "if (0 < 1e-9) {")! + * if (fabs(value - 1e-7) < 1e-9) { + */ + if (fabs(value - 1e-7) < 1e-9) { liebert_line_voltage_mult = 1e7; upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", value, liebert_line_voltage_mult); @@ -209,8 +223,12 @@ static const char *liebert_line_voltage_fun(double value) static const char *liebert_psi5_line_voltage_fun(double value) { - if( value < 1 ) { - if( fabs(value - 1e-3) < 1e-3 ) { + if (value < 1) { + /* Practical use-case for mult=1e5: + * 0.000273 => 27.3 + * 0.001212 => 121.2 + */ + if (fabs(value - 1e-3) < 1e-3) { liebert_line_voltage_mult = 1e5; upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", value, liebert_line_voltage_mult); From 630de574db645271d604a715351a26bb76d26233 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 18:17:00 +0100 Subject: [PATCH 079/325] tests/getexponenttest-belkin-hid.c: add tests for larger value ranges (over 200V) Signed-off-by: Jim Klimov --- tests/getexponenttest-belkin-hid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/getexponenttest-belkin-hid.c b/tests/getexponenttest-belkin-hid.c index 21256ebb5a..084e22abf2 100644 --- a/tests/getexponenttest-belkin-hid.c +++ b/tests/getexponenttest-belkin-hid.c @@ -75,9 +75,14 @@ static int RunBuiltInTests(char *argv[]) { } testData[] = { {.buf = "0.000273", .expectedRawValue = 0.000273, .type = 3, .expectedMult = 1e5, .expectedValue = 27.3 }, {.buf = "0.001212", .expectedRawValue = 0.001212, .type = 3, .expectedMult = 1e5, .expectedValue = 121.2 }, + {.buf = "0.002456", .expectedRawValue = 0.002456, .type = 3, .expectedMult = 1e5, .expectedValue = 245.6 }, + {.buf = "0.003801", .expectedRawValue = 0.003801, .type = 3, .expectedMult = 1e5, .expectedValue = 380.1 }, + {.buf = "0.004151", .expectedRawValue = 0.004151, .type = 3, .expectedMult = 1e5, .expectedValue = 415.1 }, {.buf = "1.39e-06", .expectedRawValue = 0.00000139, .type = 2, .expectedMult = 1e7, .expectedValue = 13.9 }, + {.buf = "1.273e-05", .expectedRawValue = 0.00001273, .type = 2, .expectedMult = 1e7, .expectedValue = 127.3 }, {.buf = "2.201e-05", .expectedRawValue = 0.00002201, .type = 2, .expectedMult = 1e7, .expectedValue = 220.1 }, + {.buf = "4.201e-05", .expectedRawValue = 0.00004201, .type = 2, .expectedMult = 1e7, .expectedValue = 420.1 }, /* Edge cases - what should not be converted (good enough already) */ {.buf = "12", .expectedRawValue = 12.0, .type = 3, .expectedMult = 1, .expectedValue = 12.0 }, From c0b0c040d3d942bfe1203ea1ac413176033d1b13 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 25 Mar 2024 18:20:11 +0100 Subject: [PATCH 080/325] drivers/belkin-hid.c: fix liebert_line_voltage_fun() and friends for 0..500V range (cover 3-pole while we are at it) Not touching liebert_config_voltage_fun() at the moment as have no non-integer examples under hand to test against. Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index b14d36d18e..23561d9bf0 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -33,7 +33,7 @@ #include /* for fabs() */ -#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.20" +#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.21" /* Belkin */ #define BELKIN_VENDORID 0x050d @@ -207,7 +207,7 @@ static const char *liebert_line_voltage_fun(double value) * integer-oriented abs() so collapsed into "if (0 < 1e-9) {")! * if (fabs(value - 1e-7) < 1e-9) { */ - if (fabs(value - 1e-7) < 1e-9) { + if (fabs(value - 1e-5) < 4*1e-5) { liebert_line_voltage_mult = 1e7; upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", value, liebert_line_voltage_mult); @@ -228,7 +228,7 @@ static const char *liebert_psi5_line_voltage_fun(double value) * 0.000273 => 27.3 * 0.001212 => 121.2 */ - if (fabs(value - 1e-3) < 1e-3) { + if (fabs(value - 1e-3) < 4*1e-3) { liebert_line_voltage_mult = 1e5; upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", value, liebert_line_voltage_mult); From 490fa8bb047afb47a78469e414ac4dc05a18c49a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 26 Mar 2024 02:05:40 +0100 Subject: [PATCH 081/325] tests/getexponenttest-belkin-hid.c, drivers/belkin-hid.c: absorb liebert_psi5_line_voltage_fun() into common liebert_line_voltage_fun() Hopefully should help more devices than those which serve this or that HID subtree only. Follows up from PR #2369 Signed-off-by: Jim Klimov --- drivers/belkin-hid.c | 35 ++++++++++-------------------- tests/getexponenttest-belkin-hid.c | 34 ++++++++++------------------- 2 files changed, 23 insertions(+), 46 deletions(-) diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index 23561d9bf0..1baed8f00d 100644 --- a/drivers/belkin-hid.c +++ b/drivers/belkin-hid.c @@ -96,7 +96,6 @@ static const char *liebert_shutdownimm_fun(double value); * Exposed for unit testing - not "static" */ static const char *liebert_config_voltage_fun(double value); static const char *liebert_line_voltage_fun(double value); -static const char *liebert_psi5_line_voltage_fun(double value); static double liebert_config_voltage_mult = 1.0; static double liebert_line_voltage_mult = 1.0; @@ -134,10 +133,6 @@ static info_lkp_t liebert_line_voltage_info[] = { { 0, NULL, liebert_line_voltage_fun, NULL }, }; -static info_lkp_t liebert_psi5_line_voltage_info[] = { - { 0, NULL, liebert_psi5_line_voltage_fun, NULL }, -}; - static const char *liebert_online_fun(double value) { return value ? "online" : "!online"; @@ -199,6 +194,9 @@ static const char *liebert_line_voltage_fun(double value) { /* Keep large readings like "230" or "24" as is */ if (value < 1) { + int picked_scale = 0; + /* NOTE: Start with tiniest scale first */ + /* Practical use-case for mult=1e7: * 1.39e-06 => 13.9 * 2.201e-05 => 220.1 @@ -209,27 +207,18 @@ static const char *liebert_line_voltage_fun(double value) */ if (fabs(value - 1e-5) < 4*1e-5) { liebert_line_voltage_mult = 1e7; - upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", - value, liebert_line_voltage_mult); - } else { - upslogx(LOG_NOTICE, "LineVoltage exponent looks wrong, but not correcting."); - } - } - - snprintf(liebert_conversion_buf, sizeof(liebert_conversion_buf), "%.1f", - value * liebert_line_voltage_mult); - return liebert_conversion_buf; -} - -static const char *liebert_psi5_line_voltage_fun(double value) -{ - if (value < 1) { + picked_scale = 1; + } else /* Practical use-case for mult=1e5: * 0.000273 => 27.3 * 0.001212 => 121.2 */ if (fabs(value - 1e-3) < 4*1e-3) { liebert_line_voltage_mult = 1e5; + picked_scale = 1; + } + + if (picked_scale) { upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g", value, liebert_line_voltage_mult); } else { @@ -528,12 +517,12 @@ static hid_info_t belkin_hid2nut[] = { /* Liebert PSI5 */ { "input.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%s", 0, divide_by_100_conversion }, - { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%s", 0, liebert_psi5_line_voltage_info }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%s", 0, liebert_line_voltage_info }, { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%s", 0, divide_by_100_conversion }, - { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%s", 0, liebert_psi5_line_voltage_info }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%s", 0, liebert_line_voltage_info }, { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.0f", 0, NULL }, - { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%s", 0, liebert_psi5_line_voltage_info }, + { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%s", 0, liebert_line_voltage_info }, { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", 0, NULL }, { "battery.capacity", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, /* status */ diff --git a/tests/getexponenttest-belkin-hid.c b/tests/getexponenttest-belkin-hid.c index 084e22abf2..5cb872b02b 100644 --- a/tests/getexponenttest-belkin-hid.c +++ b/tests/getexponenttest-belkin-hid.c @@ -39,15 +39,14 @@ extern double liebert_config_voltage_mult, liebert_line_voltage_mult; const char *liebert_config_voltage_fun(double value); const char *liebert_line_voltage_fun(double value); -const char *liebert_psi5_line_voltage_fun(double value); */ static void Usage(char *name) { /* - printf("%s {-c | -l | -p } \n", name); + printf("%s {-c | -l } \n", name); printf("\n"); printf("%s -c 12\n", name); - printf("%s -p 0.001212\n", name); + printf("%s -l 0.001212\n", name); printf("%s -l 1.39e-06\n", name); */ printf("%s\nIf no arguments are given a builtin set of tests are run.\n", name); @@ -60,24 +59,23 @@ static int RunBuiltInTests(char *argv[]) { double rawValue, value, mult; const char *valueStr; - static char* methodName[3] = { + static char* methodName[2] = { "liebert_config_voltage_mult() ", - "liebert_line_voltage_mult() ", - "liebert_psi5_line_voltage_mult()" + "liebert_line_voltage_mult() " }; static struct { char *buf; /* raw voltage as a string (from CLI input, e.g. NUT driver log trace) */ double expectedRawValue; /* parsed raw voltage (as seen in USB HID reports) */ - char type; /* 1 = config, 2 = line, 3 = PSI5 line */ + char type; /* 1 = config, 2 = line */ double expectedMult; /* expected liebert_config_voltage_mult or liebert_line_voltage_mult */ double expectedValue; /* the expected result of decoding the value in the buffer */ } testData[] = { - {.buf = "0.000273", .expectedRawValue = 0.000273, .type = 3, .expectedMult = 1e5, .expectedValue = 27.3 }, - {.buf = "0.001212", .expectedRawValue = 0.001212, .type = 3, .expectedMult = 1e5, .expectedValue = 121.2 }, - {.buf = "0.002456", .expectedRawValue = 0.002456, .type = 3, .expectedMult = 1e5, .expectedValue = 245.6 }, - {.buf = "0.003801", .expectedRawValue = 0.003801, .type = 3, .expectedMult = 1e5, .expectedValue = 380.1 }, - {.buf = "0.004151", .expectedRawValue = 0.004151, .type = 3, .expectedMult = 1e5, .expectedValue = 415.1 }, + {.buf = "0.000273", .expectedRawValue = 0.000273, .type = 2, .expectedMult = 1e5, .expectedValue = 27.3 }, + {.buf = "0.001212", .expectedRawValue = 0.001212, .type = 2, .expectedMult = 1e5, .expectedValue = 121.2 }, + {.buf = "0.002456", .expectedRawValue = 0.002456, .type = 2, .expectedMult = 1e5, .expectedValue = 245.6 }, + {.buf = "0.003801", .expectedRawValue = 0.003801, .type = 2, .expectedMult = 1e5, .expectedValue = 380.1 }, + {.buf = "0.004151", .expectedRawValue = 0.004151, .type = 2, .expectedMult = 1e5, .expectedValue = 415.1 }, {.buf = "1.39e-06", .expectedRawValue = 0.00000139, .type = 2, .expectedMult = 1e7, .expectedValue = 13.9 }, {.buf = "1.273e-05", .expectedRawValue = 0.00001273, .type = 2, .expectedMult = 1e7, .expectedValue = 127.3 }, @@ -85,11 +83,6 @@ static int RunBuiltInTests(char *argv[]) { {.buf = "4.201e-05", .expectedRawValue = 0.00004201, .type = 2, .expectedMult = 1e7, .expectedValue = 420.1 }, /* Edge cases - what should not be converted (good enough already) */ - {.buf = "12", .expectedRawValue = 12.0, .type = 3, .expectedMult = 1, .expectedValue = 12.0 }, - {.buf = "12.3", .expectedRawValue = 12.3, .type = 3, .expectedMult = 1, .expectedValue = 12.3 }, - {.buf = "232.1", .expectedRawValue = 232.1, .type = 3, .expectedMult = 1, .expectedValue = 232.1 }, - {.buf = "240", .expectedRawValue = 240.0, .type = 3, .expectedMult = 1, .expectedValue = 240.0 }, - {.buf = "12", .expectedRawValue = 12.0, .type = 2, .expectedMult = 1, .expectedValue = 12.0 }, {.buf = "12.3", .expectedRawValue = 12.3, .type = 2, .expectedMult = 1, .expectedValue = 12.3 }, {.buf = "232.1", .expectedRawValue = 232.1, .type = 2, .expectedMult = 1, .expectedValue = 232.1 }, @@ -128,11 +121,6 @@ static int RunBuiltInTests(char *argv[]) { mult = liebert_line_voltage_mult; break; - case 3: - valueStr = liebert_psi5_line_voltage_fun(rawValue); - mult = liebert_line_voltage_mult; - break; - default: printf(" invalid entry\n"); continue; @@ -148,7 +136,7 @@ static int RunBuiltInTests(char *argv[]) { printf("%s\tGOT value %9g\tmult %6g FAIL" "\tEXPECTED v=%7g\tm=%7g" "\tORIGINAL (string)'%s'\t=> (double)%g\n", - (testData[i].type < 1 || testData[i].type > 3 ? "" : methodName[testData[i].type - 1]), + (testData[i].type < 1 || testData[i].type > 2 ? "" : methodName[testData[i].type - 1]), value, mult, testData[i].expectedValue, testData[i].expectedMult, From 43f4b996056f265025cb80fa6133451c36470878 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 26 Mar 2024 02:37:04 +0100 Subject: [PATCH 082/325] NEWS.adoc: document fixes for Belkin/Liebert readings Signed-off-by: Jim Klimov --- NEWS.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.adoc b/NEWS.adoc index ba5eb36150..4cd6964b3c 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -182,7 +182,9 @@ https://github.com/networkupstools/nut/milestone/10 by cooperation with Cyber Power Systems. [#2312] * `belkin-hid` subdriver now supports Liebert PSI5 devices which have a different numeric reading scale than earlier handled models. [issue #2271, - PR #2272, PR #2369] + PR #2272, PR #2369] Generally the wrong-scale processing was addressed, + including a regression in NUT v2.8.0 which led to zero values + in voltage data points which NUT v2.7.4 reported well [#2371] * The `onlinedischarge` configuration flag name was too ambiguous and got deprecated (will be supported but no longer promoted by documentation), introducing `onlinedischarge_onbattery` as the meaningful alias. [#2213] From 229f91f7ee2c5732a73a4803ab50b69803d8aeb1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 26 Mar 2024 12:08:15 +0100 Subject: [PATCH 083/325] tests/Makefile.am: EXTRA_DIST the test mock "program" source Signed-off-by: Jim Klimov --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 036948359f..b6633707a4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,6 +88,7 @@ getvaluetest_LDADD = $(top_builddir)/common/libcommon.la else !WITH_USB EXTRA_DIST += getvaluetest.c hidparser.c endif !WITH_USB +EXTRA_DIST += driver-stub-usb.c if WITH_GPIO TESTS += gpiotest From e89e6cae8e9afca3b96ff3a378c14e5220b4f80a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 31 Mar 2024 01:29:41 +0100 Subject: [PATCH 084/325] drivers/riello_usb.c: upsdrv_initinfo(): set batt_volt_* limit vars from settings or initial reading [#1692] Signed-off-by: Jim Klimov --- drivers/riello_usb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 4d321d0d28..baf8d8858e 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -1061,6 +1061,12 @@ void upsdrv_initinfo(void) batt_volt_high *= times12; } } else { + if (valL) + batt_volt_low = strtod(valL, NULL); + + if (valH) + batt_volt_high = strtod(valH, NULL); + /* If just one of those is set, then what? */ if (valL || valH) { upsdebugx(1, "WARNING: Only one of battery.voltage.low=%.1f " From 0e14eebfaad138dc8eeb527b759a33a73a5ba813 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 31 Mar 2024 03:08:17 +0200 Subject: [PATCH 085/325] drivers/riello_usb.c: upsdrv_initinfo(): set batt_volt_* limit vars from nominal voltage alignment, then apply from settings or initial reading [#1692] Signed-off-by: Jim Klimov --- drivers/riello_usb.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index baf8d8858e..32a46b5618 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -1049,30 +1049,47 @@ void upsdrv_initinfo(void) valL = dstate_getinfo("battery.voltage.low"); valH = dstate_getinfo("battery.voltage.high"); - if (!valL && !valH) { - /* Both not set (NULL) => pick by nominal (X times 12V). - * Pick a suitable low/high range (or keep built-in default). + { /* scoping */ + /* Pick a suitable low/high range (or keep built-in default). + * The factor may be a count of battery packs in the UPS. */ int times12 = batt_volt_nom / 12; if (times12 > 1) { /* Scale up the range for 24V (X=2) etc. */ - upsdebugx(1, "Using %i times the voltage range of 12V PbAc battery", times12); + upsdebugx(3, "%s: Using %i times the voltage range of 12V PbAc battery", + __func__, times12); batt_volt_low *= times12; batt_volt_high *= times12; } + } + + if (!valL && !valH) { + /* Both not set (NULL) => pick by nominal (X times 12V above). */ + upsdebugx(3, "Neither battery.voltage.low=%.1f " + "nor battery.voltage.high=%.1f is set via " + "driver configuration or by device; keeping " + "at built-in default value (aligned " + "with battery.voltage.nominal=%.1f)", + batt_volt_low, batt_volt_high, batt_volt_nom); } else { - if (valL) + if (valL) { batt_volt_low = strtod(valL, NULL); + upsdebugx(2, "%s: Using battery.voltage.low=%.1f from device or settings", + __func__, batt_volt_low); + } - if (valH) + if (valH) { batt_volt_high = strtod(valH, NULL); + upsdebugx(2, "%s: Using battery.voltage.high=%.1f from device or settings", + __func__, batt_volt_high); + } /* If just one of those is set, then what? */ if (valL || valH) { upsdebugx(1, "WARNING: Only one of battery.voltage.low=%.1f " "or battery.voltage.high=%.1f is set via " "driver configuration; keeping the other " - "at built-in default value (and not aligning " + "at built-in default value (aligned " "with battery.voltage.nominal=%.1f)", batt_volt_low, batt_volt_high, batt_volt_nom); } else { From 3bdb12ff4c339629c38e9cbf351538b9dec6f79b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 31 Mar 2024 22:45:35 +0200 Subject: [PATCH 086/325] NEWS.adoc: mention belkin-hid fix as also a regression fix [#2371] Signed-off-by: Jim Klimov --- NEWS.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.adoc b/NEWS.adoc index 4cd6964b3c..c08a8d9d4d 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -87,6 +87,10 @@ https://github.com/networkupstools/nut/milestone/10 `configure` script option `--with-debuginfo`. Note that default autoconf behavior usually embeds moderate optimizations and debug information on its own. [PR #2310] + * A fix applied among clean-ups between NUT v2.7.4 and v2.8.0 releases + backfired for `usbhid-ups` subdriver `belkin-hid` which in practice + relied on the broken older behavior; more details in its entry below. + [PR #2371] - nut-usbinfo.pl, nut-scanner and libnutscan: * Library API version for `libnutscan` was bumped from 2.2.0 to 2.5.0 From 3abb88f4d70934b9ffd38e93fd23bcbd02406937 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 09:59:14 +0200 Subject: [PATCH 087/325] docs/maintainer-guide.txt: update release instructions, fix typos Signed-off-by: Jim Klimov --- docs/maintainer-guide.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/maintainer-guide.txt b/docs/maintainer-guide.txt index 51c7561ab4..7b0014f5ce 100644 --- a/docs/maintainer-guide.txt +++ b/docs/maintainer-guide.txt @@ -88,7 +88,7 @@ MAINTAINER SANDBOX (to be completed and pushed) * clean up "in-development" bits from files, e.g.: ** TODO etc. referring planned future in the `NEWS.adoc` and `UPDATING.adoc` - files + files - except for the upcoming release ** comment away the top-most (auto-resolved) NUT version and build date in `docs/docinfo.xml.in` -- DO NOT add (or at least commit) an entry for the actual fixed release version and date just yet @@ -104,9 +104,11 @@ MAINTAINER SANDBOX (to be completed and pushed) any recent changes to drivers (including `main.c` and other major impact from common code) and sub-drivers (`*-hid.c` for `usbhid-ups`, `*-mib.c` for `snmp-ups`, `nutdrv_qx_*` etc.) have been reflected in bumps to their - `DRIVER_VERSION` or equivalen macros + `DRIVER_VERSION` or equivalent macros ** ideally maintained during development, as features are getting merged for community testing and future development baseline in the master branch +** this is the good time to remove the `PLANNED` status from the upcoming + release info section title * NOTE that the `ChangeLog` file is currently not tracked in SCM * update this document: `docs/maintainer-guide.txt` as it inevitably requires * commit these finishing touches @@ -158,7 +160,8 @@ MAINTAINER SANDBOX (to be completed and pushed) * post-release update of the "in-development" codebase: ** maybe update nut/configure.ac version to .1 (ex: 2.8.0.1) ** `git revert` the commit which cleaned up "in-development" bits above -** Possibly resolve relevant merge conflicts for the changed context +** Possibly resolve relevant merge conflicts for the changed context, + e.g. the changed "PLANNED" status of the now-issued release info * push commits and tag From 4c9396e0221022950e211d960372a241634788be Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 10:06:17 +0200 Subject: [PATCH 088/325] docs/maintainer-guide.txt: top note about (not-)spellchecking this doc Signed-off-by: Jim Klimov --- docs/maintainer-guide.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/maintainer-guide.txt b/docs/maintainer-guide.txt index 7b0014f5ce..6f10f9cb1f 100644 --- a/docs/maintainer-guide.txt +++ b/docs/maintainer-guide.txt @@ -6,6 +6,10 @@ ____________________ Introduction ============ +////////////////////////////////////////////////////////////////////////////// +NOTE: This file is currently not delivered in tarballs nor spellchecked. +////////////////////////////////////////////////////////////////////////////// + ... Mailing lists administration From fc9d6211b46955ce7961536cac53a2e10e248584 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 10:10:03 +0200 Subject: [PATCH 089/325] NEWS.adoc, UPGRADING.adoc, docs/docinfo.xml.in: finalize text before NUT v2.8.2 release Signed-off-by: Jim Klimov --- NEWS.adoc | 27 --------------------------- UPGRADING.adoc | 6 ------ docs/docinfo.xml.in | 2 ++ 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index cddd558d64..e852491806 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -13,33 +13,6 @@ ChangeLog file (generated for release archives), or to the Git version control history for "live" codebase. -PLANNED: Release notes for NUT 2.8.4 - what's new since 2.8.3 -------------------------------------------------------------- - -https://github.com/networkupstools/nut/milestone/9 - - - (expected) Dynamic Mapping Files (DMF) feature supported, to allow - the driver binaries to be built once and data mappings to be loaded - and modernized on the fly [Ported from 42ITy project] - - -PLANNED: Release notes for NUT 2.8.3 - what's new since 2.8.2 -------------------------------------------------------------- - -https://github.com/networkupstools/nut/milestone/11 - - - (expected) clean-up of libusb API variants support [#300 and follow-ups] - - - (expected) CI automation for coding style - - - (expected) CI automation for use of data points in drivers that conform - to patterns defined in link:docs/nut-names.txt[] - - - (expected) Porting of performance and bug fixes from 42ITy project - - - (expected) Bug fixes for fallout possible due to "fightwarn" effort in 2.8.0 - - PLANNED: Release notes for NUT 2.8.2 - what's new since 2.8.1 ------------------------------------------------------------- diff --git a/UPGRADING.adoc b/UPGRADING.adoc index fbbac8b3df..522727b426 100644 --- a/UPGRADING.adoc +++ b/UPGRADING.adoc @@ -21,12 +21,6 @@ be beneficial to add `--enable-option-checking=fatal` to the `./configure` command line, in order to quickly pick up any other removed option flags. ====== -Changes from 2.8.2 to 2.8.3 ---------------------------- - -- PLANNED: Keep track of any further API clean-up? - - Changes from 2.8.1 to 2.8.2 --------------------------- diff --git a/docs/docinfo.xml.in b/docs/docinfo.xml.in index 20284705e6..0ad2acf5da 100644 --- a/docs/docinfo.xml.in +++ b/docs/docinfo.xml.in @@ -1,6 +1,7 @@ + + + 2.8.2 + 2024-04-01 + JK + + Some changes to docs and recipes, libnutscan API and functionality. + Added nutconf (library and tool). Fixed some regressions and added + improvements for certain new device series. + + + 2.8.1 2023-10-31 diff --git a/scripts/Windows/build-mingw-nut.sh b/scripts/Windows/build-mingw-nut.sh index bafccc0ab4..a213f2bbb2 100755 --- a/scripts/Windows/build-mingw-nut.sh +++ b/scripts/Windows/build-mingw-nut.sh @@ -24,7 +24,7 @@ DLLLDD_SOURCED=true . "${SCRIPTDIR}/dllldd.sh" # This should match the tarball and directory name, # if a stable version is used: -[ -n "$VER_OPT" ] || VER_OPT=2.8.1 +[ -n "$VER_OPT" ] || VER_OPT=2.8.2 DEBUG=true # default to 32bits build From f53a2354c5700a1ebafbaa425caf115c4b1cec49 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 14:10:04 +0200 Subject: [PATCH 092/325] docs/maintainer-guide.txt: example command fix Signed-off-by: Jim Klimov --- docs/maintainer-guide.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/maintainer-guide.txt b/docs/maintainer-guide.txt index 6f10f9cb1f..51219fd66d 100644 --- a/docs/maintainer-guide.txt +++ b/docs/maintainer-guide.txt @@ -148,7 +148,7 @@ MAINTAINER SANDBOX (to be completed and pushed) ---- * create a GPG-signed tag v (ex: v2.8.0): ---- -:; git tag -sm 'Release NUT v2.8.0' +:; git tag -sm 'Release NUT v2.8.0' v2.8.0 ---- ** try to avoid adding signed tags later (ex. v2.8.0-signed) to avoid the mess in GitHub release URLs (or do amend that post-factum), for more From 350271b35ba8513ceba5618afa471c9c6a632642 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 14:11:19 +0200 Subject: [PATCH 093/325] docs/maintainer-guide.txt: example command for tag remake Signed-off-by: Jim Klimov --- docs/maintainer-guide.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/maintainer-guide.txt b/docs/maintainer-guide.txt index 51219fd66d..37777e929d 100644 --- a/docs/maintainer-guide.txt +++ b/docs/maintainer-guide.txt @@ -150,6 +150,7 @@ MAINTAINER SANDBOX (to be completed and pushed) ---- :; git tag -sm 'Release NUT v2.8.0' v2.8.0 ---- +** in case of second thoughts, `git tag -d v2.8.0` and retry later ** try to avoid adding signed tags later (ex. v2.8.0-signed) to avoid the mess in GitHub release URLs (or do amend that post-factum), for more details see e.g. https://github.com/networkupstools/nut/issues/1971 From f2458d310b41bd98a76065fb477e78c7eb86adea Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 19:29:34 +0000 Subject: [PATCH 094/325] Makefile.am: avoid parallelizing "doc" and "all-recursive" just in case (only follow up by "make doc") Maybe this is behind duplicate man page builds which tend to step on each other's toes. Signed-off-by: Jim Klimov --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 08de3eb46a..7153c9e558 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,8 @@ # missing e.g. PDF and HTML which then pop up in `make check` footprint, # or misses a .prep-src-docs stage needed to pattern-make man page files # with some "make" implementations... -all all-am-local all-local: doc all-recursive +all all-am-local all-local: all-recursive + +@$(MAKE) $(AM_MAKEFLAGS) doc +@$(MAKE) $(AM_MAKEFLAGS) doc # include directory for aclocal From 8486a450d05e925e8fa597aaee8f5b66227744a2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 22:06:31 +0200 Subject: [PATCH 095/325] docs/maintainer-guide.txt: update instruction Signed-off-by: Jim Klimov --- docs/maintainer-guide.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/maintainer-guide.txt b/docs/maintainer-guide.txt index 37777e929d..dddd09baf6 100644 --- a/docs/maintainer-guide.txt +++ b/docs/maintainer-guide.txt @@ -123,7 +123,7 @@ MAINTAINER SANDBOX (to be completed and pushed) ** revise `.github/workflows/PyNUTClient.yml` for fallback `TAG_NAME` naming ** revise `appveyor.yml` for branch naming ** revise `scripts/Windows/build-mingw-nut.sh` for fallback value of `VER_OPT` -** update version to (ex: 2.8.0) in `configure.ac` +** update version to (ex: 2.8.0) in `configure.ac` ** commit with a relevant release message, e.g.: ---- :; git commit -sm 'Update versions for release of NUT v2.8.0' From 440ca2348e665abf3787c30bdcd9373b479f4efc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 22:07:23 +0200 Subject: [PATCH 096/325] configure.ac: mark exact NUT v2.8.2 release Happy Fools' Day! Signed-off-by: Jim Klimov --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ed24101cb0..cffd288da8 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ dnl +------------------------------------------------------------------+ dnl NUT version number is defined here, with a Git suffixed macro like dnl NUT_VERSION_MACRO "2.7.4-2838-gdfc3ac08" dnl in include/nut_version.h (generated by make) -AC_INIT([nut],[2.8.2.1],[https://github.com/networkupstools/nut/issues]) +AC_INIT([nut],[2.8.2],[https://github.com/networkupstools/nut/issues]) dnl See docs/maintainer-guide.txt about releases - updating the version dnl above is a small part of the consistent ritual! From 09367182860150e3d287abeea0d300237685f9d5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 1 Apr 2024 22:45:08 +0200 Subject: [PATCH 097/325] Revert "NEWS.adoc, UPGRADING.adoc, docs/docinfo.xml.in: finalize text before NUT v2.8.2 release" This reverts commit fc9d6211b46955ce7961536cac53a2e10e248584. Signed-off-by: Jim Klimov --- NEWS.adoc | 27 +++++++++++++++++++++++++++ UPGRADING.adoc | 6 ++++++ docs/docinfo.xml.in | 2 -- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index b46a18411a..44779d61ad 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -13,6 +13,33 @@ ChangeLog file (generated for release archives), or to the Git version control history for "live" codebase. +PLANNED: Release notes for NUT 2.8.4 - what's new since 2.8.3 +------------------------------------------------------------- + +https://github.com/networkupstools/nut/milestone/9 + + - (expected) Dynamic Mapping Files (DMF) feature supported, to allow + the driver binaries to be built once and data mappings to be loaded + and modernized on the fly [Ported from 42ITy project] + + +PLANNED: Release notes for NUT 2.8.3 - what's new since 2.8.2 +------------------------------------------------------------- + +https://github.com/networkupstools/nut/milestone/11 + + - (expected) clean-up of libusb API variants support [#300 and follow-ups] + + - (expected) CI automation for coding style + + - (expected) CI automation for use of data points in drivers that conform + to patterns defined in link:docs/nut-names.txt[] + + - (expected) Porting of performance and bug fixes from 42ITy project + + - (expected) Bug fixes for fallout possible due to "fightwarn" effort in 2.8.0 + + Release notes for NUT 2.8.2 - what's new since 2.8.1 ---------------------------------------------------- diff --git a/UPGRADING.adoc b/UPGRADING.adoc index 522727b426..fbbac8b3df 100644 --- a/UPGRADING.adoc +++ b/UPGRADING.adoc @@ -21,6 +21,12 @@ be beneficial to add `--enable-option-checking=fatal` to the `./configure` command line, in order to quickly pick up any other removed option flags. ====== +Changes from 2.8.2 to 2.8.3 +--------------------------- + +- PLANNED: Keep track of any further API clean-up? + + Changes from 2.8.1 to 2.8.2 --------------------------- diff --git a/docs/docinfo.xml.in b/docs/docinfo.xml.in index 2b5bd63724..ea0c5fcee0 100644 --- a/docs/docinfo.xml.in +++ b/docs/docinfo.xml.in @@ -1,7 +1,6 @@ -