From a5e3f40a26d1241ab48a4ee0ec6a1a7742905d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Kova=C4=8Di=C4=8D?= Date: Thu, 2 Jul 2020 20:16:15 +0000 Subject: [PATCH 01/22] drivers: delta-hid: Add Delta HID subdriver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delta HID subdriver is added to support Delta RT Series, Single Phase, 1/2/3 kVA UPS devices. The driver was tested and tweaked on Delta RT 3 kVA UPS. Signed-off-by: Luka Kovačič --- drivers/Makefile.am | 4 +- drivers/delta-hid.c | 188 +++++++++++++++++++++++++++++ drivers/delta-hid.h | 30 +++++ drivers/usbhid-ups.c | 2 + scripts/upower/95-upower-hid.rules | 4 + 5 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 drivers/delta-hid.c create mode 100644 drivers/delta-hid.h diff --git a/drivers/Makefile.am b/drivers/Makefile.am index 1251ff2850..fc6ff946cc 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -175,7 +175,7 @@ skel_LDADD = $(LDADD_DRIVERS) # USB USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c explore-hid.c \ liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \ - openups-hid.c + openups-hid.c delta-hid.c usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \ usb-common.c $(USBHID_UPS_SUBDRIVERS) usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm @@ -285,7 +285,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \ xppc-mib.h huawei-mib.h eaton-ats16-mib.h apc-ats-mib.h raritan-px2-mib.h eaton-ats30-mib.h \ apc-pdu-mib.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h \ eaton-pdu-pulizzi-mib.h eaton-pdu-revelation-mib.h emerson-avocent-pdu-mib.h \ - hpe-pdu-mib.h + hpe-pdu-mib.h delta-hid.h # Define a dummy library so that Automake builds rules for the # corresponding object files. This library is not actually built, diff --git a/drivers/delta-hid.c b/drivers/delta-hid.c new file mode 100644 index 0000000000..cf8b7eb0cc --- /dev/null +++ b/drivers/delta-hid.c @@ -0,0 +1,188 @@ +/* delta-hid.c - subdriver to monitor Delta USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2012 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * 2013 Charles Lepple + * 2020 Luka Kovacic + * + * 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 "usbhid-ups.h" +#include "delta-hid.h" +#include "main.h" /* for getval() */ +#include "usb-common.h" + +#define DELTA_HID_VERSION "Delta HID 0.5" + +/* Delta Vendor ID */ +#define DELTA_VENDORID 0x05dd + +/* USB IDs device table */ +static usb_device_id_t delta_usb_device_table[] = { + /* Delta RT Series, Single Phase, 1/2/3 kVA */ + { USB_DEVICE(DELTA_VENDORID, 0x041b), NULL }, + + /* Terminating entry */ + { -1, -1, NULL } +}; + + +/* --------------------------------------------------------------- */ +/* Vendor-specific usage table */ +/* --------------------------------------------------------------- */ + +/* DELTA usage table */ +static usage_lkp_t delta_usage_lkp[] = { + { "DELTA1", 0x00000000 }, + { "DELTA2", 0xff000055 }, + { "DELTA3", 0xffff0010 }, + { "DELTA4", 0xffff0056 }, + { "DELTA5", 0xffff0057 }, + { "DELTA6", 0xffff0058 }, + { "DELTA7", 0xffff0059 }, + { "DELTA8", 0xffff005a }, + { "DELTA9", 0xffff0060 }, + { "DELTA10", 0xffff0061 }, + { "DELTA11", 0xffff0062 }, + { "DELTA12", 0xffff0063 }, + { "DELTA13", 0xffff0064 }, + { "DELTA14", 0xffff0065 }, + { "DELTA15", 0xffff0066 }, + { "DELTA16", 0xffff0067 }, + { "DELTA17", 0xffff0068 }, + { "DELTA18", 0xffff0075 }, + { "DELTA19", 0xffff0076 }, + { "DELTA20", 0xffff007c }, + { "DELTA21", 0xffff007d }, + { "DELTA22", 0xffff0081 }, + { "DELTA23", 0xffff0091 }, + { "DELTA24", 0xffff0092 }, + { "DELTA25", 0xffff0093 }, + { "DELTA26", 0xffff0094 }, + { "DELTA27", 0xffff0095 }, + { "DELTA28", 0xffff0096 }, + { "DELTA29", 0xffff0097 }, + { "DELTA30", 0xffff0098 }, + { "DELTA31", 0xffff0099 }, + { "DELTA32", 0xffff009a }, + { "DELTA33", 0xffff009b }, + { "DELTA34", 0xffff009c }, + { NULL, 0 } +}; + +static usage_tables_t delta_utab[] = { + delta_usage_lkp, + hid_usage_lkp, + NULL, +}; + +/* --------------------------------------------------------------- */ +/* HID2NUT lookup table */ +/* --------------------------------------------------------------- */ + +static hid_info_t delta_hid2nut[] = { + + { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", 0, NULL }, + { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", 0, kelvin_celsius_conversion }, + { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, + { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, + { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", 0, NULL }, + { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", 0, NULL }, + { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", 0, NULL }, + { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", 0, NULL }, + { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", 0, NULL }, + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", 0, NULL }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", 0, NULL }, + { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", 0, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, 0, boost_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, 0, trim_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, 0, overload_info }, + { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", 0, beeper_info }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, + { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", 0, NULL }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, + { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", 0, NULL }, + { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, + { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL }, + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", 0, stringid_conversion }, + { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", 0, stringid_conversion }, + { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", 0, stringid_conversion }, + { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", 0, stringid_conversion }, + + /* end of structure. */ + { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } +}; + +static const char *delta_format_model(HIDDevice_t *hd) { + return hd->Product; +} + +static const char *delta_format_mfr(HIDDevice_t *hd) { + return hd->Vendor ? hd->Vendor : "Delta"; +} + +static const char *delta_format_serial(HIDDevice_t *hd) { + return hd->Serial; +} + +/* this function allows the subdriver to "claim" a device: return 1 if + * the device is supported by this subdriver, else 0. */ +static int delta_claim(HIDDevice_t *hd) +{ + int status = is_usb_device_supported(delta_usb_device_table, hd); + + switch (status) + { + case POSSIBLY_SUPPORTED: + /* by default, reject, unless the productid option is given */ + if (getval("productid")) { + return 1; + } + possibly_supported("Delta", hd); + return 0; + + case SUPPORTED: + return 1; + + case NOT_SUPPORTED: + default: + return 0; + } +} + +subdriver_t delta_subdriver = { + DELTA_HID_VERSION, + delta_claim, + delta_utab, + delta_hid2nut, + delta_format_model, + delta_format_mfr, + delta_format_serial, +}; diff --git a/drivers/delta-hid.h b/drivers/delta-hid.h new file mode 100644 index 0000000000..d94c15847d --- /dev/null +++ b/drivers/delta-hid.h @@ -0,0 +1,30 @@ +/* delta-hid.h - subdriver to monitor Delta USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2009 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * + * 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 + */ + +#ifndef DELTA_HID_H +#define DELTA_HID_H + +#include "usbhid-ups.h" + +extern subdriver_t delta_subdriver; + +#endif /* DELTA_HID_H */ diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index ea198c4db9..cdf27476f8 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -44,6 +44,7 @@ #include "apc-hid.h" #include "belkin-hid.h" #include "cps-hid.h" + #include "delta-hid.h" #include "liebert-hid.h" #include "powercom-hid.h" #include "tripplite-hid.h" @@ -61,6 +62,7 @@ static subdriver_t *subdriver_list[] = { &apc_subdriver, &belkin_subdriver, &cps_subdriver, + &delta_subdriver, &liebert_subdriver, &powercom_subdriver, &tripplite_subdriver, diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules index 4f9c379a43..0b324b2ee8 100644 --- a/scripts/upower/95-upower-hid.rules +++ b/scripts/upower/95-upower-hid.rules @@ -28,6 +28,7 @@ ATTRS{idVendor}=="04d8", ENV{UPOWER_VENDOR}="Minibox" ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin" ATTRS{idVendor}=="051d", ENV{UPOWER_VENDOR}="APC" ATTRS{idVendor}=="0592", ENV{UPOWER_VENDOR}="Powerware" +ATTRS{idVendor}=="05dd", ENV{UPOWER_VENDOR}="Delta" ATTRS{idVendor}=="06da", ENV{UPOWER_VENDOR}="Phoenixtec Power Co., Ltd" ATTRS{idVendor}=="075d", ENV{UPOWER_VENDOR}="iDowell" ATTRS{idVendor}=="0764", ENV{UPOWER_VENDOR}="Cyber Power Systems" @@ -85,6 +86,9 @@ ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0003", ENV{UPOWER_BATTERY_TYPE}="ups # Powerware ATTRS{idVendor}=="0592", ATTRS{idProduct}=="0004", ENV{UPOWER_BATTERY_TYPE}="ups" +# Delta +ATTRS{idVendor}=="05dd", ATTRS{idProduct}=="041b", ENV{UPOWER_BATTERY_TYPE}="ups" + # Phoenixtec Power Co., Ltd ATTRS{idVendor}=="06da", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" From 00acf84b8c985e6a68dd576f09d2e57a8741da57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Kova=C4=8Di=C4=8D?= Date: Tue, 21 Jul 2020 07:38:35 +0000 Subject: [PATCH 02/22] drivers: delta-hid: Update entry flags appropriately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update entry flags to use HU_FLAG_QUICK_POLL for status and alarm variables, HU_FLAG_SEMI_STATIC for variables that can change on user changes and HU_FLAG_STATIC for variables that don't need to be updated after init. Signed-off-by: Luka Kovačič --- drivers/delta-hid.c | 66 ++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/delta-hid.c b/drivers/delta-hid.c index cf8b7eb0cc..977a4e547f 100644 --- a/drivers/delta-hid.c +++ b/drivers/delta-hid.c @@ -97,44 +97,44 @@ static usage_tables_t delta_utab[] = { static hid_info_t delta_hid2nut[] = { - { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", 0, NULL }, - { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", 0, NULL }, - { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", 0, kelvin_celsius_conversion }, + { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, - { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, - { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, - { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, - { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", 0, NULL }, - { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", 0, NULL }, - { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", 0, NULL }, - { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", 0, NULL }, - { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", 0, NULL }, - { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", 0, NULL }, - { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", 0, NULL }, - { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", 0, NULL }, - { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, - { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, 0, boost_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, 0, trim_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, 0, overload_info }, - { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", 0, beeper_info }, - { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, - { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", 0, NULL }, - { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", 0, NULL }, + { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, + { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, - { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, - { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", 0, NULL }, - { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, - { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL }, - { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", 0, stringid_conversion }, - { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", 0, stringid_conversion }, - { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", 0, stringid_conversion }, - { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", 0, stringid_conversion }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, replacebatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info }, + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, /* end of structure. */ { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } From 863c8bd24fc6b3b18034177cfa435e8d6abee979 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 20 Apr 2021 21:46:12 +0200 Subject: [PATCH 03/22] Update delta-hid.c Sync the vendor-name comment (for udev generation among others) with another Delta HID driver merged to master recently. --- drivers/delta-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/delta-hid.c b/drivers/delta-hid.c index 977a4e547f..1f6096b607 100644 --- a/drivers/delta-hid.c +++ b/drivers/delta-hid.c @@ -29,7 +29,7 @@ #define DELTA_HID_VERSION "Delta HID 0.5" -/* Delta Vendor ID */ +/* Delta UPS */ #define DELTA_VENDORID 0x05dd /* USB IDs device table */ From 67c2df590f452077ea49a631c8866e8b55db4a21 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 13:59:50 +0200 Subject: [PATCH 04/22] Rename delta-hid.c/.h to delta_ups-hid.c/.h and sync vendor label for USB [#807] --- drivers/Makefile.am | 4 ++-- drivers/{delta-hid.c => delta_ups-hid.c} | 6 +++--- drivers/{delta-hid.h => delta_ups-hid.h} | 2 +- drivers/usbhid-ups.c | 2 +- scripts/upower/95-upower-hid.rules | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) rename drivers/{delta-hid.c => delta_ups-hid.c} (98%) rename drivers/{delta-hid.h => delta_ups-hid.h} (93%) diff --git a/drivers/Makefile.am b/drivers/Makefile.am index 851b88b484..bfcdebefa8 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -175,7 +175,7 @@ skel_LDADD = $(LDADD_DRIVERS) # USB USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c explore-hid.c \ liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \ - openups-hid.c delta-hid.c + openups-hid.c delta_ups-hid.c usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \ usb-common.c $(USBHID_UPS_SUBDRIVERS) usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm @@ -287,7 +287,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h bcmxcp_ser.h \ xppc-mib.h huawei-mib.h eaton-ats16-mib.h apc-ats-mib.h raritan-px2-mib.h eaton-ats30-mib.h \ apc-pdu-mib.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h \ eaton-pdu-pulizzi-mib.h eaton-pdu-revelation-mib.h emerson-avocent-pdu-mib.h \ - hpe-pdu-mib.h delta-hid.h + hpe-pdu-mib.h delta_ups-hid.h # Define a dummy library so that Automake builds rules for the # corresponding object files. This library is not actually built, diff --git a/drivers/delta-hid.c b/drivers/delta_ups-hid.c similarity index 98% rename from drivers/delta-hid.c rename to drivers/delta_ups-hid.c index 977a4e547f..1847ffa246 100644 --- a/drivers/delta-hid.c +++ b/drivers/delta_ups-hid.c @@ -1,4 +1,4 @@ -/* delta-hid.c - subdriver to monitor Delta USB/HID devices with NUT +/* delta_ups-hid.c - subdriver to monitor Delta USB/HID devices with NUT * * Copyright (C) * 2003 - 2012 Arnaud Quette @@ -23,13 +23,13 @@ */ #include "usbhid-ups.h" -#include "delta-hid.h" +#include "delta_ups-hid.h" #include "main.h" /* for getval() */ #include "usb-common.h" #define DELTA_HID_VERSION "Delta HID 0.5" -/* Delta Vendor ID */ +/* Delta UPS */ #define DELTA_VENDORID 0x05dd /* USB IDs device table */ diff --git a/drivers/delta-hid.h b/drivers/delta_ups-hid.h similarity index 93% rename from drivers/delta-hid.h rename to drivers/delta_ups-hid.h index d94c15847d..43695522ed 100644 --- a/drivers/delta-hid.h +++ b/drivers/delta_ups-hid.h @@ -1,4 +1,4 @@ -/* delta-hid.h - subdriver to monitor Delta USB/HID devices with NUT +/* delta_ups-hid.h - subdriver to monitor Delta USB/HID devices with NUT * * Copyright (C) * 2003 - 2009 Arnaud Quette diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index b50496d305..39e059fa6f 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -44,7 +44,7 @@ #include "apc-hid.h" #include "belkin-hid.h" #include "cps-hid.h" - #include "delta-hid.h" + #include "delta_ups-hid.h" #include "liebert-hid.h" #include "powercom-hid.h" #include "tripplite-hid.h" diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules index 0b324b2ee8..c2262095ca 100644 --- a/scripts/upower/95-upower-hid.rules +++ b/scripts/upower/95-upower-hid.rules @@ -28,7 +28,7 @@ ATTRS{idVendor}=="04d8", ENV{UPOWER_VENDOR}="Minibox" ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin" ATTRS{idVendor}=="051d", ENV{UPOWER_VENDOR}="APC" ATTRS{idVendor}=="0592", ENV{UPOWER_VENDOR}="Powerware" -ATTRS{idVendor}=="05dd", ENV{UPOWER_VENDOR}="Delta" +ATTRS{idVendor}=="05dd", ENV{UPOWER_VENDOR}="Delta UPS" ATTRS{idVendor}=="06da", ENV{UPOWER_VENDOR}="Phoenixtec Power Co., Ltd" ATTRS{idVendor}=="075d", ENV{UPOWER_VENDOR}="iDowell" ATTRS{idVendor}=="0764", ENV{UPOWER_VENDOR}="Cyber Power Systems" @@ -86,7 +86,7 @@ ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0003", ENV{UPOWER_BATTERY_TYPE}="ups # Powerware ATTRS{idVendor}=="0592", ATTRS{idProduct}=="0004", ENV{UPOWER_BATTERY_TYPE}="ups" -# Delta +# Delta UPS ATTRS{idVendor}=="05dd", ATTRS{idProduct}=="041b", ENV{UPOWER_BATTERY_TYPE}="ups" # Phoenixtec Power Co., Ltd From 1476fdae5e2a95162efbc4be8cb1b11d03d8f9c2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:16:55 +0200 Subject: [PATCH 05/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: rename delta => delta_ups, sync comments --- drivers/delta_ups-hid.c | 52 +++++++++++++++++++++-------------------- drivers/delta_ups-hid.h | 11 +++++---- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 1847ffa246..2e05876652 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -1,4 +1,4 @@ -/* delta_ups-hid.c - subdriver to monitor Delta USB/HID devices with NUT +/* delta_ups-hid.c - data mapping subdriver to monitor Delta UPS USB/HID devices with NUT * * Copyright (C) * 2003 - 2012 Arnaud Quette @@ -6,6 +6,7 @@ * 2008 - 2009 Arjen de Korte * 2013 Charles Lepple * 2020 Luka Kovacic + * 2021 Jungeon Kim * * 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 @@ -27,15 +28,16 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define DELTA_HID_VERSION "Delta HID 0.5" +#define DELTA_UPS_HID_VERSION "Delta UPS HID 0.5" /* Delta UPS */ -#define DELTA_VENDORID 0x05dd +#define DELTA_UPS_VENDORID 0x05dd /* USB IDs device table */ -static usb_device_id_t delta_usb_device_table[] = { +static usb_device_id_t delta_ups_usb_device_table[] = { /* Delta RT Series, Single Phase, 1/2/3 kVA */ - { USB_DEVICE(DELTA_VENDORID, 0x041b), NULL }, + /* Delta UPS Amplon R Series, Single Phase UPS, 1/2/3 kVA */ + { USB_DEVICE(DELTA_UPS_VENDORID, 0x041b), NULL }, /* Terminating entry */ { -1, -1, NULL } @@ -47,7 +49,7 @@ static usb_device_id_t delta_usb_device_table[] = { /* --------------------------------------------------------------- */ /* DELTA usage table */ -static usage_lkp_t delta_usage_lkp[] = { +static usage_lkp_t delta_ups_usage_lkp[] = { { "DELTA1", 0x00000000 }, { "DELTA2", 0xff000055 }, { "DELTA3", 0xffff0010 }, @@ -82,11 +84,13 @@ static usage_lkp_t delta_usage_lkp[] = { { "DELTA32", 0xffff009a }, { "DELTA33", 0xffff009b }, { "DELTA34", 0xffff009c }, - { NULL, 0 } + + /* Terminating entry */ + { NULL, 0 } }; -static usage_tables_t delta_utab[] = { - delta_usage_lkp, +static usage_tables_t delta_ups_utab[] = { + delta_ups_usage_lkp, hid_usage_lkp, NULL, }; @@ -95,8 +99,7 @@ static usage_tables_t delta_utab[] = { /* HID2NUT lookup table */ /* --------------------------------------------------------------- */ -static hid_info_t delta_hid2nut[] = { - +static hid_info_t delta_ups_hid2nut[] = { { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, @@ -140,23 +143,22 @@ static hid_info_t delta_hid2nut[] = { { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } }; -static const char *delta_format_model(HIDDevice_t *hd) { +static const char *delta_ups_format_model(HIDDevice_t *hd) { return hd->Product; } -static const char *delta_format_mfr(HIDDevice_t *hd) { +static const char *delta_ups_format_mfr(HIDDevice_t *hd) { return hd->Vendor ? hd->Vendor : "Delta"; } -static const char *delta_format_serial(HIDDevice_t *hd) { +static const char *delta_ups_format_serial(HIDDevice_t *hd) { return hd->Serial; } /* this function allows the subdriver to "claim" a device: return 1 if * the device is supported by this subdriver, else 0. */ -static int delta_claim(HIDDevice_t *hd) -{ - int status = is_usb_device_supported(delta_usb_device_table, hd); +static int delta_ups_claim(HIDDevice_t *hd) { + int status = is_usb_device_supported(delta_ups_usb_device_table, hd); switch (status) { @@ -177,12 +179,12 @@ static int delta_claim(HIDDevice_t *hd) } } -subdriver_t delta_subdriver = { - DELTA_HID_VERSION, - delta_claim, - delta_utab, - delta_hid2nut, - delta_format_model, - delta_format_mfr, - delta_format_serial, +subdriver_t delta_ups_subdriver = { + DELTA_UPS_HID_VERSION, + delta_ups_claim, + delta_ups_utab, + delta_ups_hid2nut, + delta_ups_format_model, + delta_ups_format_mfr, + delta_ups_format_serial, }; diff --git a/drivers/delta_ups-hid.h b/drivers/delta_ups-hid.h index 43695522ed..b87fc57201 100644 --- a/drivers/delta_ups-hid.h +++ b/drivers/delta_ups-hid.h @@ -1,9 +1,10 @@ -/* delta_ups-hid.h - subdriver to monitor Delta USB/HID devices with NUT +/* delta_ups-hid.h - data mapping subdriver to monitor Delta UPS USB/HID devices with NUT * * Copyright (C) * 2003 - 2009 Arnaud Quette * 2005 - 2006 Peter Selinger * 2008 - 2009 Arjen de Korte + * 2021 Jungeon Kim * * 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 @@ -20,11 +21,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DELTA_HID_H -#define DELTA_HID_H +#ifndef DELTA_UPS_HID_H +#define DELTA_UPS_HID_H #include "usbhid-ups.h" -extern subdriver_t delta_subdriver; +extern subdriver_t delta_ups_subdriver; -#endif /* DELTA_HID_H */ +#endif /* DELTA_UPS_HID_H */ From 5a2617f12998950fd4a1727c2f130d5c4dd4c470 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:20:29 +0200 Subject: [PATCH 06/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: indentations in delta_ups_usage_lkp[] --- drivers/delta_ups-hid.c | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 2e05876652..77f1f8220c 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -50,40 +50,40 @@ static usb_device_id_t delta_ups_usb_device_table[] = { /* DELTA usage table */ static usage_lkp_t delta_ups_usage_lkp[] = { - { "DELTA1", 0x00000000 }, - { "DELTA2", 0xff000055 }, - { "DELTA3", 0xffff0010 }, - { "DELTA4", 0xffff0056 }, - { "DELTA5", 0xffff0057 }, - { "DELTA6", 0xffff0058 }, - { "DELTA7", 0xffff0059 }, - { "DELTA8", 0xffff005a }, - { "DELTA9", 0xffff0060 }, - { "DELTA10", 0xffff0061 }, - { "DELTA11", 0xffff0062 }, - { "DELTA12", 0xffff0063 }, - { "DELTA13", 0xffff0064 }, - { "DELTA14", 0xffff0065 }, - { "DELTA15", 0xffff0066 }, - { "DELTA16", 0xffff0067 }, - { "DELTA17", 0xffff0068 }, - { "DELTA18", 0xffff0075 }, - { "DELTA19", 0xffff0076 }, - { "DELTA20", 0xffff007c }, - { "DELTA21", 0xffff007d }, - { "DELTA22", 0xffff0081 }, - { "DELTA23", 0xffff0091 }, - { "DELTA24", 0xffff0092 }, - { "DELTA25", 0xffff0093 }, - { "DELTA26", 0xffff0094 }, - { "DELTA27", 0xffff0095 }, - { "DELTA28", 0xffff0096 }, - { "DELTA29", 0xffff0097 }, - { "DELTA30", 0xffff0098 }, - { "DELTA31", 0xffff0099 }, - { "DELTA32", 0xffff009a }, - { "DELTA33", 0xffff009b }, - { "DELTA34", 0xffff009c }, + { "DELTA1", 0x00000000 }, + { "DELTA2", 0xff000055 }, + { "DELTA3", 0xffff0010 }, + { "DELTA4", 0xffff0056 }, + { "DELTA5", 0xffff0057 }, + { "DELTA6", 0xffff0058 }, + { "DELTA7", 0xffff0059 }, + { "DELTA8", 0xffff005a }, + { "DELTA9", 0xffff0060 }, + { "DELTA10", 0xffff0061 }, + { "DELTA11", 0xffff0062 }, + { "DELTA12", 0xffff0063 }, + { "DELTA13", 0xffff0064 }, + { "DELTA14", 0xffff0065 }, + { "DELTA15", 0xffff0066 }, + { "DELTA16", 0xffff0067 }, + { "DELTA17", 0xffff0068 }, + { "DELTA18", 0xffff0075 }, + { "DELTA19", 0xffff0076 }, + { "DELTA20", 0xffff007c }, + { "DELTA21", 0xffff007d }, + { "DELTA22", 0xffff0081 }, + { "DELTA23", 0xffff0091 }, + { "DELTA24", 0xffff0092 }, + { "DELTA25", 0xffff0093 }, + { "DELTA26", 0xffff0094 }, + { "DELTA27", 0xffff0095 }, + { "DELTA28", 0xffff0096 }, + { "DELTA29", 0xffff0097 }, + { "DELTA30", 0xffff0098 }, + { "DELTA31", 0xffff0099 }, + { "DELTA32", 0xffff009a }, + { "DELTA33", 0xffff009b }, + { "DELTA34", 0xffff009c }, /* Terminating entry */ { NULL, 0 } From 8f29d2674fb6540515ec745d3c95331806e2d928 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:20:45 +0200 Subject: [PATCH 07/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: indentations in delta_ups_hid2nut[] --- drivers/delta_ups-hid.c | 82 ++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 77f1f8220c..4f162ca2cc 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -100,47 +100,47 @@ static usage_tables_t delta_ups_utab[] = { /* --------------------------------------------------------------- */ static hid_info_t delta_ups_hid2nut[] = { - { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, - { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, - { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, - { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, - { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, replacebatt_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info }, - { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - - /* end of structure. */ - { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } + { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, + { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, + { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, + { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, replacebatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info }, + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + + /* Terminating entry */ + { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } }; static const char *delta_ups_format_model(HIDDevice_t *hd) { From a29a2c3c9f1a7536f016383b2193711235fd2973 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:21:23 +0200 Subject: [PATCH 08/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: indentations in delta_ups_claim() --- drivers/delta_ups-hid.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 4f162ca2cc..e1f0a2137f 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -160,22 +160,21 @@ static const char *delta_ups_format_serial(HIDDevice_t *hd) { static int delta_ups_claim(HIDDevice_t *hd) { int status = is_usb_device_supported(delta_ups_usb_device_table, hd); - switch (status) - { - case POSSIBLY_SUPPORTED: - /* by default, reject, unless the productid option is given */ - if (getval("productid")) { + switch (status) { + case SUPPORTED: return 1; - } - possibly_supported("Delta", hd); - return 0; - case SUPPORTED: - return 1; - - case NOT_SUPPORTED: - default: - return 0; + case POSSIBLY_SUPPORTED: + /* by default, reject, unless the productid option is given */ + if (getval("productid")) { + return 1; + } + possibly_supported("Delta", hd); + return 0; + + case NOT_SUPPORTED: + default: + return 0; } } From c4562a39a812692c989fd68e4c77002127f02f47 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:22:41 +0200 Subject: [PATCH 09/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: move delta_ups_format_model() to same position as in master --- drivers/delta_ups-hid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index e1f0a2137f..aff4745728 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -143,14 +143,14 @@ static hid_info_t delta_ups_hid2nut[] = { { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } }; -static const char *delta_ups_format_model(HIDDevice_t *hd) { - return hd->Product; -} - static const char *delta_ups_format_mfr(HIDDevice_t *hd) { return hd->Vendor ? hd->Vendor : "Delta"; } +static const char *delta_ups_format_model(HIDDevice_t *hd) { + return hd->Product; +} + static const char *delta_ups_format_serial(HIDDevice_t *hd) { return hd->Serial; } From f0f56c8d9489c9e9dd8c9ac49d146fb39996d64e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:23:05 +0200 Subject: [PATCH 10/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: import delta_ups_format_model() content from master --- drivers/delta_ups-hid.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index aff4745728..6d9220c3d9 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -148,7 +148,14 @@ static const char *delta_ups_format_mfr(HIDDevice_t *hd) { } static const char *delta_ups_format_model(HIDDevice_t *hd) { - return hd->Product; + static char model[SMALLBUF]; + HIDGetItemString(udev, "UPS.DeltaCustom.[1].DeltaModelName", model, sizeof(model), delta_ups_utab); + + if (strlen(model) < 1) { + return hd->Product; + } + + return model; } static const char *delta_ups_format_serial(HIDDevice_t *hd) { From b28bce647d86e2a8bd2f8cb97c016abc7e4a122e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:25:47 +0200 Subject: [PATCH 11/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: import named delta_ups_usage_lkp[] content from master --- drivers/delta_ups-hid.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 6d9220c3d9..bdc048adb6 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -52,14 +52,20 @@ static usb_device_id_t delta_ups_usb_device_table[] = { static usage_lkp_t delta_ups_usage_lkp[] = { { "DELTA1", 0x00000000 }, { "DELTA2", 0xff000055 }, - { "DELTA3", 0xffff0010 }, +/* { "DELTA3", 0xffff0010 }, */ + { "DeltaCustom", 0xffff0010 }, { "DELTA4", 0xffff0056 }, - { "DELTA5", 0xffff0057 }, - { "DELTA6", 0xffff0058 }, - { "DELTA7", 0xffff0059 }, - { "DELTA8", 0xffff005a }, +/* { "DELTA5", 0xffff0057 }, */ + { "DeltaConfigTransferLowMax", 0xffff0057 }, +/* { "DELTA6", 0xffff0058 }, */ + { "DeltaConfigTransferLowMin", 0xffff0058 }, +/* { "DELTA7", 0xffff0059 }, */ + { "DeltaConfigTransferHighMax", 0xffff0059 }, +/* { "DELTA8", 0xffff005a }, */ + { "DeltaConfigTransferHighMin", 0xffff005a }, { "DELTA9", 0xffff0060 }, - { "DELTA10", 0xffff0061 }, +/* { "DELTA10", 0xffff0061 }, */ + { "DeltaConfigExternalBatteryPack", 0xffff0061 }, { "DELTA11", 0xffff0062 }, { "DELTA12", 0xffff0063 }, { "DELTA13", 0xffff0064 }, @@ -67,12 +73,16 @@ static usage_lkp_t delta_ups_usage_lkp[] = { { "DELTA15", 0xffff0066 }, { "DELTA16", 0xffff0067 }, { "DELTA17", 0xffff0068 }, - { "DELTA18", 0xffff0075 }, +/* { "DELTA18", 0xffff0075 }, */ + { "DeltaModelName", 0xffff0075 }, { "DELTA19", 0xffff0076 }, - { "DELTA20", 0xffff007c }, +/* { "DELTA20", 0xffff007c }, */ + { "DeltaUPSType", 0xffff007c }, { "DELTA21", 0xffff007d }, - { "DELTA22", 0xffff0081 }, - { "DELTA23", 0xffff0091 }, +/* { "DELTA22", 0xffff0081 }, */ + { "DeltaConfigStartPowerRestoreDelay", 0xffff0081 }, +/* { "DELTA23", 0xffff0091 }, */ + { "DeltaOutputSource", 0xffff0091 }, { "DELTA24", 0xffff0092 }, { "DELTA25", 0xffff0093 }, { "DELTA26", 0xffff0094 }, @@ -82,8 +92,10 @@ static usage_lkp_t delta_ups_usage_lkp[] = { { "DELTA30", 0xffff0098 }, { "DELTA31", 0xffff0099 }, { "DELTA32", 0xffff009a }, - { "DELTA33", 0xffff009b }, - { "DELTA34", 0xffff009c }, +/* { "DELTA33", 0xffff009b }, */ + { "DeltaConfigSensitivity", 0xffff009b }, +/* { "DELTA34", 0xffff009c }, */ + { "DeltaConfigStartPowerRestore", 0xffff009c }, /* Terminating entry */ { NULL, 0 } From 42e7e085426917a383e606d8fd892bc66bd737ec Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:30:45 +0200 Subject: [PATCH 12/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: change delta_ups_hid2nut[] content order by names to be same as in master --- drivers/delta_ups-hid.c | 58 +++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index bdc048adb6..5f4346ae67 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -112,44 +112,50 @@ static usage_tables_t delta_ups_utab[] = { /* --------------------------------------------------------------- */ static hid_info_t delta_ups_hid2nut[] = { + { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, - { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, - { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + + { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, + { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, - { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, - { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, replacebatt_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info }, - { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, + + /* 10 seconds battery test */ + { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, /* Terminating entry */ { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } From 9acb236e1088933822fa7c581c14b08419237680 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 17:31:30 +0200 Subject: [PATCH 13/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: import Helper lookup tables and mapping functions from master --- drivers/delta_ups-hid.c | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 5f4346ae67..8f2e1cd313 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -107,6 +107,61 @@ static usage_tables_t delta_ups_utab[] = { NULL, }; +/* --------------------------------------------------------------- */ +/* Helper lookup tables and mapping functions */ +/* --------------------------------------------------------------- */ + +static info_lkp_t delta_ups_sensitivity_info[] = { + { 0, "normal", NULL, NULL }, + { 1, "reduced", NULL, NULL }, + { 2, "low", NULL, NULL }, + + /* Terminating entry */ + { 0, NULL, NULL, NULL } +}; + +static const char *delta_ups_type_fun(double value) +{ + static const char* upstypes[] = { + "online", + "offline", + "line-interactive", + "3-phase", + "split-phase" + }; + + int type = (int)value & 0xf; + if (type == 6) { + type = 4; + } else if (2 < type && type <= 5) { + type -= 2; + } + + if (type < 0 || type > 4) { + return NULL; + } + + return upstypes[type]; +} + +static info_lkp_t delta_ups_type_info[] = { + { 0, NULL, delta_ups_type_fun }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t delta_ups_output_source_info[] = { + { 0, "normal", NULL, NULL }, + { 1, "battery", NULL, NULL }, + { 2, "bypass/reserve", NULL, NULL }, + { 3, "reducing", NULL, NULL }, + { 4, "boosting", NULL, NULL }, + { 5, "manual bypass", NULL, NULL }, + { 6, "other", NULL, NULL }, + { 7, "no output", NULL, NULL }, + { 8, "on eco", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + /* --------------------------------------------------------------- */ /* HID2NUT lookup table */ /* --------------------------------------------------------------- */ From 8fb4a49ea30f1ae98485e8c207df5356772686de Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 20:59:25 +0200 Subject: [PATCH 14/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: import delta_ups_hid2nut[] entries "as is" --- drivers/delta_ups-hid.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 8f2e1cd313..3bf1dcdec3 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -167,20 +167,32 @@ static info_lkp_t delta_ups_output_source_info[] = { /* --------------------------------------------------------------- */ static hid_info_t delta_ups_hid2nut[] = { + { "input.sensitivity", ST_FLAG_RW, 0, "UPS.DeltaCustom.[1].DeltaConfigSensitivity", NULL, "%s", 0, delta_ups_sensitivity_info }, { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "input.transfer.low", ST_FLAG_RW, 0, "UPS.PowerConverter.Output.LowVoltageTransfer", NULL, "%.0f", 0, NULL }, + { "input.transfer.high", ST_FLAG_RW, 0, "UPS.PowerConverter.Output.HighVoltageTransfer", NULL, "%.0f", 0, NULL }, + { "input.transfer.low.min", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferLowMin", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.transfer.low.max", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferLowMax", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.transfer.high.min", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferHighMin", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.transfer.high.max", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferHighMax", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + /* FIXME: Check vs hardware, is this an "input" or "outlet/outpu" value after all? */ + { "input.source", 0, 0, "UPS.OutletSystem.Outlet.DeltaOutputSource", NULL, "%s", 0, delta_ups_output_source_info }, { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.charge", 0, 0, "UPS.BatterySystem.Battery.RemainingCapacity", NULL, "%.1f", 0, NULL }, + { "battery.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, @@ -189,28 +201,66 @@ static hid_info_t delta_ups_hid2nut[] = { { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, + { "ups.test.result", 0, 0, "UPS.BatterySystem.Test", NULL, "%s", 0, test_read_info }, + { "ups.type", 0, 0, "UPS.DeltaCustom.[1].DeltaUPSType", NULL, "%s", HU_FLAG_STATIC, delta_ups_type_info }, + { "ups.start.auto", ST_FLAG_RW, 0, "UPS.DeltaCustom.[1].DeltaConfigStartPowerRestore", NULL, "%s", 0, yes_no_info }, { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.1f", 0, NULL }, { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + { "ups.delay.start", ST_FLAG_RW, 0, "UPS.OutletSystem.Outlet.DeltaConfigStartPowerRestoreDelay", NULL, "%.0f", 0, NULL }, +/* mge-hid.c simlar configurable settings: + { "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL }, + { "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL }, +... + { "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, +*/ { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "ups.timer.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.timer.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "ups.timer.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, HU_FLAG_QUICK_POLL, off_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, HU_FLAG_QUICK_POLL, commfault_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyCharged", NULL, NULL, HU_FLAG_QUICK_POLL, fullycharged_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyDischarged", NULL, NULL, 0, depleted_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, replacebatt_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.VoltageOutOfRange", NULL, NULL, 0, vrange_info }, { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Used", NULL, NULL, 0, nobattery_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.InternalFailure", NULL, NULL, 0, commfault_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.AwaitingPower", NULL, NULL, 0, awaitingpower_info }, + + { "beeper.on", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, + { "beeper.off", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, + { "beeper.enable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, + { "beeper.disable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL }, + { "beeper.mute", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, /* 10 seconds battery test */ { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Test", NULL, "1", HU_TYPE_CMD, NULL }, + /* test until battery low */ + { "test.battery.start.deep", 0, 0, "UPS.BatterySystem.Test", NULL, "2", HU_TYPE_CMD, NULL }, + { "test.battery.stop", 0, 0, "UPS.BatterySystem.Test", NULL, "3", HU_TYPE_CMD, NULL }, + + { "load.on.delay", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL }, + { "load.off.delay", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, + + { "shutdown.stop", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL }, + { "shutdown.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL }, /* Terminating entry */ { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } From 0ebe54f85b5f43702daf53ba57693c5611d5067a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 21:01:20 +0200 Subject: [PATCH 15/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: set battery.charge* precision to %.0f same for all entries --- drivers/delta_ups-hid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 3bf1dcdec3..11f2add66d 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -184,9 +184,9 @@ static hid_info_t delta_ups_hid2nut[] = { { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.charge", 0, 0, "UPS.BatterySystem.Battery.RemainingCapacity", NULL, "%.1f", 0, NULL }, + { "battery.charge", 0, 0, "UPS.BatterySystem.Battery.RemainingCapacity", NULL, "%.0f", 0, NULL }, { "battery.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, +/* { "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, */ { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, From 211e5c4af04081f09304042adf5be12683b54b33 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 21:04:22 +0200 Subject: [PATCH 16/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: set voltage/current/frequency precision to %.1f same for all entries --- drivers/delta_ups-hid.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 11f2add66d..e3411f12d6 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -168,20 +168,20 @@ static info_lkp_t delta_ups_output_source_info[] = { static hid_info_t delta_ups_hid2nut[] = { { "input.sensitivity", ST_FLAG_RW, 0, "UPS.DeltaCustom.[1].DeltaConfigSensitivity", NULL, "%s", 0, delta_ups_sensitivity_info }, - { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "input.voltage.nominal", 0, 0, "UPS.PowerSummary.Input.ConfigVoltage", NULL, "%.1f", HU_FLAG_SEMI_STATIC, NULL }, { "input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "input.transfer.low", ST_FLAG_RW, 0, "UPS.PowerConverter.Output.LowVoltageTransfer", NULL, "%.0f", 0, NULL }, - { "input.transfer.high", ST_FLAG_RW, 0, "UPS.PowerConverter.Output.HighVoltageTransfer", NULL, "%.0f", 0, NULL }, - { "input.transfer.low.min", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferLowMin", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "input.transfer.low.max", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferLowMax", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "input.transfer.high.min", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferHighMin", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "input.transfer.high.max", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferHighMax", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.transfer.low", ST_FLAG_RW, 0, "UPS.PowerConverter.Output.LowVoltageTransfer", NULL, "%.1f", 0, NULL }, + { "input.transfer.high", ST_FLAG_RW, 0, "UPS.PowerConverter.Output.HighVoltageTransfer", NULL, "%.1f", 0, NULL }, + { "input.transfer.low.min", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferLowMin", NULL, "%.1f", HU_FLAG_STATIC, NULL }, + { "input.transfer.low.max", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferLowMax", NULL, "%.1f", HU_FLAG_STATIC, NULL }, + { "input.transfer.high.min", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferHighMin", NULL, "%.1f", HU_FLAG_STATIC, NULL }, + { "input.transfer.high.max", 0, 0, "UPS.PowerConverter.Output.DeltaConfigTransferHighMax", NULL, "%.1f", HU_FLAG_STATIC, NULL }, /* FIXME: Check vs hardware, is this an "input" or "outlet/outpu" value after all? */ { "input.source", 0, 0, "UPS.OutletSystem.Outlet.DeltaOutputSource", NULL, "%s", 0, delta_ups_output_source_info }, { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "battery.voltage.nominal", 0, 0, "UPS.BatterySystem.Battery.ConfigVoltage", NULL, "%.1f", HU_FLAG_STATIC, NULL }, { "battery.voltage", 0, 0, "UPS.BatterySystem.Battery.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, { "battery.charge", 0, 0, "UPS.BatterySystem.Battery.RemainingCapacity", NULL, "%.0f", 0, NULL }, @@ -194,10 +194,10 @@ static hid_info_t delta_ups_hid2nut[] = { { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, - { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, - { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.1f", HU_FLAG_SEMI_STATIC, NULL }, + { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.1f", HU_FLAG_SEMI_STATIC, NULL }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_QUICK_POLL, beeper_info }, From 8a77e5a3a4666f29c2eb100fbeae93c4ba032ea3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 21:05:00 +0200 Subject: [PATCH 17/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: comment away ups.mfr/model/serial setting per PR comments --- drivers/delta_ups-hid.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index e3411f12d6..46b480bcb5 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -208,9 +208,14 @@ static hid_info_t delta_ups_hid2nut[] = { { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.1f", 0, NULL }, { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, + /* Per comments to PR #807 these 3 declarations are populated elsewhere, + * by delta_ups_format_*() functions hooks; see: + * https://github.com/networkupstools/nut/pull/807#discussion_r501496383 + */ +/* { "ups.mfr", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, { "ups.model", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, { "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, +*/ { "ups.delay.start", ST_FLAG_RW, 0, "UPS.OutletSystem.Outlet.DeltaConfigStartPowerRestoreDelay", NULL, "%.0f", 0, NULL }, /* mge-hid.c simlar configurable settings: { "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL }, From 370443ea976722086f84c6b1a77b7e7b3fba0d44 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 21:05:42 +0200 Subject: [PATCH 18/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: remove (read-only) mappings for ups.delay* in favor of same points polled for ups.timer* --- drivers/delta_ups-hid.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 46b480bcb5..a9a10391ef 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -223,9 +223,6 @@ static hid_info_t delta_ups_hid2nut[] = { ... { "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, */ - { "ups.delay.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.delay.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, - { "ups.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "ups.timer.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, { "ups.timer.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, { "ups.timer.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, From 7614240650717e6effa04427df42f72b88862d32 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 21 Apr 2021 21:10:57 +0200 Subject: [PATCH 19/22] drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: sync polling frequencies --- drivers/delta_ups-hid.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index a9a10391ef..10791edef6 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -191,8 +191,8 @@ static hid_info_t delta_ups_hid2nut[] = { { "battery.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%s", HU_FLAG_QUICK_POLL, kelvin_celsius_conversion }, { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion }, - { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL }, - { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.1f", HU_FLAG_SEMI_STATIC, NULL }, { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.1f", HU_FLAG_SEMI_STATIC, NULL }, @@ -206,7 +206,7 @@ static hid_info_t delta_ups_hid2nut[] = { { "ups.start.auto", ST_FLAG_RW, 0, "UPS.DeltaCustom.[1].DeltaConfigStartPowerRestore", NULL, "%s", 0, yes_no_info }, { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "ups.realpower", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, - { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.1f", 0, NULL }, + { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, { "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.1f", HU_FLAG_QUICK_POLL, NULL }, /* Per comments to PR #807 these 3 declarations are populated elsewhere, * by delta_ups_format_*() functions hooks; see: @@ -235,16 +235,16 @@ static hid_info_t delta_ups_hid2nut[] = { { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyCharged", NULL, NULL, HU_FLAG_QUICK_POLL, fullycharged_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, - { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyDischarged", NULL, NULL, 0, depleted_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyDischarged", NULL, NULL, HU_FLAG_QUICK_POLL, depleted_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, replacebatt_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.VoltageOutOfRange", NULL, NULL, 0, vrange_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.VoltageOutOfRange", NULL, NULL, HU_FLAG_QUICK_POLL, vrange_info }, { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, HU_FLAG_QUICK_POLL, trim_info }, { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, HU_FLAG_QUICK_POLL, boost_info }, { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Used", NULL, NULL, 0, nobattery_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.InternalFailure", NULL, NULL, 0, commfault_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.AwaitingPower", NULL, NULL, 0, awaitingpower_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Used", NULL, NULL, HU_FLAG_QUICK_POLL, nobattery_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.OverTemperature", NULL, NULL, HU_FLAG_QUICK_POLL, overheat_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.InternalFailure", NULL, NULL, HU_FLAG_QUICK_POLL, commfault_info }, + { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.AwaitingPower", NULL, NULL, HU_FLAG_QUICK_POLL, awaitingpower_info }, { "beeper.on", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, { "beeper.off", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, From 8398d81eea75b73bcc936232bb9fa7609d770d11 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 23 Apr 2021 19:23:58 +0200 Subject: [PATCH 20/22] drivers/usbhid-ups.c: order includes and subdrivers alphabetically --- drivers/usbhid-ups.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index ee9be5d812..1e7332f303 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -40,18 +40,18 @@ #include "mge-hid.h" #ifndef SHUT_MODE + /* explore stub goes first, others alphabetically */ #include "explore-hid.h" #include "apc-hid.h" #include "belkin-hid.h" #include "cps-hid.h" #include "delta_ups-hid.h" - #include "liebert-hid.h" - #include "powercom-hid.h" - #include "tripplite-hid.h" #include "idowell-hid.h" + #include "liebert-hid.h" #include "openups-hid.h" + #include "powercom-hid.h" #include "powervar-hid.h" - #include "delta_ups-hid.h" + #include "tripplite-hid.h" #endif /* Reference list of avaiable subdrivers */ @@ -64,14 +64,13 @@ static subdriver_t *subdriver_list[] = { &apc_subdriver, &belkin_subdriver, &cps_subdriver, - &delta_subdriver, - &liebert_subdriver, - &powercom_subdriver, - &tripplite_subdriver, + &delta_ups_subdriver, &idowell_subdriver, + &liebert_subdriver, &openups_subdriver, + &powercom_subdriver, &powervar_subdriver, - &delta_ups_subdriver, + &tripplite_subdriver, #endif NULL }; From 6a2a65bb68aa71981ed3f8330a09e35092b47981 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 23 Apr 2021 19:29:49 +0200 Subject: [PATCH 21/22] drivers/delta_ups-hid.c: fix initialization of delta_ups_type_info[] --- drivers/delta_ups-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 9b14c162d2..e10063caf8 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -144,7 +144,7 @@ static const char *delta_ups_type_fun(double value) } static info_lkp_t delta_ups_type_info[] = { - { 0, NULL, delta_ups_type_fun }, + { 0, NULL, delta_ups_type_fun, NULL }, { 0, NULL, NULL, NULL } }; From e91b75e8b7bb1587d0ae77c9d3288ad1a7b9dede Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 23 Apr 2021 19:28:32 +0200 Subject: [PATCH 22/22] drivers/nutdrv_qx.c: fabula_hunnox_subdriver(): annotate NUT_UNUSED_VARIABLE(device) arg --- drivers/nutdrv_qx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index d4534ea864..bf41887823 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -1359,6 +1359,8 @@ static void *fabula_subdriver(USBDevice_t *device) /* Note: the "hunnox_subdriver" name is taken by the subdriver_t structure */ static void *fabula_hunnox_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &hunnox_command; return NULL; }