From 525c030dc39615fe96ebfc771cfdb651aade1355 Mon Sep 17 00:00:00 2001 From: EVER-PowerSystems Date: Mon, 8 May 2017 11:46:13 +0200 Subject: [PATCH 01/70] add EVER hid ups --- drivers/Makefile.am | 20 +- drivers/ever-hid.c | 638 +++++++++++++++++++++++++++++ drivers/ever-hid.h | 30 ++ drivers/usbhid-ups.c | 2 + scripts/upower/95-upower-hid.rules | 6 + 5 files changed, 681 insertions(+), 15 deletions(-) create mode 100644 drivers/ever-hid.c create mode 100644 drivers/ever-hid.h diff --git a/drivers/Makefile.am b/drivers/Makefile.am index ef4af792ed..22c5584f24 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -28,14 +28,11 @@ endif if WITH_IPMI AM_CFLAGS += $(LIBIPMI_CFLAGS) endif -if WITH_MODBUS - AM_CFLAGS += $(LIBMODBUS_CFLAGS) -endif SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \ bestfortress bestuferrups bestups dummy-ups etapro everups \ gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \ - mge-utalk microdowell mge-shut oneac optiups powercom rhino \ + oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \ safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \ blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser \ nutdrv_qx @@ -47,7 +44,6 @@ USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \ USB_DRIVERLIST = $(USB_LIBUSB_DRIVERLIST) NEONXML_DRIVERLIST = netxml-ups MACOSX_DRIVERLIST = macosx-ups -MODBUS_DRIVERLIST = phoenixcontact_modbus LINUX_I2C_DRIVERLIST = asem # distribute all drivers, even ones that are not built by default @@ -82,9 +78,6 @@ endif if WITH_LINUX_I2C driverexec_PROGRAMS += $(LINUX_I2C_DRIVERLIST) endif -if WITH_MODBUS - driverexec_PROGRAMS += $(MODBUS_DRIVERLIST) -endif else driverexec_PROGRAMS += skel endif @@ -123,6 +116,7 @@ liebert_SOURCES = liebert.c liebert_esp2_SOURCES = liebert-esp2.c masterguard_SOURCES = masterguard.c metasys_SOURCES = metasys.c +oldmge_shut_SOURCES = mge-shut.c hidparser.c mge_utalk_SOURCES = mge-utalk.c microdowell_SOURCES = microdowell.c oneac_SOURCES = oneac.c @@ -171,7 +165,7 @@ skel_SOURCES = skel.c skel_LDADD = $(LDADD_DRIVERS) # USB -USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c explore-hid.c \ +USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c ever-hid.c explore-hid.c \ liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \ openups-hid.c usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \ @@ -231,10 +225,6 @@ macosx_ups_LDADD = $(LDADD_DRIVERS) macosx_ups_LDFLAGS = $(LDFLAGS) -framework IOKit -framework CoreFoundation macosx_ups_SOURCES = macosx-ups.c -# Modbus driver -phoenixcontact_modbus_SOURCES = phoenixcontact_modbus.c -phoenixcontact_modbus_LDADD = $(LDADD_DRIVERS) $(LIBMODBUS_LIBS) - # Asem asem_LDADD = $(LDADD_DRIVERS) asem_SOURCES = asem.c @@ -265,9 +255,9 @@ nutdrv_qx_SOURCES += $(NUTDRV_QX_SUBDRIVERS) dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \ bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \ - dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \ + dummy-ups.h eaton-mib.h ever-hid.c explore-hid.h gamatronic.h genericups.h \ hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h libusb.h liebert-hid.h \ - main.h mge-hid.h mge-mib.h mge-utalk.h \ + main.h mge-hid.h mge-mib.h mge-shut.h mge-utalk.h \ mge-xml.h microdowell.h netvision-mib.h netxml-ups.h nut-ipmi.h oneac.h \ powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \ safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \ diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c new file mode 100644 index 0000000000..0f7ba4aee8 --- /dev/null +++ b/drivers/ever-hid.c @@ -0,0 +1,638 @@ +/* ever-hid.c - subdriver to monitor EVER USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2012 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * 2013 Charles Lepple + * + * Note: this subdriver was initially generated as a "stub" by the + * gen-usbhid-subdriver script. It must be customized. + * + * 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 "ever-hid.h" +#include "main.h" /* for getval() */ +#include "usb-common.h" + +#define EVER_HID_VERSION "Ever HID 0.1" +/* FIXME: experimental flag to be put in upsdrv_info */ + +/* Ever */ +#define EVER_VENDORID 0x2E51 + +/* USB IDs device table */ +static usb_device_id_t ever_usb_device_table[] = { + + { USB_DEVICE(0x0483, 0xa113), NULL }, + { USB_DEVICE(EVER_VENDORID, 0xffff), NULL}, + + + /* Terminating entry */ + { -1, -1, NULL } +}; + +/* --------------------------------------------------------------- */ +/* Vendor-specific usage table */ +/* --------------------------------------------------------------- */ + +static const char *ever_format_hardware_fun(double value) +{ + /*TODO - add exception handling for v1.0b0B */ + const char* hard_rev[27] = {"0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; + static char model[10]; + snprintf(model, sizeof(model), "rev.%sv%02d", (&hard_rev[ ((unsigned int)value & 0xFF00)>>8 ])[0], (unsigned int)value & 0xFF ); + return model; +} + +static const char *ever_format_version_fun(double value) +{ + /*upsdebugx(1, "UPS ups_firmware_conversion_fun VALUE: %d", (long)value ); */ + static char model[10]; + snprintf(model, sizeof(model), "v%X.%Xb%02d", ((unsigned int)value & 0xF000)>>12, ((unsigned int)value & 0xF00)>>8, ((int)value & 0xFF) ); + return model; +} + +static const char *ever_mac_address_fun(double value) +{ + + int mac_adress_report_id = 210; + int len = reportbuf->len[mac_adress_report_id]; + const void *buf = reportbuf->data[mac_adress_report_id]; + + static char line[100]; + line[0] = '\0'; + int n = 0; /* number of characters currently in line */ + int i; /* number of bytes output from buffer */ + + /* skip first elemnt which is a report id */ + for (i = 1; i < len; i++) { + n = snprintfcat(line, sizeof(line), n ? ":%02x" : "%02x", + ((unsigned char *)buf)[i]); + } + + return line; +} + +static const char *ever_ip_address_fun(double value) +{ + static int report_counter = 1; + int report_id = 211; + + if(report_counter == 1) + report_id = 211; /* notification dest ip */ + else if(report_counter == 2) + report_id = 230; /* ip address */ + else if(report_counter == 3) + report_id = 231; /* network mask */ + else if(report_counter == 4) + report_id = 232; /* default gateway */ + + report_counter== 4 ? report_counter=1 : report_counter++; + + int len = reportbuf->len[report_id]; + const void *buf = reportbuf->data[report_id]; + + static char line[100]; + line[0] = '\0'; + int n = 0; /* number of characters currently in line */ + int i; /* number of bytes output from buffer */ + + /*skip first element which is a report id */ + for (i = 1; i < len; i++) + { + n = snprintfcat(line, sizeof(line), n ? ".%d" : "%d", ((unsigned char *)buf)[i]); + } + + return line; +} + +static const char *ever_packets_fun(double value) +{ + static int report_counter = 1; + int report_id = 215; + + if(report_counter == 1 ) + report_id = 215; + else if(report_counter == 2 ) + report_id = 216; + else if(report_counter == 3 ) + report_id = 217; + else if(report_counter == 4 ) + report_id = 218; + + report_counter== 4 ? report_counter=1 : report_counter++; + + int len = reportbuf->len[report_id]; + const unsigned char *buf = reportbuf->data[report_id]; + + static char line[100]; + line[0] = '\0'; + + /*skip first elemnt which is a report id */ + + if(len < 5) + return ""; + + int res = (int)buf[1]; + res |= (int)buf[2] << 8; + res |= (int)buf[3] << 16; + res |= (int)buf[4] << 24; + + snprintf(line, sizeof(line), "%d", res); + return line; + +} + +static const char* ever_workmode_fun(double value) +{ + int workmode_report_id = 74; + const unsigned char *buf = reportbuf->data[workmode_report_id]; + + static char line[100]; + line[0] = '\0'; + + /*skip first element which is a report id */ + snprintfcat(line, sizeof(line), "%d", buf[1]); + + + + int workmode = atoi(line); + + switch(workmode) + { + case 1: + return "UNKNOWN"; + case 2: + return "STOP"; + case 4: + return "ONLINE"; + case 8: + return "ONBATTERY"; + case 16: + return "WATCH"; + case 32: + return "WAITING"; + case 64: + return "EMERGENCY"; + default: + return "UNKNOWN"; + + } + +} + +static const char* ever_messages_fun(double value) +{ + int messages_report_id = 75; + const unsigned char *buf = reportbuf->data[messages_report_id]; + + static char line[200]; + line[0] = '\0'; + + /*skip first element which is a report id */ + int messages = (int)buf[1]; + messages |= (int)buf[2] << 8; + + int n = 0; /* number of characters currently in line */ + + if(messages & 0x01) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERLOAD"); + if(messages & 0x02) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BATTERY_LOW"); + if(messages & 0x04) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BOOST"); + if(messages & 0x08) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "TRIM"); + if(messages & 0x10) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BOOST_BLOCKED"); + if(messages & 0x20) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "TRIM_BLOCKED"); + if(messages & 0x40) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "CHARGING"); + if(messages & 0x80) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "FAN_ON"); + if(messages & 0x100) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "EPO_BLOCKED"); + if(messages & 0x200) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "NEED_REPLACMENT"); + if(messages & 0x400 || messages & 0x800) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERHEAT"); + if(messages & 0x1000) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "WAITING_FOR_MIN_CHARGE"); + if(messages & 0x2000) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "MAINS_OUT_OF_RANGE"); + return line; +} + +static const char* ever_alarms_fun(double value) +{ + int alarms_report_id = 76; + + const unsigned char *buf = reportbuf->data[alarms_report_id]; + + static char line[200]; + line[0] = '\0'; + + /*skip first element which is a report id */ + int alarms = (int)buf[1]; + alarms |= (int)buf[2] << 8; + + int n = 0; /* number of characters currently in line */ + + if(alarms & 0x01) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERLOAD"); + if(alarms & 0x02) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "SHORTCUT"); + if(alarms & 0x04 || alarms & 0x08) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERHEAT"); + if(alarms & 0x10) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "EPO"); + if(alarms & 0x20) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "INERNAL_ERROR"); + if(alarms & 0x40) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "REVERSE_POWER_SUPPLY"); + if(alarms & 0x80) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "NO_INETERNAL_COMM"); + if(alarms & 0x100) + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "CRITICAL_BATT_VOLTAGE"); + + return line; +} + +static const char* ever_on_off_fun(double value) +{ + int workmode_report_id = 74; + const unsigned char *buf = reportbuf->data[workmode_report_id]; + + static char line[100]; + line[0] = '\0'; + + /*skip first element which is a report id */ + snprintfcat(line, sizeof(line), "%d", buf[1]); + + int workmode = atoi(line); + + if(workmode != 0x04 && workmode != 0x08) + return "off"; + + return "!off"; +} + +info_lkp_t ever_format_hardware[] = { + { 0, NULL, ever_format_hardware_fun} +}; + +info_lkp_t ever_format_version[] = { + { 0, NULL, ever_format_version_fun} +}; + +info_lkp_t ever_mac_address[] = { + { 0, NULL, ever_mac_address_fun} +}; + +info_lkp_t ever_ip_address[] = { + { 0, NULL, ever_ip_address_fun} +}; + +info_lkp_t ever_packets[] = { + { 0, NULL, ever_packets_fun} +}; + +info_lkp_t ever_workmode[] = { + { 0, NULL, ever_workmode_fun} +}; + +info_lkp_t ever_messages[] = { + { 0, NULL, ever_messages_fun} +}; + +info_lkp_t ever_alarms[] = { + { 0, NULL, ever_alarms_fun} +}; + +info_lkp_t ever_on_off_info[] = { + { 0, NULL, ever_on_off_fun} +}; + + +/* EVER usage table */ +static usage_lkp_t ever_usage_lkp[] = { + { "EVER1", 0x00000000 }, + { "EVER2", 0xff000000 }, + { "EVER3", 0xff000001 }, + { "EVER4", 0xff000002 }, + { "EVER5", 0xff000003 }, + { "EVER6", 0xff000004 }, + { "EVER7", 0xff000005 }, + { "EVER8", 0xff000006 }, + { "EVER9", 0xff000007 }, + { "EVER10", 0xff000008 }, + { "EVER11", 0xff000009 }, + { "EVER12", 0xff000010 }, + { "EVER13", 0xff000011 }, + { "EVER14", 0xff000012 }, + { "EVER15", 0xff000013 }, + { "EVER16", 0xff000014 }, + { "EVER17", 0xff000015 }, + { "EVER18", 0xff000016 }, + { "EVER19", 0xff000017 }, + { "EVER20", 0xff000018 }, + { "EVER21", 0xff000019 }, + { "EVER22", 0xff00001a }, + { "EVER23", 0xff00001b }, + { "EVER24", 0xff00001c }, + { "EVER25", 0xff00001d }, + { "EVER26", 0xff00001e }, + { "EVER27", 0xff00001f }, + { "EVER28", 0xff000020 }, + { "EVER29", 0xff000021 }, + { "EVER30", 0xff000022 }, + { "EVER31", 0xff000023 }, + { "EVER32", 0xff000030 }, + { "EVER33", 0xff000031 }, + { "EVER34", 0xff000032 }, + { "EVER35", 0xff000033 }, + { "EVER36", 0xff000034 }, + { "EVER37", 0xff000035 }, + { "EVER38", 0xff000036 }, + { "EVER39", 0xff000037 }, + { "EVER40", 0xff000038 }, + { "EVER41", 0xff000039 }, + { "EVER42", 0xff000040 }, + { "EVER43", 0xff000041 }, + { "EVER44", 0xff000042 }, + { "EVER45", 0xff000043 }, + { "EVER46", 0xff000044 }, + { "EVER47", 0xff000045 }, + { "EVER48", 0xff000046 }, + { "EVER49", 0xff000050 }, + { "EVER50", 0xff000051 }, + { "EVER51", 0xff000052 }, + { "EVER52", 0xff000053 }, + { "EVER53", 0xff000054 }, + { "EVER54", 0xff000060 }, + { "EVER55", 0xff000061 }, + { "EVER56", 0xff000062 }, + { "EVER57", 0xff000063 }, + { "EVER58", 0xff000064 }, + { "EVER59", 0xff000066 }, + { "EVER60", 0xff000067 }, + { "EVER61", 0xff000068 }, + { "EVER62", 0xff000069 }, + { "EVER63", 0xff00006a }, + { "EVER64", 0xff00006b }, + { "EVER65", 0xff00006c }, + { "EVER66", 0xff00006d }, + { "EVER67", 0xff00006e }, + { "EVER68", 0xff00006f }, + { "EVER69", 0xff000070 }, + { "EVER70", 0xff000071 }, + { "EVER71", 0xff000072 }, + { "EVER72", 0xff000073 }, + { "EVER73", 0xff000074 }, + { "EVER74", 0xff000075 }, + { "EVER75", 0xff000076 }, + { "EVER76", 0xff000077 }, + { "EVER77", 0xff000078 }, + { "EVER78", 0xff000079 }, + { "EVER79", 0xff00007a }, + { "EVER80", 0xff00007b }, + { "EVER81", 0xff00007c }, + { "EVER82", 0xff00007d }, + { "EVER83", 0xff00007e }, + { "EVER84", 0xff00007f }, + { "EVER85", 0xff000080 }, + { "EVER86", 0xff000081 }, + { "EVER87", 0xff000082 }, + { "EVER88", 0xff000083 }, + { "EVER89", 0xff000084 }, + { "EVER90", 0xff000085 }, + { "EVER91", 0xff000086 }, + { "EVER92", 0xff000087 }, + { "EVER93", 0xff000088 }, + { "EVER94", 0xff000089 }, + { "EVER95", 0xff00008a }, + { "EVER96", 0xff00008b }, + { "EVER97", 0xff000090 }, + { "EVER98", 0xff000091 }, + { "EVER99", 0xff000092 }, + { "EVER100", 0xff000093 }, + { "EVER101", 0xff000094 }, + { "EVER102", 0xff000095 }, + { "EVER103", 0xff000096 }, + { "EVER104", 0xff000097 }, + { NULL, 0 } +}; + +static usage_tables_t ever_utab[] = { + ever_usage_lkp, + hid_usage_lkp, + NULL, +}; + + +/* --------------------------------------------------------------- */ +/* HID2NUT lookup table */ +/* --------------------------------------------------------------- */ + +static hid_info_t ever_hid2nut[] = { + + { "ups.batterysystem.battery.batteryid", 0, 0, "UPS.BatterySystem.Battery.BatteryID", NULL, "%.0f", 0, NULL }, + { "ups.batterysystem.batterysystemid", 0, 0, "UPS.BatterySystem.BatterySystemID", NULL, "%.0f", 0, NULL }, + { "ups.batterysystem.charger.chargerid", 0, 0, "UPS.BatterySystem.Charger.ChargerID", NULL, "%.0f", 0, NULL }, + { "ups.batterysystem.input.flowid", 0, 0, "UPS.BatterySystem.Input.FlowID", NULL, "%.0f", 0, NULL }, + { "ups.batterysystem.input.inputid", 0, 0, "UPS.BatterySystem.Input.InputID", NULL, "%.0f", 0, NULL }, + { "ups.batterysystem.output.flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, + { "ups.batterysystem.output.outputid", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, + /*{ "ever.identyfication.upstype", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model },*/ + { "ever.identyfication.firmware.inverter.version", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, + { "ever.identyfication.firmware.interfaces.version", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, + { "ever.identyfication.hardware.version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, + { "ever.identyfication.protocol.inverter.version", 0, 0, "UPS.EVER1.EVER16", NULL, "%s", 0, ever_format_version }, + { "ever.identyfication.protocol.interfaces.version", 0, 0, "UPS.EVER1.EVER17", NULL, "%s", 0, ever_format_version }, + { "ever.hitsinktemperature", 0, 0, "UPS.EVER1.EVER42", NULL, "%s", 0, kelvin_celsius_conversion }, + { "ever.batterytemperature", 0, 0, "UPS.EVER1.EVER43", NULL, "%s", 0, kelvin_celsius_conversion }, + { "ever.outputpowerfactor", 0, 0, "UPS.EVER1.EVER44", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.upson", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER46", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.clearfault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER47", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.clearbatteryfault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER48", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.epoblocked", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER50", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.greenmode", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER51", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.buttonsound", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER52", NULL, "%.0f", 0, NULL }, + { "ever.ups.control.audiblealarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, + { "ever.ups.config.outputvoltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, + /*{ "ever.ups.config.minoutputvoltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, + { "ever.ups.config.maxoutputvoltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, + { "ever.ups.config.minoutputfrequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, + { "ever.ups.config.maxoutputfrequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL },*/ + { "ever.ups.config.overloadclearancethreshold", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER59", NULL, "%.0f", 0, NULL }, + { "ever.ups.config.stbcharge", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER60", NULL, "%.0f", 0, NULL }, + { "ever.ups.config.numberofebms", ST_FLAG_RW | ST_FLAG_STRING, 1, "UPS.EVER1.EVER61", NULL, "%.0f", 0, NULL }, + { "ever.statistics.mainslosscounter", 0, 0, "UPS.EVER1.EVER62", NULL, "%.0f", 0, NULL }, + { "ever.statistics.loweringAVRtriggercounter", 0, 0, "UPS.EVER1.EVER63", NULL, "%.0f", 0, NULL }, + { "ever.statistics.risingAVRtriggercounter", 0, 0, "UPS.EVER1.EVER64", NULL, "%.0f", 0, NULL }, + { "ever.statistics.overloadcounter", 0, 0, "UPS.EVER1.EVER65", NULL, "%.0f", 0, NULL }, + { "ever.statistics.shortcircuitcounter", 0, 0, "UPS.EVER1.EVER66", NULL, "%.0f", 0, NULL }, + { "ever.statistics.dischargecounter", 0, 0, "UPS.EVER1.EVER67", NULL, "%.0f", 0, NULL }, + { "ever.statistics.overheatcounter", 0, 0, "UPS.EVER1.EVER68", NULL, "%.0f", 0, NULL }, + { "ever.statistics.mainsoperationtime", 0, 0, "UPS.EVER1.EVER69", NULL, "%.0f", 0, NULL }, + { "ever.statistics.autonomousoperationtime", 0, 0, "UPS.EVER1.EVER70", NULL, "%.0f", 0, NULL }, + { "ever.statistics.overloadoperationtime", 0, 0, "UPS.EVER1.EVER71", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.macaddress", 0, 0, "UPS.EVER1.EVER72", NULL, "%s", 0, ever_mac_address }, + { "ever.networkcard.notificationdestinationip", 0, 0, "UPS.EVER1.EVER73", NULL, "%s", 0, ever_ip_address }, + { "ever.networkcard.statistics.sendpackets", 0, 0, "UPS.EVER1.EVER77", NULL, "%s", 0, ever_packets }, + { "ever.networkcard.statistics.receivedpackets", 0, 0, "UPS.EVER1.EVER78", NULL, "%s", 0, ever_packets }, + { "ever.networkcard.statistics.sendpacketserrors", 0, 0, "UPS.EVER1.EVER79", NULL, "%s", 0, ever_packets }, + { "ever.networkcard.statistics.receivedpacketserrors", 0, 0, "UPS.EVER1.EVER80", NULL, "%s", 0, ever_packets }, + { "ever.networkcard.config.dhcpenabled", 0, 0, "UPS.EVER1.EVER85.EVER86", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.config.ethernetenabled", 0, 0, "UPS.EVER1.EVER85.EVER87", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.config.httpenabled", 0, 0, "UPS.EVER1.EVER85.EVER88", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.config.snmpenabled", 0, 0, "UPS.EVER1.EVER85.EVER89", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.config.snmptrapenabled", 0, 0, "UPS.EVER1.EVER85.EVER90", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.config.readonly", 0, 0, "UPS.EVER1.EVER85.EVER91", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.config.restarteth", 0, 0, "UPS.EVER1.EVER85.EVER96", NULL, "%.0f", 0, NULL }, + { "ever.networkcard.ipaddress", 0, 0, "UPS.EVER1.EVER93", NULL, "%s", 0, ever_ip_address }, + { "ever.networkcard.networkmask", 0, 0, "UPS.EVER1.EVER94", NULL, "%s", 0, ever_ip_address }, + { "ever.networkcard.defaultgateway", 0, 0, "UPS.EVER1.EVER95", NULL, "%s", 0, ever_ip_address }, + { "ups.flow.configactivepower", 0, 0, "UPS.Flow.ConfigActivePower", NULL, "%.0f", 0, NULL }, + { "ups.flow.configapparentpower", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, + { "ups.flow.configfrequency", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, + { "ups.flow.configvoltage", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "ups.flow.flowid", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", 0, NULL }, + { "ups.outletsystem.outlet.outletid", 0, 0, "UPS.OutletSystem.Outlet.OutletID", NULL, "%.0f", 0, NULL }, + { "ups.outletsystem.outlet.presentstatus.present", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Present", NULL, "%.0f", 0, yes_no_info }, + { "ups.outletsystem.outlet.presentstatus.switchable", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Switchable", NULL, "%.0f", 0, yes_no_info }, + { "ups.outletsystem.outlet.presentstatus.switchon/off", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.SwitchOn/Off", NULL, "%.0f", 0, NULL }, + { "ups.outletsystem.outlet.presentstatus.undefined", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Undefined", NULL, "%.0f", 0, NULL }, + { "ups.outletsystem.outlet.switchoffcontrol", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOffControl", NULL, "%.0f", 0, NULL }, + { "ups.outletsystem.outlet.switchoncontrol", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOnControl", NULL, "%.0f", 0, NULL }, + { "ups.outletsystem.outletsystemid", 0, 0, "UPS.OutletSystem.OutletSystemID", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.input.flowid", 0, 0, "UPS.PowerConverter.Input.FlowID", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.input.inputid", 0, 0, "UPS.PowerConverter.Input.InputID", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.activepower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.apparentpower", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.flowid", 0, 0, "UPS.PowerConverter.Output.FlowID", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.outputid", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.percentload", 0, 0, "UPS.PowerConverter.Output.PercentLoad", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, + { "ups.powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.capacitygranularity1", 0, 0, "UPS.PowerSummary.CapacityGranularity1", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.capacitygranularity2", 0, 0, "UPS.PowerSummary.CapacityGranularity2", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.capacitymode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.delaybeforeshutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL }, + { "ups.powersummary.designcapacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.flowid", 0, 0, "UPS.PowerSummary.FlowID", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.fullchargecapacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.idevicechemistry", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.percentload", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.rechargeable", 0, 0, "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.remainingcapacity", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.remainingtimelimit", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.runtimetoempty", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, + { "ups.powersummary.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, + { "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + /*{ "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL },*/ + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.AwaitingPower", NULL, NULL, HU_FLAG_QUICK_POLL, awaitingpower_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, 0, nobattery_info }, + /* { "ups.presentstatus.belowremainingcapacitylimit", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, "%.0f", 0, NULL }, */ + /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Boost", NULL, NULL, 0, boost_info }, */ + /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Buck", NULL, NULL, 0, trim_info }, */ + /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info },*/ + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.CommunicationLost", NULL, NULL, 0, commfault_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + /* { "ups.powersummary.presentstatus.good", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, "%.0f", 0, NULL }, */ + /* { "ups.powersummary.presentstatus.internalfailure", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, "%.0f", 0, NULL }, */ + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, + /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, 0, lowbatt_info }, */ + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, + + { "BOOL", 0, 0, "UPS.EVER1.EVER18.EVER19", NULL, NULL, 0, overload_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER18.EVER20", NULL, NULL, 0, lowbatt_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER18.EVER21", NULL, NULL, 0, boost_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER18.EVER22", NULL, NULL, 0, trim_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER18.EVER25", NULL, NULL, 0, charging_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, replacebatt_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, overload_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER32.EVER40", NULL, "%.0f", 0, commfault_info }, + { "BOOL", 0, 0, "UPS.EVER1.EVER97.EVER102", NULL, "%s", 0, ever_on_off_info }, + + /* ever workmodes, messages & alarms */ + { "ever.ups.status.workmode", 0, 0, "UPS.EVER1.EVER97.EVER98", NULL, "%s", 0, ever_workmode }, + { "ever.ups.status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, + { "ever.ups.status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, + + /* instant commands */ + { "load.off.delay", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, + { "shutdown.return", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, + + /* end of structure. */ + { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } +}; + +static const char *ever_format_model(HIDDevice_t *hd) { + return hd->Product; +} + +static const char *ever_format_mfr(HIDDevice_t *hd) { + return hd->Vendor ? hd->Vendor : "Ever"; +} + +static const char *ever_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 ever_claim(HIDDevice_t *hd) +{ + int status = is_usb_device_supported(ever_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("Ever", hd); + return 0; + + case SUPPORTED: + return 1; + + case NOT_SUPPORTED: + default: + return 0; + } +} + +subdriver_t ever_subdriver = { + EVER_HID_VERSION, + ever_claim, + ever_utab, + ever_hid2nut, + ever_format_model, + ever_format_mfr, + ever_format_serial, +}; diff --git a/drivers/ever-hid.h b/drivers/ever-hid.h new file mode 100644 index 0000000000..2643580799 --- /dev/null +++ b/drivers/ever-hid.h @@ -0,0 +1,30 @@ +/* everhid-hid.h - subdriver to monitor Everhid 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 EVER_HID_H +#define EVER_HID_H + +#include "usbhid-ups.h" + +extern subdriver_t ever_subdriver; + +#endif /* EVER_HID_H */ diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index 954fa54670..91723847f5 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -49,6 +49,7 @@ #include "tripplite-hid.h" #include "idowell-hid.h" #include "openups-hid.h" + #include "ever-hid.h" #endif /* master list of avaiable subdrivers */ @@ -66,6 +67,7 @@ static subdriver_t *subdriver_list[] = { &tripplite_subdriver, &idowell_subdriver, &openups_subdriver, + &ever_subdriver, #endif NULL }; diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules index 4f9c379a43..6e0ccf8f3b 100644 --- a/scripts/upower/95-upower-hid.rules +++ b/scripts/upower/95-upower-hid.rules @@ -23,6 +23,7 @@ ENV{DEVTYPE}=="usb_interface", GOTO="up_hid_end" ATTRS{idVendor}=="03f0", ENV{UPOWER_VENDOR}="Hewlett Packard" ATTRS{idVendor}=="0463", ENV{UPOWER_VENDOR}="Eaton" ATTRS{idVendor}=="047c", ENV{UPOWER_VENDOR}="Dell" +ATTRS{idVendor}=="0483", ENV{UPOWER_VENDOR}="" ATTRS{idVendor}=="04b3", ENV{UPOWER_VENDOR}="IBM" ATTRS{idVendor}=="04d8", ENV{UPOWER_VENDOR}="Minibox" ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin" @@ -35,6 +36,7 @@ ATTRS{idVendor}=="09ae", ENV{UPOWER_VENDOR}="TrippLite" ATTRS{idVendor}=="0d9f", ENV{UPOWER_VENDOR}="PowerCOM" ATTRS{idVendor}=="10af", ENV{UPOWER_VENDOR}="Liebert" ATTRS{idVendor}=="2b2d", ENV{UPOWER_VENDOR}="AEG" +ATTRS{idVendor}=="2E51", ENV{UPOWER_VENDOR}="Ever" # Hewlett Packard ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" @@ -57,6 +59,7 @@ ATTRS{idVendor}=="0463", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups # Dell ATTRS{idVendor}=="047c", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" +ATTRS{idVendor}=="0483", ATTRS{idProduct}=="a113", ENV{UPOWER_BATTERY_TYPE}="ups" # IBM ATTRS{idVendor}=="04b3", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" @@ -147,4 +150,7 @@ ATTRS{idVendor}=="10af", ATTRS{idProduct}=="0008", ENV{UPOWER_BATTERY_TYPE}="ups # AEG ATTRS{idVendor}=="2b2d", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" +# Ever +ATTRS{idVendor}=="2E51", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" + LABEL="up_hid_end" From 97bfcd3651cb3a86c9266c86d14f764ac9dc0d77 Mon Sep 17 00:00:00 2001 From: EVER-PowerSystems Date: Mon, 8 May 2017 13:54:18 +0200 Subject: [PATCH 02/70] fixed errors in makefile --- drivers/Makefile.am | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/Makefile.am b/drivers/Makefile.am index 22c5584f24..ecdd1fd50b 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -28,11 +28,14 @@ endif if WITH_IPMI AM_CFLAGS += $(LIBIPMI_CFLAGS) endif +if WITH_MODBUS + AM_CFLAGS += $(LIBMODBUS_CFLAGS) +endif SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \ bestfortress bestuferrups bestups dummy-ups etapro everups \ gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \ - oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \ + mge-utalk microdowell mge-shut oneac optiups powercom rhino \ safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \ blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser \ nutdrv_qx @@ -44,6 +47,7 @@ USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \ USB_DRIVERLIST = $(USB_LIBUSB_DRIVERLIST) NEONXML_DRIVERLIST = netxml-ups MACOSX_DRIVERLIST = macosx-ups +MODBUS_DRIVERLIST = phoenixcontact_modbus LINUX_I2C_DRIVERLIST = asem # distribute all drivers, even ones that are not built by default @@ -78,6 +82,9 @@ endif if WITH_LINUX_I2C driverexec_PROGRAMS += $(LINUX_I2C_DRIVERLIST) endif +if WITH_MODBUS + driverexec_PROGRAMS += $(MODBUS_DRIVERLIST) +endif else driverexec_PROGRAMS += skel endif @@ -116,7 +123,6 @@ liebert_SOURCES = liebert.c liebert_esp2_SOURCES = liebert-esp2.c masterguard_SOURCES = masterguard.c metasys_SOURCES = metasys.c -oldmge_shut_SOURCES = mge-shut.c hidparser.c mge_utalk_SOURCES = mge-utalk.c microdowell_SOURCES = microdowell.c oneac_SOURCES = oneac.c @@ -165,9 +171,9 @@ skel_SOURCES = skel.c skel_LDADD = $(LDADD_DRIVERS) # USB -USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c ever-hid.c explore-hid.c \ +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 ever-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) @@ -225,6 +231,10 @@ macosx_ups_LDADD = $(LDADD_DRIVERS) macosx_ups_LDFLAGS = $(LDFLAGS) -framework IOKit -framework CoreFoundation macosx_ups_SOURCES = macosx-ups.c +# Modbus driver +phoenixcontact_modbus_SOURCES = phoenixcontact_modbus.c +phoenixcontact_modbus_LDADD = $(LDADD_DRIVERS) $(LIBMODBUS_LIBS) + # Asem asem_LDADD = $(LDADD_DRIVERS) asem_SOURCES = asem.c @@ -255,9 +265,9 @@ nutdrv_qx_SOURCES += $(NUTDRV_QX_SUBDRIVERS) dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \ bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \ - dummy-ups.h eaton-mib.h ever-hid.c explore-hid.h gamatronic.h genericups.h \ + dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \ hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h libusb.h liebert-hid.h \ - main.h mge-hid.h mge-mib.h mge-shut.h mge-utalk.h \ + main.h mge-hid.h mge-mib.h mge-utalk.h \ mge-xml.h microdowell.h netvision-mib.h netxml-ups.h nut-ipmi.h oneac.h \ powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \ safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \ @@ -267,7 +277,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \ nutdrv_qx_megatec.h nutdrv_qx_megatec-old.h nutdrv_qx_mustek.h nutdrv_qx_q1.h \ nutdrv_qx_voltronic.h nutdrv_qx_voltronic-qs.h nutdrv_qx_voltronic-qs-hex.h nutdrv_qx_zinto.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 + apc-pdu-mib.h ever-hid.h # Define a dummy library so that Automake builds rules for the # corresponding object files. This library is not actually built, From 8d7d6b57e7c59e87f0b5343a10067a03c110b414 Mon Sep 17 00:00:00 2001 From: EVER-PowerSystems Date: Mon, 12 Jun 2017 14:46:18 +0200 Subject: [PATCH 03/70] fixed NUT names --- drivers/ever-hid.c | 202 ++++++++++++++++++++++----------------------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 0f7ba4aee8..d544bda09a 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -452,104 +452,104 @@ static usage_tables_t ever_utab[] = { static hid_info_t ever_hid2nut[] = { - { "ups.batterysystem.battery.batteryid", 0, 0, "UPS.BatterySystem.Battery.BatteryID", NULL, "%.0f", 0, NULL }, - { "ups.batterysystem.batterysystemid", 0, 0, "UPS.BatterySystem.BatterySystemID", NULL, "%.0f", 0, NULL }, - { "ups.batterysystem.charger.chargerid", 0, 0, "UPS.BatterySystem.Charger.ChargerID", NULL, "%.0f", 0, NULL }, - { "ups.batterysystem.input.flowid", 0, 0, "UPS.BatterySystem.Input.FlowID", NULL, "%.0f", 0, NULL }, - { "ups.batterysystem.input.inputid", 0, 0, "UPS.BatterySystem.Input.InputID", NULL, "%.0f", 0, NULL }, - { "ups.batterysystem.output.flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, - { "ups.batterysystem.output.outputid", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, - /*{ "ever.identyfication.upstype", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model },*/ - { "ever.identyfication.firmware.inverter.version", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, - { "ever.identyfication.firmware.interfaces.version", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, - { "ever.identyfication.hardware.version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, - { "ever.identyfication.protocol.inverter.version", 0, 0, "UPS.EVER1.EVER16", NULL, "%s", 0, ever_format_version }, - { "ever.identyfication.protocol.interfaces.version", 0, 0, "UPS.EVER1.EVER17", NULL, "%s", 0, ever_format_version }, - { "ever.hitsinktemperature", 0, 0, "UPS.EVER1.EVER42", NULL, "%s", 0, kelvin_celsius_conversion }, - { "ever.batterytemperature", 0, 0, "UPS.EVER1.EVER43", NULL, "%s", 0, kelvin_celsius_conversion }, - { "ever.outputpowerfactor", 0, 0, "UPS.EVER1.EVER44", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.upson", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER46", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.clearfault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER47", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.clearbatteryfault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER48", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.epoblocked", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER50", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.greenmode", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER51", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.buttonsound", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER52", NULL, "%.0f", 0, NULL }, - { "ever.ups.control.audiblealarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, - { "ever.ups.config.outputvoltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, - /*{ "ever.ups.config.minoutputvoltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, - { "ever.ups.config.maxoutputvoltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, - { "ever.ups.config.minoutputfrequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, - { "ever.ups.config.maxoutputfrequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL },*/ - { "ever.ups.config.overloadclearancethreshold", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER59", NULL, "%.0f", 0, NULL }, - { "ever.ups.config.stbcharge", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER60", NULL, "%.0f", 0, NULL }, - { "ever.ups.config.numberofebms", ST_FLAG_RW | ST_FLAG_STRING, 1, "UPS.EVER1.EVER61", NULL, "%.0f", 0, NULL }, - { "ever.statistics.mainslosscounter", 0, 0, "UPS.EVER1.EVER62", NULL, "%.0f", 0, NULL }, - { "ever.statistics.loweringAVRtriggercounter", 0, 0, "UPS.EVER1.EVER63", NULL, "%.0f", 0, NULL }, - { "ever.statistics.risingAVRtriggercounter", 0, 0, "UPS.EVER1.EVER64", NULL, "%.0f", 0, NULL }, - { "ever.statistics.overloadcounter", 0, 0, "UPS.EVER1.EVER65", NULL, "%.0f", 0, NULL }, - { "ever.statistics.shortcircuitcounter", 0, 0, "UPS.EVER1.EVER66", NULL, "%.0f", 0, NULL }, - { "ever.statistics.dischargecounter", 0, 0, "UPS.EVER1.EVER67", NULL, "%.0f", 0, NULL }, - { "ever.statistics.overheatcounter", 0, 0, "UPS.EVER1.EVER68", NULL, "%.0f", 0, NULL }, - { "ever.statistics.mainsoperationtime", 0, 0, "UPS.EVER1.EVER69", NULL, "%.0f", 0, NULL }, - { "ever.statistics.autonomousoperationtime", 0, 0, "UPS.EVER1.EVER70", NULL, "%.0f", 0, NULL }, - { "ever.statistics.overloadoperationtime", 0, 0, "UPS.EVER1.EVER71", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.macaddress", 0, 0, "UPS.EVER1.EVER72", NULL, "%s", 0, ever_mac_address }, - { "ever.networkcard.notificationdestinationip", 0, 0, "UPS.EVER1.EVER73", NULL, "%s", 0, ever_ip_address }, - { "ever.networkcard.statistics.sendpackets", 0, 0, "UPS.EVER1.EVER77", NULL, "%s", 0, ever_packets }, - { "ever.networkcard.statistics.receivedpackets", 0, 0, "UPS.EVER1.EVER78", NULL, "%s", 0, ever_packets }, - { "ever.networkcard.statistics.sendpacketserrors", 0, 0, "UPS.EVER1.EVER79", NULL, "%s", 0, ever_packets }, - { "ever.networkcard.statistics.receivedpacketserrors", 0, 0, "UPS.EVER1.EVER80", NULL, "%s", 0, ever_packets }, - { "ever.networkcard.config.dhcpenabled", 0, 0, "UPS.EVER1.EVER85.EVER86", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.config.ethernetenabled", 0, 0, "UPS.EVER1.EVER85.EVER87", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.config.httpenabled", 0, 0, "UPS.EVER1.EVER85.EVER88", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.config.snmpenabled", 0, 0, "UPS.EVER1.EVER85.EVER89", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.config.snmptrapenabled", 0, 0, "UPS.EVER1.EVER85.EVER90", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.config.readonly", 0, 0, "UPS.EVER1.EVER85.EVER91", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.config.restarteth", 0, 0, "UPS.EVER1.EVER85.EVER96", NULL, "%.0f", 0, NULL }, - { "ever.networkcard.ipaddress", 0, 0, "UPS.EVER1.EVER93", NULL, "%s", 0, ever_ip_address }, - { "ever.networkcard.networkmask", 0, 0, "UPS.EVER1.EVER94", NULL, "%s", 0, ever_ip_address }, - { "ever.networkcard.defaultgateway", 0, 0, "UPS.EVER1.EVER95", NULL, "%s", 0, ever_ip_address }, - { "ups.flow.configactivepower", 0, 0, "UPS.Flow.ConfigActivePower", NULL, "%.0f", 0, NULL }, - { "ups.flow.configapparentpower", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, - { "ups.flow.configfrequency", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, - { "ups.flow.configvoltage", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, - { "ups.flow.flowid", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", 0, NULL }, - { "ups.outletsystem.outlet.outletid", 0, 0, "UPS.OutletSystem.Outlet.OutletID", NULL, "%.0f", 0, NULL }, - { "ups.outletsystem.outlet.presentstatus.present", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Present", NULL, "%.0f", 0, yes_no_info }, - { "ups.outletsystem.outlet.presentstatus.switchable", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Switchable", NULL, "%.0f", 0, yes_no_info }, - { "ups.outletsystem.outlet.presentstatus.switchon/off", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.SwitchOn/Off", NULL, "%.0f", 0, NULL }, - { "ups.outletsystem.outlet.presentstatus.undefined", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Undefined", NULL, "%.0f", 0, NULL }, - { "ups.outletsystem.outlet.switchoffcontrol", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOffControl", NULL, "%.0f", 0, NULL }, - { "ups.outletsystem.outlet.switchoncontrol", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOnControl", NULL, "%.0f", 0, NULL }, - { "ups.outletsystem.outletsystemid", 0, 0, "UPS.OutletSystem.OutletSystemID", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.input.flowid", 0, 0, "UPS.PowerConverter.Input.FlowID", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.input.inputid", 0, 0, "UPS.PowerConverter.Input.InputID", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.activepower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.apparentpower", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.flowid", 0, 0, "UPS.PowerConverter.Output.FlowID", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.outputid", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.percentload", 0, 0, "UPS.PowerConverter.Output.PercentLoad", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, - { "ups.powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.capacitygranularity1", 0, 0, "UPS.PowerSummary.CapacityGranularity1", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.capacitygranularity2", 0, 0, "UPS.PowerSummary.CapacityGranularity2", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.capacitymode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.delaybeforeshutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL }, - { "ups.powersummary.designcapacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.flowid", 0, 0, "UPS.PowerSummary.FlowID", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.fullchargecapacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.idevicechemistry", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.percentload", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.rechargeable", 0, 0, "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.remainingcapacity", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.remainingtimelimit", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.runtimetoempty", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, - { "ups.powersummary.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, - { "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + { "battery.batteryid", 0, 0, "UPS.BatterySystem.Battery.BatteryID", NULL, "%.0f", 0, NULL }, + { "battery.systemid", 0, 0, "UPS.BatterySystem.BatterySystemID", NULL, "%.0f", 0, NULL }, + { "battery.chargerid", 0, 0, "UPS.BatterySystem.Charger.ChargerID", NULL, "%.0f", 0, NULL }, + { "battery.input_flowid", 0, 0, "UPS.BatterySystem.Input.FlowID", NULL, "%.0f", 0, NULL }, + { "battery.input_id", 0, 0, "UPS.BatterySystem.Input.InputID", NULL, "%.0f", 0, NULL }, + { "battery.output_flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, + { "battery.output_id", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, + /*{ "id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model },*/ + { "id.firmware_version_inverter", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, + { "id.firmware_version_interfaces", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, + { "id.hardware_version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, + { "id.protocol_version_inverter", 0, 0, "UPS.EVER1.EVER16", NULL, "%s", 0, ever_format_version }, + { "id.protocol_version_interfaces", 0, 0, "UPS.EVER1.EVER17", NULL, "%s", 0, ever_format_version }, + { "inverter_info.heatsink_temperature", 0, 0, "UPS.EVER1.EVER42", NULL, "%s", 0, kelvin_celsius_conversion }, + { "inverter_info.battery_temperature", 0, 0, "UPS.EVER1.EVER43", NULL, "%s", 0, kelvin_celsius_conversion }, + { "ups_info.output_powerfactor", 0, 0, "UPS.EVER1.EVER44", NULL, "%.0f", 0, NULL }, + { "control.ups_on", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER46", NULL, "%.0f", 0, NULL }, + { "control.clear_fault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER47", NULL, "%.0f", 0, NULL }, + { "control.clear_battery_fault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER48", NULL, "%.0f", 0, NULL }, + { "control.epo_blocked", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER50", NULL, "%.0f", 0, NULL }, + { "control.green_mode", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER51", NULL, "%.0f", 0, NULL }, + { "control.button_sound", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER52", NULL, "%.0f", 0, NULL }, + { "control.audible_alarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, + { "config.output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, + /*{ "config.min_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, + { "config.max_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, + { "config.min_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, + { "config.max_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL },*/ + { "config.overload_clearance_threshold", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER59", NULL, "%.0f", 0, NULL }, + { "config.stb_charge", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER60", NULL, "%.0f", 0, NULL }, + { "config.number_of_ebms", ST_FLAG_RW | ST_FLAG_STRING, 1, "UPS.EVER1.EVER61", NULL, "%.0f", 0, NULL }, + { "statistics.mains_loss_counter", 0, 0, "UPS.EVER1.EVER62", NULL, "%.0f", 0, NULL }, + { "statistics.lowering_AVR_trigger_counter", 0, 0, "UPS.EVER1.EVER63", NULL, "%.0f", 0, NULL }, + { "statistics.rising_AVR_trigger_counter", 0, 0, "UPS.EVER1.EVER64", NULL, "%.0f", 0, NULL }, + { "statistics.overload_counter", 0, 0, "UPS.EVER1.EVER65", NULL, "%.0f", 0, NULL }, + { "statistics.short_circuit_counter", 0, 0, "UPS.EVER1.EVER66", NULL, "%.0f", 0, NULL }, + { "statistics.discharge_counter", 0, 0, "UPS.EVER1.EVER67", NULL, "%.0f", 0, NULL }, + { "statistics.overheat_counter", 0, 0, "UPS.EVER1.EVER68", NULL, "%.0f", 0, NULL }, + { "statistics.mains_operation_time", 0, 0, "UPS.EVER1.EVER69", NULL, "%.0f", 0, NULL }, + { "statistics.autonomous_operation_time", 0, 0, "UPS.EVER1.EVER70", NULL, "%.0f", 0, NULL }, + { "statistics.overload_operation_time", 0, 0, "UPS.EVER1.EVER71", NULL, "%.0f", 0, NULL }, + { "networkcard.mac_address", 0, 0, "UPS.EVER1.EVER72", NULL, "%s", 0, ever_mac_address }, + { "networkcard.notification_destination_ip", 0, 0, "UPS.EVER1.EVER73", NULL, "%s", 0, ever_ip_address }, + { "networkcard.send_packets", 0, 0, "UPS.EVER1.EVER77", NULL, "%s", 0, ever_packets }, + { "networkcard.received_packets", 0, 0, "UPS.EVER1.EVER78", NULL, "%s", 0, ever_packets }, + { "networkcard.send_packets_err", 0, 0, "UPS.EVER1.EVER79", NULL, "%s", 0, ever_packets }, + { "networkcard.received_packets_err", 0, 0, "UPS.EVER1.EVER80", NULL, "%s", 0, ever_packets }, + { "networkcard.config_dhcp_enabled", 0, 0, "UPS.EVER1.EVER85.EVER86", NULL, "%.0f", 0, NULL }, + { "networkcard.config_ethernet_enabled", 0, 0, "UPS.EVER1.EVER85.EVER87", NULL, "%.0f", 0, NULL }, + { "networkcard.config_http_enabled", 0, 0, "UPS.EVER1.EVER85.EVER88", NULL, "%.0f", 0, NULL }, + { "networkcard.config_snmp_enabled", 0, 0, "UPS.EVER1.EVER85.EVER89", NULL, "%.0f", 0, NULL }, + { "networkcard.config_snmp_trap_enabled", 0, 0, "UPS.EVER1.EVER85.EVER90", NULL, "%.0f", 0, NULL }, + { "networkcard.config_readonly", 0, 0, "UPS.EVER1.EVER85.EVER91", NULL, "%.0f", 0, NULL }, + { "networkcard.config_restart_eth", 0, 0, "UPS.EVER1.EVER85.EVER96", NULL, "%.0f", 0, NULL }, + { "networkcard.ip_address", 0, 0, "UPS.EVER1.EVER93", NULL, "%s", 0, ever_ip_address }, + { "networkcard.network_mask", 0, 0, "UPS.EVER1.EVER94", NULL, "%s", 0, ever_ip_address }, + { "networkcard.default_gateway", 0, 0, "UPS.EVER1.EVER95", NULL, "%s", 0, ever_ip_address }, + { "id.config_active_power", 0, 0, "UPS.Flow.ConfigActivePower", NULL, "%.0f", 0, NULL }, + { "id.config_apparent_power", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, + { "ups.config_frequency", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, + { "ups.config_voltage", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "ups.flow_id", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", 0, NULL }, + { "outlet.outlet_id", 0, 0, "UPS.OutletSystem.Outlet.OutletID", NULL, "%.0f", 0, NULL }, + { "outlet.present", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Present", NULL, "%.0f", 0, yes_no_info }, + { "outlet.switchable", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Switchable", NULL, "%.0f", 0, yes_no_info }, + { "outlet.switch_on_off", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.SwitchOn/Off", NULL, "%.0f", 0, NULL }, + { "outlet.undefined", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Undefined", NULL, "%.0f", 0, NULL }, + { "outlet.switch_off_control", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOffControl", NULL, "%.0f", 0, NULL }, + { "outlet.switch_on_control", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOnControl", NULL, "%.0f", 0, NULL }, + { "outlet.system_id", 0, 0, "UPS.OutletSystem.OutletSystemID", NULL, "%.0f", 0, NULL }, + { "powerconverter.input_flow_id", 0, 0, "UPS.PowerConverter.Input.FlowID", NULL, "%.0f", 0, NULL }, + { "powerconverter.input_frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.0f", 0, NULL }, + { "powerconverter.input_id", 0, 0, "UPS.PowerConverter.Input.InputID", NULL, "%.0f", 0, NULL }, + { "powerconverter.input_voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_active_power", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_apparent_power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_flowid", 0, 0, "UPS.PowerConverter.Output.FlowID", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_id", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_percent_load", 0, 0, "UPS.PowerConverter.Output.PercentLoad", NULL, "%.0f", 0, NULL }, + { "powerconverter.output_voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, + { "powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", 0, NULL }, + { "powersummary.capacity_granularity_1", 0, 0, "UPS.PowerSummary.CapacityGranularity1", NULL, "%.0f", 0, NULL }, + { "powersummary.capacity_granularity_2", 0, 0, "UPS.PowerSummary.CapacityGranularity2", NULL, "%.0f", 0, NULL }, + { "powersummary.capacity_mode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, + { "powersummary.delay_before_shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL }, + { "powersummary.design_capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, + { "powersummary.flow_id", 0, 0, "UPS.PowerSummary.FlowID", NULL, "%.0f", 0, NULL }, + { "powersummary.full_charge_capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, + { "powersummary.idevice_chemistry", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%.0f", 0, NULL }, + { "powersummary.percent_load", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL }, + { "powersummary.rechargeable", 0, 0, "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL }, + { "powersummary.remaining_capacity", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, + { "powersummary.remaining_time_limit", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", 0, NULL }, + { "powersummary.run_time_to_empty", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, + { "powersummary.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, + { "powersummary.delay_before_shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, /*{ "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL },*/ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.AwaitingPower", NULL, NULL, HU_FLAG_QUICK_POLL, awaitingpower_info }, @@ -579,9 +579,9 @@ static hid_info_t ever_hid2nut[] = { { "BOOL", 0, 0, "UPS.EVER1.EVER97.EVER102", NULL, "%s", 0, ever_on_off_info }, /* ever workmodes, messages & alarms */ - { "ever.ups.status.workmode", 0, 0, "UPS.EVER1.EVER97.EVER98", NULL, "%s", 0, ever_workmode }, - { "ever.ups.status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, - { "ever.ups.status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, + { "status.workmode", 0, 0, "UPS.EVER1.EVER97.EVER98", NULL, "%s", 0, ever_workmode }, + { "status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, + { "status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, /* instant commands */ { "load.off.delay", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, From 22c61eba5a4fcc989f888119aede09f876e8d417 Mon Sep 17 00:00:00 2001 From: EVER-PowerSystems Date: Mon, 12 Jun 2017 15:22:12 +0200 Subject: [PATCH 04/70] fixed status names, added comments, fixed duplicates --- drivers/ever-hid.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index d544bda09a..5207e6fb2b 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -210,18 +210,21 @@ static const char* ever_messages_fun(double value) int n = 0; /* number of characters currently in line */ + /* duplicate of ups.status: OB LB*/ + /* if(messages & 0x01) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERLOAD"); if(messages & 0x02) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BATTERY_LOW"); + */ if(messages & 0x04) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BOOST"); if(messages & 0x08) - n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "TRIM"); + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BUCK"); if(messages & 0x10) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BOOST_BLOCKED"); if(messages & 0x20) - n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "TRIM_BLOCKED"); + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BUCK_BLOCKED"); if(messages & 0x40) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "CHARGING"); if(messages & 0x80) @@ -257,7 +260,7 @@ static const char* ever_alarms_fun(double value) if(alarms & 0x01) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERLOAD"); if(alarms & 0x02) - n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "SHORTCUT"); + n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "SHORT-CIRCUIT"); if(alarms & 0x04 || alarms & 0x08) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERHEAT"); if(alarms & 0x10) @@ -459,7 +462,8 @@ static hid_info_t ever_hid2nut[] = { { "battery.input_id", 0, 0, "UPS.BatterySystem.Input.InputID", NULL, "%.0f", 0, NULL }, { "battery.output_flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, { "battery.output_id", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, - /*{ "id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model },*/ + /* not implemented*/ + /*{ "id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model },*/ { "id.firmware_version_inverter", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, { "id.firmware_version_interfaces", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, { "id.hardware_version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, @@ -476,6 +480,7 @@ static hid_info_t ever_hid2nut[] = { { "control.button_sound", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER52", NULL, "%.0f", 0, NULL }, { "control.audible_alarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, { "config.output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, + /* not implemented*/ /*{ "config.min_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, { "config.max_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, { "config.min_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, @@ -550,21 +555,25 @@ static hid_info_t ever_hid2nut[] = { { "powersummary.run_time_to_empty", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, { "powersummary.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, { "powersummary.delay_before_shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + /* not implemented*/ /*{ "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL },*/ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.AwaitingPower", NULL, NULL, HU_FLAG_QUICK_POLL, awaitingpower_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, 0, nobattery_info }, + /* not implemented*/ /* { "ups.presentstatus.belowremainingcapacitylimit", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, "%.0f", 0, NULL }, */ /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Boost", NULL, NULL, 0, boost_info }, */ /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Buck", NULL, NULL, 0, trim_info }, */ /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info },*/ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.CommunicationLost", NULL, NULL, 0, commfault_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + /* not implemented*/ /* { "ups.powersummary.presentstatus.good", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, "%.0f", 0, NULL }, */ /* { "ups.powersummary.presentstatus.internalfailure", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, "%.0f", 0, NULL }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, + /* not implemented*/ /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, 0, lowbatt_info }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, From ab6952ae862d7bed1ac6e3a06bbb6929706bdeeb Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 7 Nov 2020 22:52:58 +0100 Subject: [PATCH 05/70] Update ever-hid.c Small whitespace fixes --- drivers/ever-hid.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 5207e6fb2b..328fa62e14 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -210,13 +210,13 @@ static const char* ever_messages_fun(double value) int n = 0; /* number of characters currently in line */ - /* duplicate of ups.status: OB LB*/ + /* duplicate of ups.status: OB LB */ /* if(messages & 0x01) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERLOAD"); if(messages & 0x02) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BATTERY_LOW"); - */ + */ if(messages & 0x04) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BOOST"); if(messages & 0x08) @@ -463,7 +463,7 @@ static hid_info_t ever_hid2nut[] = { { "battery.output_flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, { "battery.output_id", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, /* not implemented*/ - /*{ "id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model },*/ + /* { "id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model }, */ { "id.firmware_version_inverter", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, { "id.firmware_version_interfaces", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, { "id.hardware_version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, @@ -481,10 +481,12 @@ static hid_info_t ever_hid2nut[] = { { "control.audible_alarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, { "config.output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, /* not implemented*/ - /*{ "config.min_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, + /* + { "config.min_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, { "config.max_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, { "config.min_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, - { "config.max_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL },*/ + { "config.max_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL }, + */ { "config.overload_clearance_threshold", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER59", NULL, "%.0f", 0, NULL }, { "config.stb_charge", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER60", NULL, "%.0f", 0, NULL }, { "config.number_of_ebms", ST_FLAG_RW | ST_FLAG_STRING, 1, "UPS.EVER1.EVER61", NULL, "%.0f", 0, NULL }, @@ -556,15 +558,15 @@ static hid_info_t ever_hid2nut[] = { { "powersummary.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, { "powersummary.delay_before_shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, /* not implemented*/ - /*{ "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL },*/ + /* { "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.AwaitingPower", NULL, NULL, HU_FLAG_QUICK_POLL, awaitingpower_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, 0, nobattery_info }, /* not implemented*/ /* { "ups.presentstatus.belowremainingcapacitylimit", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, "%.0f", 0, NULL }, */ - /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Boost", NULL, NULL, 0, boost_info }, */ - /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Buck", NULL, NULL, 0, trim_info }, */ - /*{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info },*/ + /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Boost", NULL, NULL, 0, boost_info }, */ + /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Buck", NULL, NULL, 0, trim_info }, */ + /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.CommunicationLost", NULL, NULL, 0, commfault_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, /* not implemented*/ From 00e6386b6a2550c55db150478f7327e186d8ff91 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 7 Nov 2020 22:56:38 +0100 Subject: [PATCH 06/70] Update acknowledgements.txt Acknowledge a vendor contribution from EVER Power Systems --- docs/acknowledgements.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/acknowledgements.txt b/docs/acknowledgements.txt index ce1c03a497..01bc00aa9a 100644 --- a/docs/acknowledgements.txt +++ b/docs/acknowledgements.txt @@ -92,6 +92,10 @@ support in NUT.* revived the 'sec' driver (as gamatronic), and expanded a bit genericups for its UPSs with alarm interface. +* link:https://ever.eu/[EVER Power Systems], through David, added a +USB HID subdriver for EVER UPSes (Sinline RT Series, Sinline RT XL Series, +ECO PRO AVR CDS Series). + * link:http://www.microdowell.com[Microdowell], through Elio Corbolante, has created the 'microdowell' driver to support the Enterprise Nxx/Bxx serial devices. They also proposes NUT as an alternative to its software for From 8ed1101c219ff3b1f8aebdff7fade325acbcf5be Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 9 Nov 2020 20:38:42 +0100 Subject: [PATCH 07/70] Update nut.dict Add EVER Sinline model name --- docs/nut.dict | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/nut.dict b/docs/nut.dict index 5573685da3..c9f8cfe614 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2491 utf-8 +personal_ws-1.1 en 2492 utf-8 AAS ACFAIL ACFREQ @@ -965,6 +965,7 @@ Sicon Sidorov Signetic Silvino +Sinline Sistem Sistemas Slackware From a73a8e79b01f908c066eea97e94404785e1ec3b3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 12 Nov 2020 00:14:28 +0100 Subject: [PATCH 08/70] Update acknowledgements.txt Do not constrain contribution from EVER Power Systems to one person --- docs/acknowledgements.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/acknowledgements.txt b/docs/acknowledgements.txt index 3341c063a0..622f9d6376 100644 --- a/docs/acknowledgements.txt +++ b/docs/acknowledgements.txt @@ -92,9 +92,8 @@ support in NUT.* revived the 'sec' driver (as gamatronic), and expanded a bit genericups for its UPSs with alarm interface. -* link:https://ever.eu/[EVER Power Systems], through David, added a -USB HID subdriver for EVER UPSes (Sinline RT Series, Sinline RT XL Series, -ECO PRO AVR CDS Series). +* link:https://ever.eu/[EVER Power Systems] added a USB HID subdriver for +EVER UPSes (Sinline RT Series, Sinline RT XL Series, ECO PRO AVR CDS Series). * link:http://www.microdowell.com[Microdowell], through Elio Corbolante, has created the 'microdowell' driver to support the Enterprise Nxx/Bxx serial From b62631477742cf7865e9f6b9928ea53c84c95c29 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 12 Nov 2020 10:16:03 +0100 Subject: [PATCH 09/70] 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 908ebf8c1e..bcb116e1c8 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2516 utf-8 +personal_ws-1.1 en 2517 utf-8 AAS ACFAIL ACFREQ @@ -143,6 +143,7 @@ CAs CBLimit CCC CCCC +CDS CELLPADDING CELLSPACING CERTHOST From c271a8af945b722cf50d300e1f99033332784761 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 23 Apr 2021 16:29:24 +0200 Subject: [PATCH 10/70] Update ever-hid.c Lowercase the hex in vendor ID macro, for consistency --- drivers/ever-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 328fa62e14..6c73809924 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -33,7 +33,7 @@ /* FIXME: experimental flag to be put in upsdrv_info */ /* Ever */ -#define EVER_VENDORID 0x2E51 +#define EVER_VENDORID 0x2e51 /* USB IDs device table */ static usb_device_id_t ever_usb_device_table[] = { From f62677d6a0596721e160d96ba8eee7d20e2f8e21 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 23 Apr 2021 16:33:00 +0200 Subject: [PATCH 11/70] Update ever-hid.c Make and comment the macro for ST Microelectronics vendor id (to generate udev data, etc. properly) --- drivers/ever-hid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 6c73809924..247c8c52b9 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -35,10 +35,13 @@ /* Ever */ #define EVER_VENDORID 0x2e51 +/* ST Microelectronics */ +#define STMICRO_VENDORID 0x0483 + /* USB IDs device table */ static usb_device_id_t ever_usb_device_table[] = { - { USB_DEVICE(0x0483, 0xa113), NULL }, + { USB_DEVICE(STMICRO_VENDORID, 0xa113), NULL }, { USB_DEVICE(EVER_VENDORID, 0xffff), NULL}, From 508dd645f12f1dc977c29077533d0ca10cd3dce4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 13 Nov 2021 19:40:12 +0100 Subject: [PATCH 12/70] drivers/snmp-ups.h: redefine bit-flags macros so they do not overlap (and some helper-masking macros) [follow up on issue from PR #1177] --- drivers/snmp-ups.h | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 528b7c5e45..6b9b46de22 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -168,53 +168,44 @@ typedef struct { #define SU_FLAG_UNIQUE (1UL << 5) /* There can be only be one * provider of this info, * disable the other providers */ -/* Free slot +/* Note: older releases defined the following flag, but removed it by 2.7.5: * #define SU_FLAG_SETINT (1UL << 6)*/ /* save value */ -#define SU_OUTLET (1UL << 7) /* outlet template definition */ +#define SU_FLAG_ZEROINVALID (1UL << 6) /* Invalid if "0" value */ +#define SU_FLAG_NAINVALID (1UL << 7) /* Invalid if "N/A" value */ #define SU_CMD_OFFSET (1UL << 8) /* Add +1 to the OID index */ + +/* Reserved slot (1UL << 9) -- to import SU_FLAG_FUNCTION from DMF branch codebase */ + /* Notes on outlet templates usage: * - outlet.count MUST exist and MUST be declared before any outlet template * Otherwise, the driver will try to determine it by itself... * - the first outlet template MUST NOT be a server side variable (ie MUST have * a valid OID) in order to detect the base SNMP index (0 or 1) */ -/* Reserved slot (1UL << 9) -- to import from DMF branch codebase */ - -/* status string components - * FIXME: these should be removed, since there is no added value. - * Ie, this can be guessed from info->type! */ - -/* "flags" value 0, or bits 8..9, or "8 and 9" */ -#define SU_STATUS_PWR (0UL << 8) /* indicates power status element */ -#define SU_STATUS_BATT (1UL << 8) /* indicates battery status element */ -#define SU_STATUS_CAL (2UL << 8) /* indicates calibration status element */ -#define SU_STATUS_RB (3UL << 8) /* indicates replace battery status element */ -#define SU_STATUS_NUM_ELEM 4 /* Obsolete? No references found in codebase */ -#define SU_STATUS_INDEX(t) (((unsigned long)(t) >> 8) & 7UL) /* "flags" bit 10 */ #define SU_OUTLET_GROUP (1UL << 10) /* outlet group template definition */ +#define SU_OUTLET (1UL << 11) /* outlet template definition */ /* Phase specific data */ /* "flags" bits 12..17 */ -#define SU_PHASES (0x0000003F << 12) -#define SU_INPHASES (0x00000003 << 12) -#define SU_INPUT_1 (1UL << 12) /* only if 1 input phase */ -#define SU_INPUT_3 (1UL << 13) /* only if 3 input phases */ -#define SU_OUTPHASES (0x00000003 << 14) -#define SU_OUTPUT_1 (1UL << 14) /* only if 1 output phase */ -#define SU_OUTPUT_3 (1UL << 15) /* only if 3 output phases */ -#define SU_BYPPHASES (0x00000003 << 16) -#define SU_BYPASS_1 (1UL << 16) /* only if 1 bypass phase */ -#define SU_BYPASS_3 (1UL << 17) /* only if 3 bypass phases */ +#define SU_PHASES (0x0000003F << 12) +#define SU_INPHASES (0x00000003 << 12) +#define SU_INPUT_1 (1UL << 12) /* only if 1 input phase */ +#define SU_INPUT_3 (1UL << 13) /* only if 3 input phases */ +#define SU_OUTPHASES (0x00000003 << 14) +#define SU_OUTPUT_1 (1UL << 14) /* only if 1 output phase */ +#define SU_OUTPUT_3 (1UL << 15) /* only if 3 output phases */ +#define SU_BYPPHASES (0x00000003 << 16) +#define SU_BYPASS_1 (1UL << 16) /* only if 1 bypass phase */ +#define SU_BYPASS_3 (1UL << 17) /* only if 3 bypass phases */ /* FIXME: use input.phases and output.phases to replace this */ /* hints for su_ups_set, applicable only to rw vars */ -/* "flags" value 0, or bits 18..19, or "18 and 19" */ -#define SU_TYPE_INT (0UL << 18) /* cast to int when setting value */ -/* Free slot (1UL << 18) */ -#define SU_TYPE_TIME (2UL << 18) /* cast to int */ -#define SU_TYPE_CMD (3UL << 18) /* instant command */ +/* "flags" bits 18..20 */ +#define SU_TYPE_INT (1UL << 18) /* cast to int when setting value */ +#define SU_TYPE_TIME (1UL << 19) /* cast to int */ +#define SU_TYPE_CMD (1UL << 20) /* instant command */ /* The following helper macro is used like: * if (SU_TYPE(su_info_p) == SU_TYPE_CMD) { ... } */ @@ -225,16 +216,26 @@ typedef struct { * in the formatting string. This is useful when considering daisychain with * templates, such as outlets / outlets groups, which already have a format * string specifier */ -/* "flags" bits 19..20, and 20 again */ -#define SU_TYPE_DAISY_1 (1UL << 19) /* Daisychain index is the 1st specifier */ -#define SU_TYPE_DAISY_2 (2UL << 19) /* Daisychain index is the 2nd specifier */ -#define SU_TYPE_DAISY(t) ((t)->flags & (7UL << 19)) -#define SU_DAISY (2UL << 19) /* Daisychain template definition */ +/* "flags" bits 21..23 */ +#define SU_TYPE_DAISY_1 (1UL << 21) /* Daisychain index is the 1st specifier */ +#define SU_TYPE_DAISY_2 (1UL << 22) /* Daisychain index is the 2nd specifier */ +#define SU_TYPE_DAISY(t) ((t)->flags & (7UL << 21)) /* FIXME? Mask with 7 or 3 here? */ +#define SU_DAISY (1UL << 23) /* Daisychain template definition */ +/* NOTE: Previously SU_DAISY had same bit-flag value as SU_TYPE_DAISY_2*/ + +/* status string components + * FIXME: these should be removed, since there is no added value. + * Ie, this can be guessed from info->type! */ -/* "flags" bits 20..21 */ -#define SU_FLAG_ZEROINVALID (1UL << 20) /* Invalid if "0" value */ -#define SU_FLAG_NAINVALID (1UL << 21) /* Invalid if "N/A" value */ +/* "flags" bits 24..27 */ +#define SU_STATUS_PWR (1UL << 24) /* indicates power status element */ +#define SU_STATUS_BATT (1UL << 25) /* indicates battery status element */ +#define SU_STATUS_CAL (1UL << 26) /* indicates calibration status element */ +#define SU_STATUS_RB (1UL << 27) /* indicates replace battery status element */ +#define SU_STATUS_NUM_ELEM 4 /* Obsolete? No references found in codebase */ +#define SU_STATUS_INDEX(t) (((unsigned long)(t) >> 24) & 15UL) +/* Despite similar names, definitons below are not among the bit-flags ;) */ #define SU_VAR_COMMUNITY "community" #define SU_VAR_VERSION "snmp_version" #define SU_VAR_RETRIES "snmp_retries" From 4eb9bf79b399c823dbd2c7db62ca2e1bd12b4697 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 13 Nov 2021 20:11:26 +0100 Subject: [PATCH 13/70] drivers/snmp-ups.c: report if an snmp_info[] entry flag was not defined (is 0) --- drivers/snmp-ups.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 3ea8bedc8f..7ac575fc3c 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -211,6 +211,17 @@ void upsdrv_initinfo(void) * outlet (and groups) commands are processed later, during initial walk */ for (su_info_p = &snmp_info[0]; (su_info_p != NULL && su_info_p->info_type != NULL) ; su_info_p++) { + if (su_info_p->flags == 0UL) { + upsdebugx(0, + "SNMP UPS driver: %s: MIB2NUT mapping '%s' (OID '%s') did not define flags bits. " + "Please report as a bug to the NUT maintainers.", + __func__, + (su_info_p->info_type ? su_info_p->info_type : ""), + (su_info_p->OID ? su_info_p->OID : "") + ); + /* FIXME? Bail out of driver here? Ignore the entry? */ + } + su_info_p->flags |= SU_FLAG_OK; if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && !(su_info_p->flags & SU_OUTLET) From 9c83480844b057b54f7fbe3432197ab2c9422c9a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 22 Nov 2021 21:31:46 +0100 Subject: [PATCH 14/70] drivers/snmp-ups.h: update mask for SU_TYPE_DAISY() and comments for it and SU_DAISY --- drivers/snmp-ups.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 6b9b46de22..494bbc2500 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -219,8 +219,8 @@ typedef struct { /* "flags" bits 21..23 */ #define SU_TYPE_DAISY_1 (1UL << 21) /* Daisychain index is the 1st specifier */ #define SU_TYPE_DAISY_2 (1UL << 22) /* Daisychain index is the 2nd specifier */ -#define SU_TYPE_DAISY(t) ((t)->flags & (7UL << 21)) /* FIXME? Mask with 7 or 3 here? */ -#define SU_DAISY (1UL << 23) /* Daisychain template definition */ +#define SU_TYPE_DAISY(t) ((t)->flags & (3UL << 21)) /* Mask the 2 SU_TYPE_DAISY_* but not SU_DAISY */ +#define SU_DAISY (1UL << 23) /* Daisychain template definition - set at run-time for devices with detected "device.count" over 1 */ /* NOTE: Previously SU_DAISY had same bit-flag value as SU_TYPE_DAISY_2*/ /* status string components From ef4aee4c038bb8fcd3bb73a3dc86e3d5d5e88d1c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 23 Jan 2022 02:58:38 +0100 Subject: [PATCH 15/70] drivers/snmp-ups.h: redefine bit-flags macros so they do not overlap (and update some helper-masking macros) follows up on issue from PR #1177 and aligns with ultimately DMF (42ity fork) tested changes to help merge that later with less effort --- drivers/snmp-ups.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 494bbc2500..7a99da3613 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -174,7 +174,9 @@ typedef struct { #define SU_FLAG_NAINVALID (1UL << 7) /* Invalid if "N/A" value */ #define SU_CMD_OFFSET (1UL << 8) /* Add +1 to the OID index */ -/* Reserved slot (1UL << 9) -- to import SU_FLAG_FUNCTION from DMF branch codebase */ +/* Reserved slot -- to import from DMF branch codebase: +//#define SU_FLAG_SEMI_STATIC (1UL << 9)*/ /* Refresh this entry once in several walks +// * (for R/W values user can set on device, like descriptions or contacts) */ /* Notes on outlet templates usage: * - outlet.count MUST exist and MUST be declared before any outlet template @@ -216,24 +218,36 @@ typedef struct { * in the formatting string. This is useful when considering daisychain with * templates, such as outlets / outlets groups, which already have a format * string specifier */ -/* "flags" bits 21..23 */ +/* "flags" bits 21..23 (and 24 reserved for DMF) */ #define SU_TYPE_DAISY_1 (1UL << 21) /* Daisychain index is the 1st specifier */ #define SU_TYPE_DAISY_2 (1UL << 22) /* Daisychain index is the 2nd specifier */ #define SU_TYPE_DAISY(t) ((t)->flags & (3UL << 21)) /* Mask the 2 SU_TYPE_DAISY_* but not SU_DAISY */ #define SU_DAISY (1UL << 23) /* Daisychain template definition - set at run-time for devices with detected "device.count" over 1 */ /* NOTE: Previously SU_DAISY had same bit-flag value as SU_TYPE_DAISY_2*/ +/* Reserved slot -- to import from DMF branch codebase +// (and change SU_TYPE_DAISY to 11UL<<21 for the 3 types then): +//#define SU_TYPE_DAISY_MASTER_ONLY (1UL << 24)*/ /* Only valid for daisychain master (device.1) */ + +/* Free slot: (1UL << 25) */ + +/* Reserved slot -- to import from DMF branch codebase: +//#define SU_AMBIENT_TEMPLATE (1UL << 26)*/ /* ambient template definition */ + +/* Reserved slot -- to import from DMF branch codebase: +//#define SU_FLAG_FUNCTION (1UL << 27) +*/ /* status string components * FIXME: these should be removed, since there is no added value. * Ie, this can be guessed from info->type! */ -/* "flags" bits 24..27 */ -#define SU_STATUS_PWR (1UL << 24) /* indicates power status element */ -#define SU_STATUS_BATT (1UL << 25) /* indicates battery status element */ -#define SU_STATUS_CAL (1UL << 26) /* indicates calibration status element */ -#define SU_STATUS_RB (1UL << 27) /* indicates replace battery status element */ +/* "flags" bits 28..31 */ +#define SU_STATUS_PWR (1UL << 28) /* indicates power status element */ +#define SU_STATUS_BATT (1UL << 29) /* indicates battery status element */ +#define SU_STATUS_CAL (1UL << 30) /* indicates calibration status element */ +#define SU_STATUS_RB (1UL << 31) /* indicates replace battery status element */ #define SU_STATUS_NUM_ELEM 4 /* Obsolete? No references found in codebase */ -#define SU_STATUS_INDEX(t) (((unsigned long)(t) >> 24) & 15UL) +#define SU_STATUS_INDEX(t) (((unsigned long)(t) >> 28) & 15UL) /* Despite similar names, definitons below are not among the bit-flags ;) */ #define SU_VAR_COMMUNITY "community" From d6356427f00db3b83d43c63c8b279fc032d4292e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 18 Jan 2022 20:15:43 +0100 Subject: [PATCH 16/70] drivers/snmp-ups.c: mib2nut mappings with "zero" flag value are not illegal Do not yell about them like it's a bug, after all. --- drivers/snmp-ups.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 7ac575fc3c..7ad1d45243 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -212,14 +212,14 @@ void upsdrv_initinfo(void) for (su_info_p = &snmp_info[0]; (su_info_p != NULL && su_info_p->info_type != NULL) ; su_info_p++) { if (su_info_p->flags == 0UL) { - upsdebugx(0, + upsdebugx(4, "SNMP UPS driver: %s: MIB2NUT mapping '%s' (OID '%s') did not define flags bits. " - "Please report as a bug to the NUT maintainers.", + "Entry would be treated as SU_FLAG_OK if available in returned data.", __func__, (su_info_p->info_type ? su_info_p->info_type : ""), (su_info_p->OID ? su_info_p->OID : "") ); - /* FIXME? Bail out of driver here? Ignore the entry? */ + /* Treat as OK if avail, otherwise discarded */ } su_info_p->flags |= SU_FLAG_OK; From 7056dc7a15235a8a393c276cd56e2e062fce5ee2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 23 Jan 2022 03:00:26 +0100 Subject: [PATCH 17/70] drivers/snmp-ups.h: mib2nut mappings with "zero" flag value are not illegal --- drivers/snmp-ups.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 7a99da3613..eb7c28d13c 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -149,6 +149,8 @@ typedef struct { * NOTE that some *-mib.c mappings can specify * a zero in this field... better fix that in * favor of explicit values with a meaning! + * Current code treats such zero values as + * "OK if avail, otherwise discarded". * NOTE: With C99+ a "long" is guaranteed to be * at least 4 bytes; consider "unsigned long long" * when/if we get more than 32 flag values. From 88e8a83ec38e013c1a625b1fb530786f90dc46ed Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 23 Jan 2022 15:13:40 +0100 Subject: [PATCH 18/70] NEWS, UPGRADING: snmp-ups.h flags (bit-mask macros) changed for NUT v2.7.5 --- NEWS | 2 ++ UPGRADING | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index bd48da0699..ac9220c69d 100644 --- a/NEWS +++ b/NEWS @@ -174,6 +174,8 @@ Release notes for NUT 2.7.5 - what's new since 2.7.4: for CyberPower, as well as shutdown and other instant commands * several rounds of updates for Eaton devices, including new ATS and ePDU hardware families + * fixed bit mask values for flags to surely use different numbers behind + logical items (inevitably changing some of those macro symbols) [PR #1180] - snmp-ups and nut-scanner should now support more SNMPv3 Auth and Priv protocols, as available at NUT build time [PRs #1165, #1172] diff --git a/UPGRADING b/UPGRADING index 430fc243ad..7ff3c3cf08 100644 --- a/UPGRADING +++ b/UPGRADING @@ -62,6 +62,12 @@ Changes from 2.7.4 to 2.7.5 preference of the detected script over `pkg-config` information, if both are available, and `--with-netsnmp-config=/path/name` would as well. +- snmp-ups: bit mask values for flags in earlier codebase were defined in a + way that caused logically different items to have same numeric values. + This was fixed to surely use different definitions (so changing numbers + behind some of those macro symbols), and testing with UPS, ePDU and ATS + hardware which was available did not expose any practical differences. + - usbhid-ups: numeric data conversion from wire protocol to CPU representation in GetValue() was completely reworked, aiming to be correct on all CPU types. That said, regressions are possible and feedback is welcome. From b14528fc3f7508d4355006ae1d3d06923787ebc4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 27 Jan 2022 03:50:28 +0100 Subject: [PATCH 19/70] Revert "tools/nut-scanner/scan_snmp.c, drivers/snmp-ups.c: strcmp() shorter "SHA" and "AES" and check this is all of the string length" This reverts commit 57182d51b2954e6b7bb5199f658f38a89ce93648. Currently the configure script should properly avoid the built-in strcmp() versions which upset current build compiler. Using the range-limited strncmp() has a downside of matching start-of-string. --- drivers/snmp-ups.c | 16 ++++------------ tools/nut-scanner/scan_snmp.c | 12 ++---------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 7ad1d45243..8f2afc68ed 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -810,21 +810,15 @@ void nut_snmp_init(const char *type, const char *hostname) g_snmp_sess.securityAuthKeyLen = USM_AUTH_KU_LEN; authProtocol = testvar(SU_VAR_AUTHPROT) ? getval(SU_VAR_AUTHPROT) : "MD5"; - /* Note: start with strcmp of the longer strings, - * or explicitly check the length (end of string), - * to avoid matching everything as e.g. "SHA" by - * strncmp() below - that was needed for platforms - * where strcmp() is a built-in/macro which offends - * alignment checks with short strings... */ #if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol - if (strncmp(authProtocol, "MD5", 3) == 0 && authProtocol[3] == '\0') { + if (strncmp(authProtocol, "MD5", 3) == 0) { g_snmp_sess.securityAuthProto = usmHMACMD5AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid); } else #endif #if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol - if (strncmp(authProtocol, "SHA", 3) == 0 && authProtocol[3] == '\0') { + if (strncmp(authProtocol, "SHA", 3) == 0) { g_snmp_sess.securityAuthProto = usmHMACSHA1AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/sizeof(oid); } @@ -893,17 +887,15 @@ net-snmp/library/keytools.h: int generate_Ku(const oid * hashtype, u_int ha privProtocol = testvar(SU_VAR_PRIVPROT) ? getval(SU_VAR_PRIVPROT) : "DES"; - /* Note: start with strcmp of the longer strings, or check string - * lengths explicitly, to avoid matching everything as e.g. "AES"! */ #if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol - if (strncmp(privProtocol, "DES", 3) == 0 && privProtocol[3] == '\0') { + if (strncmp(privProtocol, "DES", 3) == 0) { g_snmp_sess.securityPrivProto = usmDESPrivProtocol; g_snmp_sess.securityPrivProtoLen = sizeof(usmDESPrivProtocol)/sizeof(oid); } else #endif #if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol - if (strncmp(privProtocol, "AES", 3) == 0 && privProtocol[3] == '\0') { + if (strncmp(privProtocol, "AES", 3) == 0) { g_snmp_sess.securityPrivProto = usmAESPrivProtocol; g_snmp_sess.securityPrivProtoLen = NUT_securityPrivProtoLen; } diff --git a/tools/nut-scanner/scan_snmp.c b/tools/nut-scanner/scan_snmp.c index a028c8712f..e923d3887c 100644 --- a/tools/nut-scanner/scan_snmp.c +++ b/tools/nut-scanner/scan_snmp.c @@ -595,14 +595,8 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) #endif if (sec->authProtocol) { - /* Note: start with strcmp of the longer strings, - * or explicitly check string lengths (null char), - * to avoid matching everything as e.g. "SHA" by - * strncmp() below - that was needed for platforms - * where strcmp() is a built-in/macro which offends - * alignment checks with short strings... */ #if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol - if (strncmp(sec->authProtocol, "SHA", 3) == 0 && sec->authProtocol[3] == '\0') { + if (strncmp(sec->authProtocol, "SHA", 3) == 0) { snmp_sess->securityAuthProto = nut_usmHMACSHA1AuthProtocol; snmp_sess->securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/ @@ -695,10 +689,8 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) #endif if (sec->privProtocol) { - /* Note: start with strcmp of the longer strings, or check - * lengths, to avoid matching everything as e.g. "AES"! */ #if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol - if (strncmp(sec->privProtocol, "AES", 3) == 0 && sec->privProtocol[3] == '\0') { + if (strncmp(sec->privProtocol, "AES", 3) == 0) { snmp_sess->securityPrivProto = nut_usmAESPrivProtocol; snmp_sess->securityPrivProtoLen = sizeof(usmAESPrivProtocol)/ From 3ffd48048e86d5085776ac84afd327d892371f81 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 27 Jan 2022 03:53:07 +0100 Subject: [PATCH 20/70] Revert "Replace strcmp() and strcasecmp() use-cases for short fixed string args by strncmp() and strncasecmp() respectively" This reverts commit a0d5ad57956ebcb5878744acb7657e1356ba0ea8. Currently the configure script should properly avoid the built-in strcmp() versions which upset current build compiler. Using the range-limited strncmp() has a downside of matching start-of-string. --- clients/upsclient.c | 4 +-- clients/upslog.c | 2 +- clients/upsmon.c | 12 ++++---- clients/upsrw.c | 2 +- clients/upssched.c | 4 +-- clients/upsset.c | 2 +- common/state.c | 2 +- common/upsconf.c | 2 +- docs/developers.txt | 7 ----- docs/nut.dict | 5 +--- drivers/apcsmart-old.c | 40 +++++++++++++------------- drivers/apcsmart.c | 42 ++++++++++++++-------------- drivers/apcupsd-ups.c | 2 +- drivers/belkin.c | 2 +- drivers/belkinunv.c | 4 +-- drivers/bestups.c | 18 ++++++------ drivers/clone-outlet.c | 2 +- drivers/clone.c | 4 +-- drivers/dstate.c | 4 +-- drivers/gamatronic.c | 20 ++++++------- drivers/huawei-ups2000.c | 4 +-- drivers/main.c | 12 ++++---- drivers/masterguard.c | 2 +- drivers/mge-utalk.c | 24 ++++++++-------- drivers/mge-xml.c | 10 +++---- drivers/nutdrv_qx.c | 2 +- drivers/nutdrv_qx_bestups.c | 40 +++++++++++++------------- drivers/nutdrv_qx_blazer-common.c | 6 ++-- drivers/nutdrv_qx_voltronic-qs-hex.c | 4 +-- drivers/nutdrv_qx_voltronic-qs.c | 2 +- drivers/nutdrv_qx_voltronic.c | 6 ++-- drivers/oneac.c | 4 +-- drivers/powercom.c | 40 +++++++++++++------------- drivers/powerman-pdu.c | 4 +-- drivers/powerp-txt.c | 6 ++-- drivers/snmp-ups.c | 10 +++---- drivers/tripplite_usb.c | 2 +- drivers/upscode2.c | 8 +++--- drivers/victronups.c | 14 +++++----- server/conf.c | 6 ++-- server/netget.c | 2 +- server/netlist.c | 8 +++--- server/netset.c | 6 ++-- server/user.c | 4 +-- tests/cpputest.cpp | 2 +- tools/nut-scanner/nut-scanner.c | 4 +-- tools/nut-scanner/scan_snmp.c | 8 +++--- 47 files changed, 204 insertions(+), 216 deletions(-) diff --git a/clients/upsclient.c b/clients/upsclient.c index 6963160903..afe815ec4c 100644 --- a/clients/upsclient.c +++ b/clients/upsclient.c @@ -1424,8 +1424,8 @@ int upscli_list_next(UPSCONN_t *ups, size_t numq, const char **query, /* see if this is the end */ if (ups->pc_ctx.numargs >= 2) { - if ((!strncmp(ups->pc_ctx.arglist[0], "END", 3)) && - (!strncmp(ups->pc_ctx.arglist[1], "LIST", 4))) + if ((!strcmp(ups->pc_ctx.arglist[0], "END")) && + (!strcmp(ups->pc_ctx.arglist[1], "LIST"))) return 0; } diff --git a/clients/upslog.c b/clients/upslog.c index cd2066c54b..1d8b2aec65 100644 --- a/clients/upslog.c +++ b/clients/upslog.c @@ -488,7 +488,7 @@ int main(int argc, char **argv) fprintf(stderr, "Warning: initial connect failed: %s\n", upscli_strerror(&ups)); - if (strncmp(logfn, "-", 1) == 0) + if (strcmp(logfn, "-") == 0) logfile = stdout; else logfile = fopen(logfn, "a"); diff --git a/clients/upsmon.c b/clients/upsmon.c index b00a1dd131..37c908091f 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -1619,19 +1619,19 @@ static void parse_status(utype_t *ups, char *status) upsdebugx(3, "parsing: [%s]", statword); - if (!strncasecmp(statword, "OL", 2)) + if (!strcasecmp(statword, "OL")) ups_on_line(ups); - if (!strncasecmp(statword, "OB", 2)) + if (!strcasecmp(statword, "OB")) ups_on_batt(ups); - if (!strncasecmp(statword, "LB", 2)) + if (!strcasecmp(statword, "LB")) ups_low_batt(ups); - if (!strncasecmp(statword, "RB", 2)) + if (!strcasecmp(statword, "RB")) upsreplbatt(ups); - if (!strncasecmp(statword, "CAL", 3)) + if (!strcasecmp(statword, "CAL")) ups_cal(ups); /* do it last to override any possible OL */ - if (!strncasecmp(statword, "FSD", 3)) + if (!strcasecmp(statword, "FSD")) ups_fsd(ups); update_crittimer(ups); diff --git a/clients/upsrw.c b/clients/upsrw.c index 3c50908f57..d2fe1d9efb 100644 --- a/clients/upsrw.c +++ b/clients/upsrw.c @@ -523,7 +523,7 @@ static void do_type(const char *varname) } /* ignore this one */ - if (!strncasecmp(answer[i], "RW", 2)) { + if (!strcasecmp(answer[i], "RW")) { continue; } diff --git a/clients/upssched.c b/clients/upssched.c index 2898aecdd4..b885015b5c 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -823,7 +823,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd, /* check upsname: does this apply to us? */ if (strcmp(upsname, un) != 0) - if (strncmp(un, "*", 1) != 0) + if (strcmp(un, "*") != 0) return; /* not for us, and not the wildcard */ /* see if the current notify type matches the one from the .conf */ @@ -885,7 +885,7 @@ static int conf_arg(size_t numargs, char **arg) return 0; /* AT [] */ - if (!strncmp(arg[0], "AT", 2)) { + if (!strcmp(arg[0], "AT")) { /* don't use arg[5] unless we have it... */ if (numargs > 5) diff --git a/clients/upsset.c b/clients/upsset.c index e147ce30a9..ac8f2854ae 100644 --- a/clients/upsset.c +++ b/clients/upsset.c @@ -759,7 +759,7 @@ static void do_type(const char *varname) } /* ignore this one */ - if (!strncasecmp(answer[i], "RW", 2)) + if (!strcasecmp(answer[i], "RW")) continue; printf("Unrecognized\n"); diff --git a/common/state.c b/common/state.c index 53045c4560..280eac5181 100644 --- a/common/state.c +++ b/common/state.c @@ -424,7 +424,7 @@ void state_setflags(st_tree_t *root, const char *var, size_t numflags, char **fl for (i = 0; i < numflags; i++) { - if (!strncasecmp(flag[i], "RW", 2)) { + if (!strcasecmp(flag[i], "RW")) { sttmp->flags |= ST_FLAG_RW; continue; } diff --git a/common/upsconf.c b/common/upsconf.c index d5b2847103..bb7fd35108 100644 --- a/common/upsconf.c +++ b/common/upsconf.c @@ -56,7 +56,7 @@ static void conf_args(size_t numargs, char **arg) return; /* handle 'foo = bar', 'foo=bar', 'foo =bar' or 'foo= bar' forms */ - if (!strncmp(arg[1], "=", 1)) { + if (!strcmp(arg[1], "=")) { do_upsconf_args(ups_section, arg[0], arg[2]); return; } diff --git a/docs/developers.txt b/docs/developers.txt index 702bd1fe55..352488dd44 100644 --- a/docs/developers.txt +++ b/docs/developers.txt @@ -21,13 +21,6 @@ Don't use `strcat()`. We have a neat wrapper for `snprintf()` called `snprintfcat()` that allows you to append to `char *` with a format string and all the usual string length checking of `snprintf()` routine. -Some systems define `strcmp()` and `strcasecmp()` as macros or inline -functions optimized for aligned memory access in a way that some compilers -complain about array out-of-bounds access when comparing fixed short strings. -For this reason, we compare strings with length 3 chars and less ("", "x", -"on", "VAL") with fixed-length methods `strncmp()` and `strncasecmp()`, -e.g. `strncmp(buf, "VAL", 3)`. - Error reporting ~~~~~~~~~~~~~~~ diff --git a/docs/nut.dict b/docs/nut.dict index 2facf581b2..8221b9b8e7 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2864 utf-8 +personal_ws-1.1 en 2861 utf-8 AAS ACFAIL ACFREQ @@ -2555,14 +2555,11 @@ strarr strcasecmp strcat strchr -strcmp strcpy strdup strerror strftime strlen -strncasecmp -strncmp struct structs sts diff --git a/drivers/apcsmart-old.c b/drivers/apcsmart-old.c index eb1d7d0548..4ba4b95843 100644 --- a/drivers/apcsmart-old.c +++ b/drivers/apcsmart-old.c @@ -238,7 +238,7 @@ static ssize_t poll_data(apc_vartab_t *vt) } /* no longer supported by the hardware somehow */ - if (!strncmp(tmp, "NA", 2)) { + if (!strcmp(tmp, "NA")) { dstate_delinfo(vt->name); return 1; } @@ -292,7 +292,7 @@ static int query_ups(const char *var, int first) ser_comm_good(); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) /* not supported */ + if ((ret < 1) || (!strcmp(temp, "NA"))) /* not supported */ return 0; vt->flags |= APC_PRESENT; @@ -333,7 +333,7 @@ static void do_capabilities(void) ret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, MINIGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA"))) { /* Early Smart-UPS, not as smart as later ones */ /* This should never happen since we only call @@ -446,7 +446,7 @@ static int update_status(void) ret = read_buf(buf, sizeof(buf)); - if ((ret < 1) || (!strncmp(buf, "NA", 2))) { + if ((ret < 1) || (!strcmp(buf, "NA"))) { dstate_datastale(); return 0; } @@ -566,7 +566,7 @@ static int firmware_table_lookup(void) * Some UPSes support both 'V' and 'b'. As 'b' doesn't always return * firmware version, we attempt that only if 'V' doesn't work. */ - if ((ret < 1) || (!strncmp(buf, "NA", 2))) { + if ((ret < 1) || (!strcmp(buf, "NA"))) { upsdebugx(1, "Attempting firmware lookup using command 'b'"); ret = ser_send_char(upsfd, 'b'); @@ -646,7 +646,7 @@ static void getbaseinfo(void) ret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, IGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA"))) { /* We have an old dumb UPS - go to specific code for old stuff */ oldapcsetup(); return; @@ -698,7 +698,7 @@ static int do_cal(int start) ret = read_buf(temp, sizeof(temp)); /* if we can't check the current calibration status, bail out */ - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_INSTCMD_HANDLED; /* FUTURE: failure */ tval = strtol(temp, 0, 16); @@ -723,7 +723,7 @@ static int do_cal(int start) ret = read_buf(temp, sizeof(temp)); - if ((ret < 1) || (!strncmp(temp, "NA", 2)) || (!strncmp(temp, "NO", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA")) || (!strcmp(temp, "NO"))) { upslogx(LOG_WARNING, "Stop calibration failed: %s", temp); return STAT_INSTCMD_HANDLED; /* FUTURE: failure */ @@ -750,7 +750,7 @@ static int do_cal(int start) ret = read_buf(temp, sizeof(temp)); - if ((ret < 1) || (!strncmp(temp, "NA", 2)) || (!strncmp(temp, "NO", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA")) || (!strcmp(temp, "NO"))) { upslogx(LOG_WARNING, "Start calibration failed: %s", temp); return STAT_INSTCMD_HANDLED; /* FUTURE: failure */ } @@ -778,7 +778,7 @@ static int smartmode(void) IGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC); if (ret > 0) - if (!strncmp(temp, "SM", 2)) + if (!strcmp(temp, "SM")) return 1; /* success */ sleep(1); /* wait before trying again */ @@ -810,7 +810,7 @@ static long sdok(void) ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, IGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC); upsdebugx(4, "sdok: got \"%s\"", temp); - if (!strncmp(temp, "*", 1) || !strncmp(temp, "OK", 2)) { + if (!strcmp(temp, "*") || !strcmp(temp, "OK")) { upsdebugx(4, "Last issued shutdown command succeeded"); return 1; } @@ -1077,7 +1077,7 @@ void upsdrv_shutdown(void) status = APC_STAT_LB | APC_STAT_OB; } - if (testvar("advorder") && strncasecmp(getval("advorder"), "no", 2)) + if (testvar("advorder") && strcasecmp(getval("advorder"), "no")) upsdrv_shutdown_advanced(status); else upsdrv_shutdown_simple(status); @@ -1144,7 +1144,7 @@ static int setvar_enum(apc_vartab_t *vt, const char *val) ret = read_buf(orig, sizeof(orig)); - if ((ret < 1) || (!strncmp(orig, "NA", 2))) + if ((ret < 1) || (!strcmp(orig, "NA"))) return STAT_SET_HANDLED; /* FUTURE: failed */ ptr = convert_data(vt, orig); @@ -1168,13 +1168,13 @@ static int setvar_enum(apc_vartab_t *vt, const char *val) /* this should return either OK (if rotated) or NO (if not) */ ret = read_buf(temp, sizeof(temp)); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_SET_HANDLED; /* FUTURE: failed */ /* sanity checks */ - if (!strncmp(temp, "NO", 2)) + if (!strcmp(temp, "NO")) return STAT_SET_HANDLED; /* FUTURE: failed */ - if (strncmp(temp, "OK", 2) != 0) + if (strcmp(temp, "OK") != 0) return STAT_SET_HANDLED; /* FUTURE: failed */ /* see what it rotated onto */ @@ -1187,7 +1187,7 @@ static int setvar_enum(apc_vartab_t *vt, const char *val) ret = read_buf(temp, sizeof(temp)); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_SET_HANDLED; /* FUTURE: failed */ ptr = convert_data(vt, temp); @@ -1238,7 +1238,7 @@ static int setvar_string(apc_vartab_t *vt, const char *val) ret = read_buf(temp, sizeof(temp)); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_SET_HANDLED; /* FUTURE: failed */ /* suppress redundant changes - easier on the eeprom */ @@ -1288,7 +1288,7 @@ static int setvar_string(apc_vartab_t *vt, const char *val) return STAT_SET_HANDLED; /* FUTURE: failed */ } - if (!strncmp(temp, "NO", 2)) { + if (!strcmp(temp, "NO")) { upslogx(LOG_ERR, "setvar_string: got NO at final read"); return STAT_SET_HANDLED; /* FUTURE: failed */ } @@ -1356,7 +1356,7 @@ static int do_cmd(apc_cmdtab_t *ct) if (ret < 1) return STAT_INSTCMD_HANDLED; /* FUTURE: failed */ - if (strncmp(buf, "OK", 2) != 0) { + if (strcmp(buf, "OK") != 0) { upslogx(LOG_WARNING, "Got [%s] after command [%s]", buf, ct->name); diff --git a/drivers/apcsmart.c b/drivers/apcsmart.c index ceae009bf8..0122c924b3 100644 --- a/drivers/apcsmart.c +++ b/drivers/apcsmart.c @@ -308,7 +308,7 @@ static void apc_ser_set(void) * compatibility measure for windows systems and perhaps some * problematic serial cards/converters */ - if ((val = getval("ttymode")) && !strncmp(val, "raw", 3)) + if ((val = getval("ttymode")) && !strcmp(val, "raw")) return; memset(&tio, 0, sizeof(tio)); @@ -779,7 +779,7 @@ static const char *preread_data(apc_vartab_t *vt) ret = apc_read(temp, sizeof(temp), SER_TO); - if (ret < 1 || !strncmp(temp, "NA", 2)) { + if (ret < 1 || !strcmp(temp, "NA")) { if (ret >= 0) upslogx(LOG_ERR, "%s: %s [%s] timed out or not supported", __func__, vt->name, prtchr(vt->cmd)); return 0; @@ -804,7 +804,7 @@ static int poll_data(apc_vartab_t *vt) return 0; /* automagically no longer supported by the hardware somehow */ - if (!strncmp(temp, "NA", 2)) { + if (!strcmp(temp, "NA")) { upslogx(LOG_WARNING, "%s: verified variable %s [%s] returned NA, removing", __func__, vt->name, prtchr(vt->cmd)); vt->flags &= ~(unsigned int)APC_PRESENT; apc_dstate_delinfo(vt, 0); @@ -826,7 +826,7 @@ static int update_status(void) return 0; ret = apc_read(buf, sizeof(buf), SER_AA); - if ((ret < 1) || (!strncmp(buf, "NA", 2))) { + if ((ret < 1) || (!strcmp(buf, "NA"))) { if (ret >= 0) upslogx(LOG_WARNING, "%s: %s", __func__, "failed"); return 0; @@ -973,7 +973,7 @@ static void apc_getcaps(int qco) */ ret = apc_read(temp, sizeof(temp), SER_CC|SER_TO); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA"))) { /* * Early Smart-UPS not as smart as the later ones ... @@ -1193,7 +1193,7 @@ static int firmware_table_lookup(void) * Some UPSes support both 'V' and 'b'. As 'b' doesn't always return * firmware version, we attempt that only if 'V' doesn't work. */ - if (!ret || !strncmp(buf, "NA", 2)) { + if (!ret || !strcmp(buf, "NA")) { upsdebugx(1, "attempting firmware lookup using [%s]", prtchr(APC_FW_NEW)); if (apc_write(APC_FW_NEW) != 1) @@ -1274,7 +1274,7 @@ static int getbaseinfo(void) if ((ret = apc_read(temp, sizeof(temp), SER_CS|SER_TO)) < 0) return 0; - if (!ret || !strncmp(temp, "NA", 2) || !rexhlp(APC_CMDSET_FMT, temp)) { + if (!ret || !strcmp(temp, "NA") || !rexhlp(APC_CMDSET_FMT, temp)) { /* We have an old dumb UPS - go to specific code for old stuff */ upslogx(LOG_NOTICE, "very old or unknown APC model, support will be limited"); oldapcsetup(); @@ -1323,7 +1323,7 @@ static int do_cal(int start) ret = apc_read(temp, sizeof(temp), SER_AA); /* if we can't check the current calibration status, bail out */ - if ((ret < 1) || (!strncmp(temp, "NA", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA"))) { upslogx(LOG_WARNING, "%s", "runtime calibration state undeterminable"); return STAT_INSTCMD_HANDLED; /* FUTURE: failure */ } @@ -1349,7 +1349,7 @@ static int do_cal(int start) ret = apc_read(temp, sizeof(temp), SER_AA); - if ((ret < 1) || (!strncmp(temp, "NA", 2)) || (!strncmp(temp, "NO", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA")) || (!strcmp(temp, "NO"))) { upslogx(LOG_WARNING, "stop calibration failed, cmd returned: %s", temp); return STAT_INSTCMD_HANDLED; /* FUTURE: failure */ } @@ -1374,7 +1374,7 @@ static int do_cal(int start) ret = apc_read(temp, sizeof(temp), SER_AA); - if ((ret < 1) || (!strncmp(temp, "NA", 2)) || (!strncmp(temp, "NO", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA")) || (!strcmp(temp, "NO"))) { upslogx(LOG_WARNING, "start calibration failed, cmd returned: %s", temp); return STAT_INSTCMD_HANDLED; /* FUTURE: failure */ } @@ -1396,7 +1396,7 @@ static int smartmode(void) } ret = apc_read(temp, sizeof(temp), 0); - if ((ret < 1) || (!strncmp(temp, "NA", 2)) || (!strncmp(temp, "NO", 2))) { + if ((ret < 1) || (!strcmp(temp, "NA")) || (!strcmp(temp, "NO"))) { upslogx(LOG_CRIT, "%s", "enabling smartmode failed !"); return 0; } @@ -1425,7 +1425,7 @@ static int smartmode(int cnt) /* timeout here is intented */ ret = apc_read(temp, sizeof(temp), SER_TO|SER_D1); - if (ret > 0 && !strncmp(temp, "SM", 2)) + if (ret > 0 && !strcmp(temp, "SM")) return 1; /* success */ if (ret < 0) /* error, so we didn't timeout - wait a bit before retry */ @@ -1462,7 +1462,7 @@ static int sdok(int ign) upsdebugx(1, "%s: got \"%s\"", __func__, temp); - if ((!ret && ign) || !strncmp(temp, "OK", 2)) { + if ((!ret && ign) || !strcmp(temp, "OK")) { upsdebugx(1, "%s: %s", __func__, "last shutdown cmd succeeded"); return STAT_INSTCMD_HANDLED; } @@ -1751,7 +1751,7 @@ static int setvar_enum(apc_vartab_t *vt, const char *val) ret = apc_read(orig, sizeof(orig), SER_AA); - if ((ret < 1) || (!strncmp(orig, "NA", 2))) + if ((ret < 1) || (!strcmp(orig, "NA"))) return STAT_SET_FAILED; ptr = convert_data(vt, orig); @@ -1771,13 +1771,13 @@ static int setvar_enum(apc_vartab_t *vt, const char *val) /* this should return either OK (if rotated) or NO (if not) */ ret = apc_read(temp, sizeof(temp), SER_AA); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_SET_FAILED; /* sanity checks */ - if (!strncmp(temp, "NO", 2)) + if (!strcmp(temp, "NO")) return STAT_SET_FAILED; - if (strncmp(temp, "OK", 2)) + if (strcmp(temp, "OK")) return STAT_SET_FAILED; /* see what it rotated onto */ @@ -1786,7 +1786,7 @@ static int setvar_enum(apc_vartab_t *vt, const char *val) ret = apc_read(temp, sizeof(temp), SER_AA); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_SET_FAILED; ptr = convert_data(vt, temp); @@ -1836,7 +1836,7 @@ static int setvar_string(apc_vartab_t *vt, const char *val) ret = apc_read(temp, sizeof(temp), SER_AA); - if ((ret < 1) || (!strncmp(temp, "NA", 2))) + if ((ret < 1) || (!strcmp(temp, "NA"))) return STAT_SET_FAILED; /* suppress redundant changes - easier on the eeprom */ @@ -1865,7 +1865,7 @@ static int setvar_string(apc_vartab_t *vt, const char *val) return STAT_SET_FAILED; } - if (!strncmp(temp, "NO", 2)) { + if (!strcmp(temp, "NO")) { upslogx(LOG_ERR, "%s: %s", __func__, "got NO at final read"); return STAT_SET_FAILED; } @@ -1947,7 +1947,7 @@ static int do_cmd(const apc_cmdtab_t *ct) if (ret < 1) return STAT_INSTCMD_FAILED; - if (strncmp(temp, "OK", 2)) { + if (strcmp(temp, "OK")) { upslogx(LOG_WARNING, "%s: got [%s] after command [%s]", __func__, temp, ct->name); diff --git a/drivers/apcupsd-ups.c b/drivers/apcupsd-ups.c index d630aa6833..1f14332bfb 100644 --- a/drivers/apcupsd-ups.c +++ b/drivers/apcupsd-ups.c @@ -64,7 +64,7 @@ static void process(char *item,char *data) else if(!strcmp(data,"SELFTEST"))status_set("OB"); else for(;(data=strtok(data," "));data=NULL) { - if(!strncmp(data, "CAL", 3))status_set("CAL"); + if(!strcmp(data,"CAL"))status_set("CAL"); else if(!strcmp(data,"TRIM"))status_set("TRIM"); else if(!strcmp(data,"BOOST"))status_set("BOOST"); else if(!strcmp(data,"ONLINE"))status_set("OL"); diff --git a/drivers/belkin.c b/drivers/belkin.c index 04c5b696e4..2a2b3b9f9f 100644 --- a/drivers/belkin.c +++ b/drivers/belkin.c @@ -513,7 +513,7 @@ void upsdrv_initinfo(void) /* deal with stupid firmware that breaks RAT */ send_belkin_command(STATUS, RATING, ""); - if (!strncmp(temp, "001", 3)) { + if (!strcmp(temp, "001")) { res = do_broken_rat(temp); } else { res = get_belkin_reply(temp); diff --git a/drivers/belkinunv.c b/drivers/belkinunv.c index 020eb0cb42..76f61ed1f1 100644 --- a/drivers/belkinunv.c +++ b/drivers/belkinunv.c @@ -1270,10 +1270,10 @@ static int setvar(const char *varname, const char *val) } else if (!strcasecmp(varname, "ups.beeper.status")) { if (!strcasecmp(val, "disabled")) { i=1; - } else if (!strncasecmp(val, "on", 2) || + } else if (!strcasecmp(val, "on") || !strcasecmp(val, "enabled")) { i=2; - } else if (!strncasecmp(val, "off", 3) || + } else if (!strcasecmp(val, "off") || !strcasecmp(val, "muted")) { i=3; } else { diff --git a/drivers/bestups.c b/drivers/bestups.c index 4389184d7b..6cd8c4edbd 100644 --- a/drivers/bestups.c +++ b/drivers/bestups.c @@ -53,57 +53,57 @@ static int inverted_bypass_bit = 0; static void model_set(const char *abbr, const char *rating) { - if (!strncmp(abbr, "FOR", 3)) { + if (!strcmp(abbr, "FOR")) { dstate_setinfo("ups.mfr", "%s", "Best Power"); dstate_setinfo("ups.model", "Fortress %s", rating); return; } - if (!strncmp(abbr, "FTC", 3)) { + if (!strcmp(abbr, "FTC")) { dstate_setinfo("ups.mfr", "%s", "Best Power"); dstate_setinfo("ups.model", "Fortress Telecom %s", rating); return; } - if (!strncmp(abbr, "PRO", 3)) { + if (!strcmp(abbr, "PRO")) { dstate_setinfo("ups.mfr", "%s", "Best Power"); dstate_setinfo("ups.model", "Patriot Pro %s", rating); inverted_bypass_bit = 1; return; } - if (!strncmp(abbr, "PR2", 3)) { + if (!strcmp(abbr, "PR2")) { dstate_setinfo("ups.mfr", "%s", "Best Power"); dstate_setinfo("ups.model", "Patriot Pro II %s", rating); inverted_bypass_bit = 1; return; } - if (!strncmp(abbr, "325", 3)) { + if (!strcmp(abbr, "325")) { dstate_setinfo("ups.mfr", "%s", "Sola Australia"); dstate_setinfo("ups.model", "Sola 325 %s", rating); return; } - if (!strncmp(abbr, "520", 3)) { + if (!strcmp(abbr, "520")) { dstate_setinfo("ups.mfr", "%s", "Sola Australia"); dstate_setinfo("ups.model", "Sola 520 %s", rating); return; } - if (!strncmp(abbr, "610", 3)) { + if (!strcmp(abbr, "610")) { dstate_setinfo("ups.mfr", "%s", "Best Power"); dstate_setinfo("ups.model", "610 %s", rating); return; } - if (!strncmp(abbr, "620", 3)) { + if (!strcmp(abbr, "620")) { dstate_setinfo("ups.mfr", "%s", "Sola Australia"); dstate_setinfo("ups.model", "Sola 620 %s", rating); return; } - if (!strncmp(abbr, "AX1", 3)) { + if (!strcmp(abbr, "AX1")) { dstate_setinfo("ups.mfr", "%s", "Best Power"); dstate_setinfo("ups.model", "Axxium Rackmount %s", rating); return; diff --git a/drivers/clone-outlet.c b/drivers/clone-outlet.c index 9e8eebf4ab..48fd4c8f86 100644 --- a/drivers/clone-outlet.c +++ b/drivers/clone-outlet.c @@ -124,7 +124,7 @@ static int parse_args(size_t numargs, char **arg) } if (!strcasecmp(arg[1], prefix.status)) { - outlet.status = strncasecmp(arg[2], "off", 3); + outlet.status = strcasecmp(arg[2], "off"); } if (!strcasecmp(arg[1], "ups.status")) { diff --git a/drivers/clone.c b/drivers/clone.c index 3776b7a7eb..3e53ddedf8 100644 --- a/drivers/clone.c +++ b/drivers/clone.c @@ -358,11 +358,11 @@ static int instcmd(const char *cmdname, const char *extra) val = dstate_getinfo(getval("load.status")); if (val) { - if (!strncasecmp(val, "off", 3) || !strncasecmp(val, "no", 2)) { + if (!strcasecmp(val, "off") || !strcasecmp(val, "no")) { outlet = 0; } - if (!strncasecmp(val, "on", 2) || !strncasecmp(val, "yes", 3)) { + if (!strcasecmp(val, "on") || !strcasecmp(val, "yes")) { outlet = 1; } } diff --git a/drivers/dstate.c b/drivers/dstate.c index e595c7b9ef..9076ee91b3 100644 --- a/drivers/dstate.c +++ b/drivers/dstate.c @@ -493,7 +493,7 @@ static int sock_arg(conn_t *conn, size_t numarg, char **arg) } /* SET [TRACKING ] */ - if (!strncasecmp(arg[0], "SET", 3)) { + if (!strcasecmp(arg[0], "SET")) { int ret; char *setid = NULL; @@ -1022,7 +1022,7 @@ void status_init(void) /* add a status element */ void status_set(const char *buf) { - if (ignorelb && !strncasecmp(buf, "LB", 2)) { + if (ignorelb && !strcasecmp(buf, "LB")) { upsdebugx(2, "%s: ignoring LB flag from device", __func__); return; } diff --git a/drivers/gamatronic.c b/drivers/gamatronic.c index ed4a0b6285..084cf64f88 100644 --- a/drivers/gamatronic.c +++ b/drivers/gamatronic.c @@ -167,31 +167,31 @@ static void update_pseudovars( void ) { status_init(); - if(strncmp(sec_varlist[9].value, "1", 1)== 0) { + if(strcmp(sec_varlist[9].value,"1")== 0) { status_set("OFF"); } - if(strncmp(sec_varlist[76].value, "0", 1)== 0) { + if(strcmp(sec_varlist[76].value,"0")== 0) { status_set("OL"); } - if(strncmp(sec_varlist[76].value, "1", 1)== 0) { + if(strcmp(sec_varlist[76].value,"1")== 0) { status_set("OB"); } - if(strncmp(sec_varlist[76].value, "2", 1)== 0) { + if(strcmp(sec_varlist[76].value,"2")== 0) { status_set("BYPASS"); } - if(strncmp(sec_varlist[76].value, "3", 1)== 0) { + if(strcmp(sec_varlist[76].value,"3")== 0) { status_set("TRIM"); } - if(strncmp(sec_varlist[76].value, "4", 1)== 0) { + if(strcmp(sec_varlist[76].value,"4")== 0) { status_set("BOOST"); } - if(strncmp(sec_varlist[10].value, "1", 1)== 0) { + if(strcmp(sec_varlist[10].value,"1")== 0) { status_set("OVER"); } - if(strncmp(sec_varlist[22].value, "1", 1)== 0) { + if(strcmp(sec_varlist[22].value,"1")== 0) { status_set("LB"); } - if(strncmp(sec_varlist[19].value, "2", 1)== 0) { + if(strcmp(sec_varlist[19].value,"2")== 0) { status_set("RB"); } @@ -246,7 +246,7 @@ static void sec_poll ( int pollflag ) { } /* If SEC VAR is alarm and it's on, add it to the alarm property */ - if (sec_varlist[sqv(q,f)].flags & FLAG_ALARM && strncmp(r, "1", 1)== 0) { + if (sec_varlist[sqv(q,f)].flags & FLAG_ALARM && strcmp(r,"1")== 0) { alarm_set(sec_varlist[sqv(q,f)].name); } } diff --git a/drivers/huawei-ups2000.c b/drivers/huawei-ups2000.c index 83e9e35eec..c0cb6f5337 100644 --- a/drivers/huawei-ups2000.c +++ b/drivers/huawei-ups2000.c @@ -1267,9 +1267,9 @@ static int ups2000_autostart_set(const uint16_t reg, const char *string) uint16_t val; int r; - if (!strncasecmp(string, "yes", 3)) + if (!strcasecmp(string, "yes")) val = 1; - else if (!strncasecmp(string, "no", 2)) + else if (!strcasecmp(string, "no")) val = 0; else return STAT_SET_INVALID; diff --git a/drivers/main.c b/drivers/main.c index c06d9adc27..a3f7026449 100644 --- a/drivers/main.c +++ b/drivers/main.c @@ -305,10 +305,10 @@ static int main_arg(char *var, char *val) /* allow per-driver overrides of the global setting */ if (!strcmp(var, "synchronous")) { - if (!strncmp(val, "yes", 3)) - do_synchronous = 1; + if (!strcmp(val, "yes")) + do_synchronous=1; else - do_synchronous = 0; + do_synchronous=0; return 1; /* handled */ } @@ -347,10 +347,10 @@ static void do_global_args(const char *var, const char *val) } if (!strcmp(var, "synchronous")) { - if (!strncmp(val, "yes", 3)) - do_synchronous = 1; + if (!strcmp(val, "yes")) + do_synchronous=1; else - do_synchronous = 0; + do_synchronous=0; } diff --git a/drivers/masterguard.c b/drivers/masterguard.c index c93683308b..450d1bd19a 100644 --- a/drivers/masterguard.c +++ b/drivers/masterguard.c @@ -412,7 +412,7 @@ static ssize_t ups_ident( void ) printf( "Old (broken) WH found\n" ); parseOldWH( buf ); } - else if( ret == 3 && strncmp(buf, "NAK", 3) == 0 ) + else if( ret == 3 && strcmp(buf, "NAK") == 0 ) { if( DEBUG ) printf( "WH was NAKed\n" ); diff --git a/drivers/mge-utalk.c b/drivers/mge-utalk.c index cc211bfc61..57142b92e9 100644 --- a/drivers/mge-utalk.c +++ b/drivers/mge-utalk.c @@ -183,7 +183,7 @@ void upsdrv_initups(void) mge_ups.LowBatt = atoi (getval ("lowbatt")); /* Set the value in the UPS */ mge_command(buf, sizeof(buf), "Bl %d", mge_ups.LowBatt); - if(!strncmp(buf, "OK", 2)) + if(!strcmp(buf, "OK")) upsdebugx(1, "Low Battery Level set to %d%%", mge_ups.LowBatt); else upsdebugx(1, "initups: Low Battery Level cannot be set"); @@ -195,7 +195,7 @@ void upsdrv_initups(void) mge_ups.OnDelay = atoi (getval ("ondelay")); /* Set the value in the UPS */ mge_command(buf, sizeof(buf), "Sm %d", mge_ups.OnDelay); - if(!strncmp(buf, "OK", 2)) + if(!strcmp(buf, "OK")) upsdebugx(1, "ON delay set to %d min", mge_ups.OnDelay); else upsdebugx(1, "initups: OnDelay unavailable"); @@ -207,7 +207,7 @@ void upsdrv_initups(void) mge_ups.OffDelay = atoi (getval ("offdelay")); /* Set the value in the UPS */ mge_command(buf, sizeof(buf), "Sn %d", mge_ups.OffDelay); - if(!strncmp(buf, "OK", 2)) + if(!strcmp(buf, "OK")) upsdebugx(1, "OFF delay set to %d sec", mge_ups.OffDelay); else upsdebugx(1, "initups: OffDelay unavailable"); @@ -476,13 +476,13 @@ void upsdrv_shutdown(void) /* Only call the effective shutoff if restart is ok */ /* or if we need only a stayoff... */ - if (!strncmp(buf, "OK", 2) || (sdtype == SD_STAYOFF)) { + if (!strcmp(buf, "OK") || (sdtype == SD_STAYOFF)) { /* shutdown UPS */ mge_command(buf, sizeof(buf), "Sx 0"); upslogx(LOG_INFO, "UPS response to Shutdown was %s", buf); } -/* if(strncmp(buf, "OK", 2)) */ +/* if(strcmp(buf, "OK")) */ /* call the cleanup to disable/close the comm link */ upsdrv_cleanup(); @@ -509,7 +509,7 @@ int instcmd(const char *cmdname, const char *extra) mge_command(temp, sizeof(temp), "Bx 1"); upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else return STAT_INSTCMD_HANDLED; @@ -521,7 +521,7 @@ int instcmd(const char *cmdname, const char *extra) mge_command(temp, sizeof(temp), "Sx 129"); upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else return STAT_INSTCMD_HANDLED; @@ -547,13 +547,13 @@ int instcmd(const char *cmdname, const char *extra) mge_command(temp, sizeof(temp), "Wy 65535"); upsdebugx(2, "UPS response to Select All Plugs was %s", temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else { mge_command(temp, sizeof(temp), "Wx 0"); upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else return STAT_INSTCMD_HANDLED; @@ -567,13 +567,13 @@ int instcmd(const char *cmdname, const char *extra) mge_command(temp, sizeof(temp), "Wy 65535"); upsdebugx(2, "UPS response to Select All Plugs was %s", temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else { mge_command(temp, sizeof(temp), "Wx 1"); upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else return STAT_INSTCMD_HANDLED; @@ -601,7 +601,7 @@ int instcmd(const char *cmdname, const char *extra) upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - if(strncmp(temp, "OK", 2)) + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else return STAT_INSTCMD_HANDLED; diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index 8093409509..8a1a3cc497 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -1231,7 +1231,7 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* url="upsprop.xml" or url="ws/summary.xml" */ int i; for (i = 0; atts[i] && atts[i+1]; i += 2) { - if (!strncasecmp(atts[i], "url", 3)) { + if (!strcasecmp(atts[i], "url")) { free(mge_xml_subdriver.summary); mge_xml_subdriver.summary = strdup(url_convert(atts[i+1])); } @@ -1243,7 +1243,7 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* url="config.xml" */ int i; for (i = 0; atts[i] && atts[i+1]; i += 2) { - if (!strncasecmp(atts[i], "url", 3)) { + if (!strcasecmp(atts[i], "url")) { free(mge_xml_subdriver.configure); mge_xml_subdriver.configure = strdup(url_convert(atts[i+1])); } @@ -1263,7 +1263,7 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* url="subscribe.cgi" security="basic" */ int i; for (i = 0; atts[i] && atts[i+1]; i += 2) { - if (!strncasecmp(atts[i], "url", 3)) { + if (!strcasecmp(atts[i], "url")) { free(mge_xml_subdriver.subscribe); mge_xml_subdriver.subscribe = strdup(url_convert(atts[i+1])); } @@ -1301,7 +1301,7 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* url="getvalue.cgi" security="none" */ int i; for (i = 0; atts[i] && atts[i+1]; i += 2) { - if (!strncasecmp(atts[i], "url", 3)) { + if (!strcasecmp(atts[i], "url")) { free(mge_xml_subdriver.getobject); mge_xml_subdriver.getobject = strdup(url_convert(atts[i+1])); } @@ -1313,7 +1313,7 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* url="setvalue.cgi" security="ssl" */ int i; for (i = 0; atts[i] && atts[i+1]; i += 2) { - if (!strncasecmp(atts[i], "url", 3)) { + if (!strcasecmp(atts[i], "url")) { free(mge_xml_subdriver.setobject); mge_xml_subdriver.setobject = strdup(url_convert(atts[i+1])); } diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index 7b9128cef1..6414688ea4 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -4001,7 +4001,7 @@ int ups_infoval_set(item_t *item) if (item->qxflags & QX_FLAG_TRIM) str_trim_m(value, "# "); - if (strncasecmp(item->dfl, "%s", 2)) { + if (strcasecmp(item->dfl, "%s")) { if (strspn(value, "0123456789 .") != strlen(value)) { upsdebugx(2, "%s: non numerical value [%s: %s]", diff --git a/drivers/nutdrv_qx_bestups.c b/drivers/nutdrv_qx_bestups.c index 1763ee3c1f..adc102f0c5 100644 --- a/drivers/nutdrv_qx_bestups.c +++ b/drivers/nutdrv_qx_bestups.c @@ -432,11 +432,11 @@ static int bestups_manufacturer(item_t *item, char *value, const size_t valuelen /* Best Power devices */ if ( - !strncmp(item->value, "AX1", 3) || - !strncmp(item->value, "FOR", 3) || - !strncmp(item->value, "FTC", 3) || - !strncmp(item->value, "PR2", 3) || - !strncmp(item->value, "PRO", 3) + !strcmp(item->value, "AX1") || + !strcmp(item->value, "FOR") || + !strcmp(item->value, "FTC") || + !strcmp(item->value, "PR2") || + !strcmp(item->value, "PRO") ) { snprintf(value, valuelen, item->dfl, "Best Power"); return 0; @@ -444,9 +444,9 @@ static int bestups_manufacturer(item_t *item, char *value, const size_t valuelen /* Sola Australia devices */ if ( - !strncmp(item->value, "325", 3) || - !strncmp(item->value, "520", 3) || - !strncmp(item->value, "620", 3) + !strcmp(item->value, "325") || + !strcmp(item->value, "520") || + !strcmp(item->value, "620") ) { snprintf(value, valuelen, item->dfl, "Sola Australia"); return 0; @@ -479,35 +479,35 @@ static int bestups_model(item_t *item, char *value, const size_t valuelen) /* Best Power devices */ - if (!strncmp(item->value, "AX1", 3)) { + if (!strcmp(item->value, "AX1")) { snprintf(value, valuelen, item->dfl, "Axxium Rackmount"); - } else if (!strncmp(item->value, "FOR", 3)) { + } else if (!strcmp(item->value, "FOR")) { snprintf(value, valuelen, item->dfl, "Fortress"); - } else if (!strncmp(item->value, "FTC", 3)) { + } else if (!strcmp(item->value, "FTC")) { snprintf(value, valuelen, item->dfl, "Fortress Telecom"); - } else if (!strncmp(item->value, "PR2", 3)) { + } else if (!strcmp(item->value, "PR2")) { snprintf(value, valuelen, item->dfl, "Patriot Pro II"); inverted_bbb_bit = 1; - } else if (!strncmp(item->value, "PRO", 3)) { + } else if (!strcmp(item->value, "PRO")) { snprintf(value, valuelen, item->dfl, "Patriot Pro"); inverted_bbb_bit = 1; /* Sola Australia devices */ } else if ( - !strncmp(item->value, "320", 3) || - !strncmp(item->value, "325", 3) || - !strncmp(item->value, "520", 3) || - !strncmp(item->value, "525", 3) || - !strncmp(item->value, "620", 3) + !strcmp(item->value, "320") || + !strcmp(item->value, "325") || + !strcmp(item->value, "520") || + !strcmp(item->value, "525") || + !strcmp(item->value, "620") ) { snprintf(value, valuelen, "Sola %s", item->value); @@ -523,7 +523,7 @@ static int bestups_model(item_t *item, char *value, const size_t valuelen) /* Unskip qx2nut table's items according to the UPS model */ /* battery.runtime var is not available on the Patriot Pro/Sola 320 model series: leave it skipped in these cases, otherwise unskip it */ - if (strncmp(item->value, "PRO", 3) && strncmp(item->value, "320", 3)) { + if (strcmp(item->value, "PRO") && strcmp(item->value, "320")) { unskip = find_nut_info("battery.runtime", 0, 0); @@ -536,7 +536,7 @@ static int bestups_model(item_t *item, char *value, const size_t valuelen) } /* battery.packs var is available only on the Axxium/Sola 620 model series: unskip it in these cases */ - if (!strncmp(item->value, "AX1", 3) || !strncmp(item->value, "620", 3)) { + if (!strcmp(item->value, "AX1") || !strcmp(item->value, "620")) { unskip = find_nut_info("battery.packs", 0, QX_FLAG_SETVAR); diff --git a/drivers/nutdrv_qx_blazer-common.c b/drivers/nutdrv_qx_blazer-common.c index 1fe113e758..2ff16bc3bb 100644 --- a/drivers/nutdrv_qx_blazer-common.c +++ b/drivers/nutdrv_qx_blazer-common.c @@ -145,15 +145,13 @@ void blazer_initups(item_t *qx2nut) continue; /* norating */ - if (nr && !strncasecmp(item->command, "F\r", strlen("F\r"))) { + if (nr && !strcasecmp(item->command, "F\r")) { upsdebugx(2, "%s: skipping %s", __func__, item->info_type); item->qxflags |= QX_FLAG_SKIP; } /* novendor */ - if (nv && (!strncasecmp(item->command, "I\r", strlen("I\r")) - || !strncasecmp(item->command, "FW?\r", strlen("FW?\r"))) - ) { + if (nv && (!strcasecmp(item->command, "I\r") || !strcasecmp(item->command, "FW?\r"))) { upsdebugx(2, "%s: skipping %s", __func__, item->info_type); item->qxflags |= QX_FLAG_SKIP; } diff --git a/drivers/nutdrv_qx_voltronic-qs-hex.c b/drivers/nutdrv_qx_voltronic-qs-hex.c index 266a3f324e..9485fe0e18 100644 --- a/drivers/nutdrv_qx_voltronic-qs-hex.c +++ b/drivers/nutdrv_qx_voltronic-qs-hex.c @@ -318,7 +318,7 @@ static int voltronic_qs_hex_protocol(item_t *item, char *value, const size_t val { NULL, 0, 0 } }; - if (strncasecmp(item->value, "P", 1) && strncasecmp(item->value, "T", 1)) { + if (strcasecmp(item->value, "P") && strcasecmp(item->value, "T")) { upsdebugx(2, "%s: invalid protocol [%s]", __func__, item->value); return -1; } @@ -339,7 +339,7 @@ static int voltronic_qs_hex_protocol(item_t *item, char *value, const size_t val /* Unskip items supported only by devices that implement 'T' protocol */ - if (!strncasecmp(item->value, "P", 1)) + if (!strcasecmp(item->value, "P")) return 0; for (i = 0; items_to_be_unskipped[i].info_type; i++) { diff --git a/drivers/nutdrv_qx_voltronic-qs.c b/drivers/nutdrv_qx_voltronic-qs.c index 5d53278da8..43df438d04 100644 --- a/drivers/nutdrv_qx_voltronic-qs.c +++ b/drivers/nutdrv_qx_voltronic-qs.c @@ -191,7 +191,7 @@ static void voltronic_qs_initups(void) /* Protocol used by the UPS */ static int voltronic_qs_protocol(item_t *item, char *value, const size_t valuelen) { - if (strncasecmp(item->value, "V", 1)) { + if (strcasecmp(item->value, "V")) { upsdebugx(2, "%s: invalid protocol [%s]", __func__, item->value); return -1; } diff --git a/drivers/nutdrv_qx_voltronic.c b/drivers/nutdrv_qx_voltronic.c index 8d2496e531..8e2f2ad7ce 100644 --- a/drivers/nutdrv_qx_voltronic.c +++ b/drivers/nutdrv_qx_voltronic.c @@ -2438,12 +2438,12 @@ static int voltronic_capability_set(item_t *item, char *value, const size_t valu #ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY #pragma GCC diagnostic ignored "-Wformat-security" #endif - if (!strncasecmp(value, "yes", 3)) { + if (!strcasecmp(value, "yes")) { snprintf(value, valuelen, item->command, "E"); return 0; } - if (!strncasecmp(value, "no", 2)) { + if (!strcasecmp(value, "no")) { snprintf(value, valuelen, item->command, "D"); return 0; } @@ -2980,7 +2980,7 @@ static int voltronic_fault(item_t *item, char *value, const size_t valuelen) upslogx(LOG_INFO, "Checking for faults.."); - if (!strncasecmp(item->value, "OK", 2)) { + if (!strcasecmp(item->value, "OK")) { #ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL #pragma GCC diagnostic push #endif diff --git a/drivers/oneac.c b/drivers/oneac.c index 8d0a499b7f..cf243c374b 100644 --- a/drivers/oneac.c +++ b/drivers/oneac.c @@ -1030,13 +1030,13 @@ int setcmd(const char* varname, const char* setvalue) if (!strcasecmp(varname, "ups.start.auto")) { - if (!strncasecmp(setvalue, "yes", 3)) + if (!strcasecmp(setvalue, "yes")) { ser_send(upsfd,"%c0%s",SETX_AUTO_START, COMMAND_END); dstate_setinfo("ups.start.auto", "yes"); return STAT_SET_HANDLED; } - else if (!strncasecmp(setvalue, "no", 2)) + else if (!strcasecmp(setvalue, "no")) { ser_send(upsfd,"%c1%s",SETX_AUTO_START, COMMAND_END); dstate_setinfo("ups.start.auto", "no"); diff --git a/drivers/powercom.c b/drivers/powercom.c index c092a85a7a..f244d91fac 100644 --- a/drivers/powercom.c +++ b/drivers/powercom.c @@ -437,9 +437,9 @@ static float input_voltage(void) unsigned int model; float tmp=0.0; - if ( !strncmp(types[type].name, "BNT", 3) && raw_data[MODELNUMBER]%16 > 7 ) { + if ( !strcmp(types[type].name, "BNT") && raw_data[MODELNUMBER]%16 > 7 ) { tmp=2.2*raw_data[INPUT_VOLTAGE]-24; - } else if ( !strncmp(types[type].name, "KIN", 3)) { + } else if ( !strcmp(types[type].name, "KIN")) { model=KINmodels[raw_data[MODELNUMBER]/16]; /* Process input voltage, according to line voltage and model rating */ if (linevoltage < 200) { @@ -460,7 +460,7 @@ static float input_voltage(void) tmp = 1.625 * raw_data[INPUT_VOLTAGE]; } } - } else if ( !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) { + } else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { tmp=raw_data[INPUT_VOLTAGE]*2.0; } else { tmp=linevoltage >= 220 ? @@ -482,12 +482,12 @@ static float output_voltage(void) static float datay2[]={0,1.73,1.74,1.74,1.77,0.9,0.9,0.9,13.204,13.204,0.88,0.88,0.88,6.645}; static float dataz2[]={0,1.15,0.9,0.9,0.75,1.1,1.1,1.1,0.8,0.8,0.86,0.86,0.86,0.7}; - if ( !strncmp(types[type].name, "BNT", 3) || !strncmp(types[type].name, "KIN", 3)) { + if ( !strcmp(types[type].name, "BNT") || !strcmp(types[type].name, "KIN")) { statINV=raw_data[STATUS_A] & ONLINE; statAVR=raw_data[STATUS_A] & AVR_ON; statAVRMode=raw_data[STATUS_A] & AVR_MODE; } - if ( !strncmp(types[type].name, "BNT", 3) && raw_data[MODELNUMBER]%16 > 7 ) { + if ( !strcmp(types[type].name, "BNT") && raw_data[MODELNUMBER]%16 > 7 ) { if (statINV==0) { if (statAVR==0){ tmp=2.2*raw_data[OUTPUT_VOLTAGE]-24; @@ -505,7 +505,7 @@ static float output_voltage(void) else tmp=0.0; } - } else if ( !strncmp(types[type].name, "KIN", 3)) { + } else if ( !strcmp(types[type].name, "KIN")) { model=KINmodels[raw_data[MODELNUMBER]/16]; if (statINV == 0) { if (statAVR == 0) { @@ -594,7 +594,7 @@ static float output_voltage(void) } /* FIXME: may miss a last processing with ErrorVal = 5 | 10 */ } - } else if ( !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) { + } else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { tmp=raw_data[OUTPUT_VOLTAGE]*2.0; } else { tmp= linevoltage >= 220 ? @@ -609,9 +609,9 @@ static float output_voltage(void) static float input_freq(void) { - if ( !strncmp(types[type].name, "BNT", 3) || !strncmp(types[type].name, "KIN", 3)) + if ( !strcmp(types[type].name, "BNT") || !strcmp(types[type].name, "KIN")) return 4807.0/raw_data[INPUT_FREQUENCY]; - else if ( !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) + else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) return raw_data[INPUT_FREQUENCY]; return raw_data[INPUT_FREQUENCY] ? 1.0 / (types[type].freq[0] * @@ -621,9 +621,9 @@ static float input_freq(void) static float output_freq(void) { - if ( !strncmp(types[type].name, "BNT", 3) || !strncmp(types[type].name, "KIN", 3)) + if ( !strcmp(types[type].name, "BNT") || !strcmp(types[type].name, "KIN")) return 4807.0/raw_data[OUTPUT_FREQUENCY]; - else if ( !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) + else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) return raw_data[OUTPUT_FREQUENCY]; return raw_data[OUTPUT_FREQUENCY] ? 1.0 / (types[type].freq[0] * @@ -652,7 +652,7 @@ static float load_level(void) int load1000i[]={1,1,1,1,1,1,1,1,56,54,52}; int load1200i[]={1,1,1,1,1,1,1,1,76,74,72}; - if ( !strncmp(types[type].name, "BNT", 3) && raw_data[MODELNUMBER]%16 > 7 ) { + if ( !strcmp(types[type].name, "BNT") && raw_data[MODELNUMBER]%16 > 7 ) { statINV=raw_data[STATUS_A] & ONLINE; voltage=raw_data[MODELNUMBER]%16; model=BNTmodels[raw_data[MODELNUMBER]/16]; @@ -676,7 +676,7 @@ static float load_level(void) case 2000: return raw_data[UPS_LOAD]*110.0/load1000i[voltage]; } } - } else if (!strncmp(types[type].name, "KIN", 3)) { + } else if (!strcmp(types[type].name, "KIN")) { statINV=raw_data[STATUS_A] & ONLINE; voltage=raw_data[MODELNUMBER]%16; model=KINmodels[raw_data[MODELNUMBER]/16]; @@ -693,7 +693,7 @@ static float load_level(void) if (model<2000) return raw_data[UPS_LOAD]*1.66; return raw_data[UPS_LOAD]*110.0/load2ki[voltage]; } - } else if ( !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) { + } else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { return raw_data[UPS_LOAD]; } return (raw_data[STATUS_A] & MAINS_FAILURE) ? @@ -709,7 +709,7 @@ static float batt_level(void) unsigned int model; float battval; - if ( !strncmp(types[type].name, "BNT", 3) ) { + if ( !strcmp(types[type].name, "BNT") ) { bat0=157; bat29=165; bat100=193; @@ -722,7 +722,7 @@ static float batt_level(void) return 30.0+(battval-bat29)*70.0/(bat100-bat29); return 100.0; } - if ( !strncmp(types[type].name, "KIN", 3)) { + if ( !strcmp(types[type].name, "KIN")) { model=KINmodels[raw_data[MODELNUMBER]/16]; if (model>=800 && model<=2000){ battval=(raw_data[BATTERY_CHARGE]-165.0)*2.6; @@ -750,7 +750,7 @@ static float batt_level(void) return 30.0+(battval-bat29)*70.0/(bat100-bat29); return 100; } - if ( !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) + if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) return raw_data[BATTERY_CHARGE]; return (raw_data[STATUS_A] & ONLINE) ? /* Are we on battery power? */ /* Yes */ @@ -997,7 +997,7 @@ void upsdrv_initups(void) types[type].flowControl.setup_flow_control(); /* Setup Model and LineVoltage */ - if (!strncmp(types[type].name, "BNT",3) || !strncmp(types[type].name, "KIN", 3) || !strncmp(types[type].name, "IMP", 3) || !strcmp(types[type].name, "OPTI")) { + if (!strncmp(types[type].name, "BNT",3) || !strcmp(types[type].name, "KIN") || !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { if (!ups_getinfo()) return; /* Give "BNT-other" a chance! */ if (raw_data[MODELNAME]==0x42 || raw_data[MODELNAME]==0x4B || raw_data[MODELNAME]==0x4F){ @@ -1068,7 +1068,7 @@ void upsdrv_initups(void) types[type].shutdown_arguments.delay[0], types[type].shutdown_arguments.delay[1], types[type].shutdown_arguments.minutesShouldBeUsed); - if ( strncmp(types[type].name, "KIN", 3) && strncmp(types[type].name, "BNT", 3) && strncmp(types[type].name, "IMP", 3)) { + if ( strcmp(types[type].name, "KIN") && strcmp(types[type].name, "BNT") && strcmp(types[type].name, "IMP")) { upsdebugx(1, " frequency calculation coefficients: '{%f,%f}'", types[type].freq[0], types[type].freq[1]); upsdebugx(1, " load percentage calculation coefficients: " @@ -1194,7 +1194,7 @@ void upsdrv_makevartable(void) "Flow control method for UPS: 'dtr0rts1' or 'no_flow_control'"); addvar(VAR_VALUE, "validationSequence", "Validation values: ByteIndex, ByteValue x 3"); - if ( strncmp(types[type].name, "KIN", 3) && strncmp(types[type].name, "BNT", 3) && strncmp(types[type].name, "IMP", 3)) { + if ( strcmp(types[type].name, "KIN") && strcmp(types[type].name, "BNT") && strcmp(types[type].name, "IMP")) { addvar(VAR_VALUE, "frequency", "Frequency conversion values: FreqFactor, FreqConst"); addvar(VAR_VALUE, "loadPercentage", diff --git a/drivers/powerman-pdu.c b/drivers/powerman-pdu.c index 998c5b678e..1611d3ce5b 100644 --- a/drivers/powerman-pdu.c +++ b/drivers/powerman-pdu.c @@ -73,13 +73,13 @@ static int instcmd(const char *cmdname, const char *extra) } /* Power on the outlet */ - if (!strncasecmp(cmdsuffix, "on", 2)) { + if (!strcasecmp(cmdsuffix, "on")) { rv = pm_node_on(pm, outletname); return (rv==PM_ESUCCESS)?STAT_INSTCMD_HANDLED:STAT_SET_INVALID; } /* Power off the outlet */ - if (!strncasecmp(cmdsuffix, "off", 3)) { + if (!strcasecmp(cmdsuffix, "off")) { rv = pm_node_off(pm, outletname); return (rv==PM_ESUCCESS)?STAT_INSTCMD_HANDLED:STAT_SET_INVALID; } diff --git a/drivers/powerp-txt.c b/drivers/powerp-txt.c index 1fc8998577..6f22a608d7 100644 --- a/drivers/powerp-txt.c +++ b/drivers/powerp-txt.c @@ -150,7 +150,7 @@ static int powpan_instcmd(const char *cmdname, const char *extra) continue; } - if ((powpan_command(cmdtab[i].command) == 2) && (!strncasecmp(powpan_answer, "#0", 2))) { + if ((powpan_command(cmdtab[i].command) == 2) && (!strcasecmp(powpan_answer, "#0"))) { return STAT_INSTCMD_HANDLED; } @@ -181,7 +181,7 @@ static int powpan_instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_UNKNOWN; } - if ((powpan_command(command) == 2) && (!strncasecmp(powpan_answer, "#0", 2))) { + if ((powpan_command(command) == 2) && (!strcasecmp(powpan_answer, "#0"))) { return STAT_INSTCMD_HANDLED; } @@ -219,7 +219,7 @@ static int powpan_setvar(const char *varname, const char *val) #pragma GCC diagnostic pop #endif - if ((powpan_command(command) == 2) && (!strncasecmp(powpan_answer, "#0", 2))) { + if ((powpan_command(command) == 2) && (!strcasecmp(powpan_answer, "#0"))) { dstate_setinfo(varname, "%s", val); return STAT_SET_HANDLED; } diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 8f2afc68ed..e9d55952ab 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -811,14 +811,14 @@ void nut_snmp_init(const char *type, const char *hostname) authProtocol = testvar(SU_VAR_AUTHPROT) ? getval(SU_VAR_AUTHPROT) : "MD5"; #if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol - if (strncmp(authProtocol, "MD5", 3) == 0) { + if (strcmp(authProtocol, "MD5") == 0) { g_snmp_sess.securityAuthProto = usmHMACMD5AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid); } else #endif #if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol - if (strncmp(authProtocol, "SHA", 3) == 0) { + if (strcmp(authProtocol, "SHA") == 0) { g_snmp_sess.securityAuthProto = usmHMACSHA1AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/sizeof(oid); } @@ -888,14 +888,14 @@ net-snmp/library/keytools.h: int generate_Ku(const oid * hashtype, u_int ha privProtocol = testvar(SU_VAR_PRIVPROT) ? getval(SU_VAR_PRIVPROT) : "DES"; #if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol - if (strncmp(privProtocol, "DES", 3) == 0) { + if (strcmp(privProtocol, "DES") == 0) { g_snmp_sess.securityPrivProto = usmDESPrivProtocol; g_snmp_sess.securityPrivProtoLen = sizeof(usmDESPrivProtocol)/sizeof(oid); } else #endif #if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol - if (strncmp(privProtocol, "AES", 3) == 0) { + if (strcmp(privProtocol, "AES") == 0) { g_snmp_sess.securityPrivProto = usmAESPrivProtocol; g_snmp_sess.securityPrivProtoLen = NUT_securityPrivProtoLen; } @@ -3620,7 +3620,7 @@ static int parse_mibconf_args(size_t numargs, char **arg) /* special case for setting some OIDs value at driver startup */ if (!strcmp(arg[0], "init")) { /* set value. */ - if (!strncmp(arg[1], "str", 3)) { + if (!strcmp(arg[1], "str")) { ret = nut_snmp_set_str(arg[3], arg[4]); } else { ret = nut_snmp_set_int(arg[3], strtol(arg[4], NULL, 0)); diff --git a/drivers/tripplite_usb.c b/drivers/tripplite_usb.c index ab67664498..800d4c2efb 100644 --- a/drivers/tripplite_usb.c +++ b/drivers/tripplite_usb.c @@ -945,7 +945,7 @@ static int setvar(const char *varname, const char *val) index = atoi(index_str); upslogx(LOG_DEBUG, "outlet.%d.switch = %s", index, val); - if(!strncasecmp(val, "on", 2) || !strncmp(val, "1", 1)) { + if(!strcasecmp(val, "on") || !strcmp(val, "1")) { state = 1; } else { state = 0; diff --git a/drivers/upscode2.c b/drivers/upscode2.c index fe923c346b..a2b73e19c4 100644 --- a/drivers/upscode2.c +++ b/drivers/upscode2.c @@ -1334,17 +1334,17 @@ static int upsc_simple(const simple_t *sp, const char *var, const char *val) dstate_setinfo(sp->desc, "%s", val); break; case t_status: - if (strncmp(val, "00", 2) == 0) + if (strcmp(val, "00") == 0) ; - else if (strncmp(val, "11", 2) == 0) + else if (strcmp(val, "11") == 0) status |= sp->status; else upslogx(LOG_ERR, "Unknown status value: '%s' '%s'", var, val); break; case t_alarm: - if (strncmp(val, "00", 2) == 0) + if (strcmp(val, "00") == 0) ; - else if (strncmp(val, "11", 2) == 0) + else if (strcmp(val, "11") == 0) status |= sp->status; else upslogx(LOG_ERR, "Unknown alarm value: '%s' '%s'", var, val); diff --git a/drivers/victronups.c b/drivers/victronups.c index 71fa29345e..cdec6540ba 100644 --- a/drivers/victronups.c +++ b/drivers/victronups.c @@ -244,31 +244,31 @@ void upsdrv_updateinfo(void) if (start_is_datastale) { if (get_data("vDS?",temp)) return; - if (strncmp(temp+3, "NA", 2)) + if (strcmp(temp+3,"NA")) exist_ups_serial=1; if (get_data("vBT?",temp)) return; - if (strncmp(temp+3, "NA", 2)) + if (strcmp(temp+3,"NA")) exist_ups_temperature =1; if (get_data("vO0I?",temp)) return; - if (strncmp(temp+4, "NA", 2)) + if (strcmp(temp+4,"NA")) exist_output_current =1; if (get_data("vBC?",temp)) return; - if (strncmp(temp+3, "NA", 2)) + if (strcmp(temp+3,"NA")) exist_battery_charge = 1; if (get_data("vBI?",temp)) return; - if (strncmp(temp+3, "NA", 2)) + if (strcmp(temp+3,"NA")) exist_battery_charge = 1; if (get_data("vBT?",temp)) return; - if (strncmp(temp+3, "NA", 2)) + if (strcmp(temp+3,"NA")) exist_battery_temperature = 1; if (get_data("vBt?",temp)) return; - if (strncmp(temp+3, "NA", 2)) + if (strcmp(temp+3,"NA")) exist_battery_runtime = 1; start_is_datastale = 0; diff --git a/server/conf.c b/server/conf.c index 1831bfdebb..639b750220 100644 --- a/server/conf.c +++ b/server/conf.c @@ -118,11 +118,11 @@ static void ups_update(const char *fn, const char *name, const char *desc) */ static int parse_boolean(char *arg, int *result) { - if ( (!strcasecmp(arg, "true")) || (!strncasecmp(arg, "on", 2)) || (!strncasecmp(arg, "yes", 3)) || (!strncasecmp(arg, "1", 1))) { + if ( (!strcasecmp(arg, "true")) || (!strcasecmp(arg, "on")) || (!strcasecmp(arg, "yes")) || (!strcasecmp(arg, "1"))) { *result = 1; return 1; } - if ( (!strcasecmp(arg, "false")) || (!strncasecmp(arg, "off", 3)) || (!strncasecmp(arg, "no", 2)) || (!strncasecmp(arg, "0", 1))) { + if ( (!strcasecmp(arg, "false")) || (!strcasecmp(arg, "off")) || (!strcasecmp(arg, "no")) || (!strcasecmp(arg, "0"))) { *result = 0; return 1; } @@ -266,7 +266,7 @@ static int parse_upsd_conf_args(size_t numargs, char **arg) return 0; /* ACL */ - if (!strncmp(arg[0], "ACL", 3)) { + if (!strcmp(arg[0], "ACL")) { upslogx(LOG_WARNING, "ACL in upsd.conf is no longer supported - switch to LISTEN"); return 1; } diff --git a/server/netget.c b/server/netget.c index 505b71b092..a5f822a569 100644 --- a/server/netget.c +++ b/server/netget.c @@ -258,7 +258,7 @@ void net_get(nut_ctype_t *client, size_t numarg, const char **arg) } /* GET VAR UPS VARNAME */ - if (!strncasecmp(arg[0], "VAR", 3)) { + if (!strcasecmp(arg[0], "VAR")) { get_var(client, arg[1], arg[2]); return; } diff --git a/server/netlist.c b/server/netlist.c index 132ceddb6a..d480eb1fa3 100644 --- a/server/netlist.c +++ b/server/netlist.c @@ -293,7 +293,7 @@ void net_list(nut_ctype_t *client, size_t numarg, const char **arg) } /* LIST UPS */ - if (!strncasecmp(arg[0], "UPS", 3)) { + if (!strcasecmp(arg[0], "UPS")) { list_ups(client); return; } @@ -304,19 +304,19 @@ void net_list(nut_ctype_t *client, size_t numarg, const char **arg) } /* LIST VAR UPS */ - if (!strncasecmp(arg[0], "VAR", 3)) { + if (!strcasecmp(arg[0], "VAR")) { list_var(client, arg[1]); return; } /* LIST RW UPS */ - if (!strncasecmp(arg[0], "RW", 2)) { + if (!strcasecmp(arg[0], "RW")) { list_rw(client, arg[1]); return; } /* LIST CMD UPS */ - if (!strncasecmp(arg[0], "CMD", 3)) { + if (!strcasecmp(arg[0], "CMD")) { list_cmd(client, arg[1]); return; } diff --git a/server/netset.c b/server/netset.c index 549b2db4c5..1e185b86d7 100644 --- a/server/netset.c +++ b/server/netset.c @@ -181,7 +181,7 @@ void net_set(nut_ctype_t *client, size_t numarg, const char **arg) } /* SET VAR UPS VARNAME VALUE */ - if (!strncasecmp(arg[0], "VAR", 3)) { + if (!strcasecmp(arg[0], "VAR")) { if (numarg < 4) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; @@ -199,11 +199,11 @@ void net_set(nut_ctype_t *client, size_t numarg, const char **arg) /* SET TRACKING VALUE */ if (!strcasecmp(arg[0], "TRACKING")) { - if (!strncasecmp(arg[1], "ON", 2)) { + if (!strcasecmp(arg[1], "ON")) { /* general enablement along with for this client */ client->tracking = tracking_enable(); } - else if (!strncasecmp(arg[1], "OFF", 3)) { + else if (!strcasecmp(arg[1], "OFF")) { /* disable status tracking for this client first */ client->tracking = 0; /* then only disable the general one if no other clients use it! diff --git a/server/user.c b/server/user.c index 8508cf1700..b0c985be55 100644 --- a/server/user.c +++ b/server/user.c @@ -222,7 +222,7 @@ static int user_matchinstcmd(ulist_t *user, const char * cmd) return 1; /* good */ } - if (!strncasecmp(tmp->cmd, "all", 3)) { + if (!strcasecmp(tmp->cmd, "all")) { return 1; /* good */ } } @@ -444,7 +444,7 @@ static void user_parse_arg(size_t numargs, char **arg) } /* handle 'foo = bar' (split form) */ - if (!strncmp(arg[1], "=", 1)) { + if (!strcmp(arg[1], "=")) { /* 0 1 2 3 4 ... */ /* foo = bar ... */ diff --git a/tests/cpputest.cpp b/tests/cpputest.cpp index 31702604e8..d0b0adbec7 100644 --- a/tests/cpputest.cpp +++ b/tests/cpputest.cpp @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) { bool verbose = false; if (argc > 1) { - if (strncmp("-v", argv[1], 2) == 0 || strcmp("--verbose", argv[1]) == 0 ) { + if (strcmp("-v", argv[1]) == 0 || strcmp("--verbose", argv[1]) == 0 ) { verbose = true; } } diff --git a/tools/nut-scanner/nut-scanner.c b/tools/nut-scanner/nut-scanner.c index 9856235274..30a7206720 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -525,10 +525,10 @@ int main(int argc, char *argv[]) else if (!strcmp(optarg, "STRAIGHT_PASSWORD_KEY")) { ipmi_sec.authentication_type = IPMI_AUTHENTICATION_TYPE_STRAIGHT_PASSWORD_KEY; } - else if (!strncmp(optarg, "MD2", 3)) { + else if (!strcmp(optarg, "MD2")) { ipmi_sec.authentication_type = IPMI_AUTHENTICATION_TYPE_MD2; } - else if (!strncmp(optarg, "MD5", 3)) { + else if (!strcmp(optarg, "MD5")) { ipmi_sec.authentication_type = IPMI_AUTHENTICATION_TYPE_MD5; } else { diff --git a/tools/nut-scanner/scan_snmp.c b/tools/nut-scanner/scan_snmp.c index e923d3887c..48bdaaa250 100644 --- a/tools/nut-scanner/scan_snmp.c +++ b/tools/nut-scanner/scan_snmp.c @@ -596,7 +596,7 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) if (sec->authProtocol) { #if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol - if (strncmp(sec->authProtocol, "SHA", 3) == 0) { + if (strcmp(sec->authProtocol, "SHA") == 0) { snmp_sess->securityAuthProto = nut_usmHMACSHA1AuthProtocol; snmp_sess->securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/ @@ -632,7 +632,7 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) else #endif #if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol - if (strncmp(sec->authProtocol, "MD5", 3) != 0) { + if (strcmp(sec->authProtocol, "MD5") != 0) { #else { #endif @@ -690,7 +690,7 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) if (sec->privProtocol) { #if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol - if (strncmp(sec->privProtocol, "AES", 3) == 0) { + if (strcmp(sec->privProtocol, "AES") == 0) { snmp_sess->securityPrivProto = nut_usmAESPrivProtocol; snmp_sess->securityPrivProtoLen = sizeof(usmAESPrivProtocol)/ @@ -719,7 +719,7 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) # endif #endif /* NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 */ #if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol - if (strncmp(sec->privProtocol, "DES", 3) != 0) { + if (strcmp(sec->privProtocol, "DES") != 0) { #else { #endif From 71ed8fd69aba63dd65414b6d6c844412316886c0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 27 Jan 2022 03:53:17 +0100 Subject: [PATCH 21/70] Revert "drivers/snmp-ups.c: fix strncmp() limits for "v1" and "v3" checks (copy-pasting typo)" This reverts commit d0d02d3a70c6544c8ea7868dd63738595f2ae657. Currently the configure script should properly avoid the built-in strcmp() versions which upset current build compiler. Using the range-limited strncmp() has a downside of matching start-of-string. --- drivers/snmp-ups.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index e9d55952ab..6ac384934e 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -747,13 +747,13 @@ void nut_snmp_init(const char *type, const char *hostname) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Warray-bounds" #endif - if ((strncmp(version, "v1", 2) == 0) || (strncmp(version, "v2c", 3) == 0)) { - g_snmp_sess.version = (strncmp(version, "v1", 2) == 0) ? SNMP_VERSION_1 : SNMP_VERSION_2c; + if ((strncmp(version, "v1", 3) == 0) || (strncmp(version, "v2c", 3) == 0)) { + g_snmp_sess.version = (strncmp(version, "v1", 3) == 0) ? SNMP_VERSION_1 : SNMP_VERSION_2c; community = testvar(SU_VAR_COMMUNITY) ? getval(SU_VAR_COMMUNITY) : "public"; g_snmp_sess.community = (unsigned char *)xstrdup(community); g_snmp_sess.community_len = strlen(community); } - else if (strncmp(version, "v3", 2) == 0) { + else if (strncmp(version, "v3", 3) == 0) { #ifdef __clang__ # pragma clang diagnostic pop #endif From 4b3c6ce025835791ce9664d91f969a6cea5ed278 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 27 Jan 2022 03:54:44 +0100 Subject: [PATCH 22/70] Revert "drivers/snmp-ups.c: replace strcmp("short string") with strncmp() (clang-3.4 warns about array out of bounds)" This reverts commit d2f7193af42e987f7948e072a963dc7bb1e25dc1. Currently the configure script should properly avoid the built-in strcmp() versions which upset current build compiler. Using the range-limited strncmp() has a downside of matching start-of-string. --- drivers/snmp-ups.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 6ac384934e..d63ebc140b 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -747,13 +747,13 @@ void nut_snmp_init(const char *type, const char *hostname) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Warray-bounds" #endif - if ((strncmp(version, "v1", 3) == 0) || (strncmp(version, "v2c", 3) == 0)) { - g_snmp_sess.version = (strncmp(version, "v1", 3) == 0) ? SNMP_VERSION_1 : SNMP_VERSION_2c; + if ((strcmp(version, "v1") == 0) || (strcmp(version, "v2c") == 0)) { + g_snmp_sess.version = (strcmp(version, "v1") == 0) ? SNMP_VERSION_1 : SNMP_VERSION_2c; community = testvar(SU_VAR_COMMUNITY) ? getval(SU_VAR_COMMUNITY) : "public"; g_snmp_sess.community = (unsigned char *)xstrdup(community); g_snmp_sess.community_len = strlen(community); } - else if (strncmp(version, "v3", 3) == 0) { + else if (strcmp(version, "v3") == 0) { #ifdef __clang__ # pragma clang diagnostic pop #endif From 7ccee802a4cc9b99424d0fc41de089ac3143f7af Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 23 Jan 2022 17:58:27 +0100 Subject: [PATCH 23/70] ci_build.sh: fix CI_FAILFAST to abort after failed configure scripts --- ci_build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ci_build.sh b/ci_build.sh index eaf7921690..80d77c89b5 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -1101,6 +1101,10 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp RES_ALLERRORS=$? FAILED="${FAILED} NUT_SSL_VARIANT=${NUT_SSL_VARIANT}[configure]" # TOTHINK: Do we want to try clean-up if we likely have no Makefile? + if [ "$CI_FAILFAST" = true ]; then + echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2 + break + fi BUILDSTODO="`expr $BUILDSTODO - 1`" || [ "$BUILDSTODO" = "0" ] || break continue } @@ -1221,6 +1225,10 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp RES_ALLERRORS=$? FAILED="${FAILED} NUT_USB_VARIANT=${NUT_USB_VARIANT}[configure]" # TOTHINK: Do we want to try clean-up if we likely have no Makefile? + if [ "$CI_FAILFAST" = true ]; then + echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2 + break + fi BUILDSTODO="`expr $BUILDSTODO - 1`" || [ "$BUILDSTODO" = "0" ] || break continue } From 305f6f8b21a76a387b0d5687b6d0fdfacc1b6298 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 16:39:27 +0100 Subject: [PATCH 24/70] download.txt: "trac" and "alioth" are AWOL, update the links --- docs/download.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/download.txt b/docs/download.txt index 2aa3282b5a..a4852bf8b2 100644 --- a/docs/download.txt +++ b/docs/download.txt @@ -68,12 +68,12 @@ use Git or <>. Browse code ^^^^^^^^^^^ -You can also browse the code at -link:https://github.com/networkupstools/nut[GitHub], or at the -link:http://alioth.debian.org/scm/?group_id=30602[Alioth mirror]. The code was -originally kept in Subversion, and the old -link:http://trac.networkupstools.org/projects/nut[Trac site] will be kept -around for a bit so as not to break the URLs in the mailing list archives. +You can also browse the "vanilla NUT" code at +link:https://github.com/networkupstools/nut[GitHub], +or at packaging sources of operating system distributions such as: + +* link:https://salsa.debian.org/debian/nut/[Debian Salsa mirror] +* link:https://src.fedoraproject.org/rpms/nut/tree/rawhide[Fedora Rawhide mirror] [[Snapshots]] Snapshots From 50a25611d8b3791a525e976b5bca0a4b3697fa00 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 16:41:30 +0100 Subject: [PATCH 25/70] developers.txt: "alioth" is AWOL, update the text --- docs/developers.txt | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/docs/developers.txt b/docs/developers.txt index 352488dd44..57088290dc 100644 --- a/docs/developers.txt +++ b/docs/developers.txt @@ -748,10 +748,10 @@ and know the industry players who help make NUT better and more useful. Source code management ---------------------- -We currently use a Git repository hosted at GitHub (with a mirror at -Alioth) to track changes to the NUT source code. This allows you to -clone the repository (or fork, in GitHub parlance), make changes, and -post them online for review prior to integration. +We currently use a Git repository hosted at GitHub to track changes to +the NUT source code. This allows you to clone the repository (or fork, +in GitHub parlance), make changes, and post them online for peer review +prior to integration. To obtain permission to commit directly to the common upstream NUT repository, you must be prepared to spend a fair amount of time contributing to the @@ -802,14 +802,6 @@ you can limit the depth of the clone: git clone --depth 1 git://github.com/networkupstools/nut.git -In case the GitHub repository is temporarily unavailable for any reason, -we also plan to push to Alioth's -link:https://alioth.debian.org/scm/?group_id=30602[Git server] as well. -You can add a remote reference to your local repository: - - cd path/to/nut - git remote add -f alioth git://anonscm.debian.org/nut/nut.git - Mercurial (hg) access ~~~~~~~~~~~~~~~~~~~~~ From a04d550bd93c970e069f57bdfa74995b6685ec4c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 16:43:13 +0100 Subject: [PATCH 26/70] developers.txt: "trac" is AWOL, update the link to github wiki copy --- docs/documentation.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/documentation.txt b/docs/documentation.txt index 8622b1e6cc..670f595db1 100644 --- a/docs/documentation.txt +++ b/docs/documentation.txt @@ -83,7 +83,7 @@ These are writeups by users of the software. - link:http://www.dimat.unina2.it/LCS/MonitoraggioUpsNutUbuntu10-eng.htm[Deploying NUT on an Ubuntu 10.04 cluster] '(Stefano Angelone)' - link:http://blog.shadypixel.com/monitoring-a-ups-with-nut-on-debian-or-ubuntu-linux[Monitoring a UPS with nut on Debian or Ubuntu Linux] '(Avery Fay)' - link:http://linux.developpez.com/cours/upsusb/[Installation et gestion d'un UPS USB en réseau sous linux] '(Olivier Van Hoof, french)' -- link:http://trac.networkupstools.org/projects/nut/wiki/NutOnMacOSX[Network UPS Tools (NUT) on Mac OS X (10.4.10)] '(Andy Poush)' +- link:https://github.com/networkupstools/nut/wiki/NUT-on-Mac-OS-X[Network UPS Tools (NUT) on Mac OS X (10.4.10)] '(Andy Poush)' - link:http://www.llondel.org/ups.shtml[Interfacing a Contact-Closure UPS to Mac OS X and Linux] '(David Hough)' - link:http://fedoranews.org/contributors/kazutoshi_morioka/nut/[How to use UPS with nut on RedHat / Fedora Core] '(Kazutoshi Morioka)' - link:http://people.freebsd.org/~thierry/nut_FreeBSD_HowTo.txt[FreeBSD installation procedure] '(Thierry Thomas, from FreeBSD)' From 4e1b6ea2d155d39895859ec4da1934b401721761 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 16:45:25 +0100 Subject: [PATCH 27/70] documentation.txt: update with a link to video by Techno Tim --- docs/documentation.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/documentation.txt b/docs/documentation.txt index 670f595db1..b482827bba 100644 --- a/docs/documentation.txt +++ b/docs/documentation.txt @@ -93,6 +93,10 @@ These are writeups by users of the software. - link:http://buffalo.nas-central.org/wiki/Install_a_UPS_%28nut%29[Install a UPS (nut) on a Buffalo NAS] '(various authors)' - link:http://blog.pointbre.com/2903/nutnetwork-ups-tool-korean-guidebook.html[NUT Korean GuideBook] '(PointBre)' +Video articles are also available: + +- link:https://www.youtube.com/watch?v=vyBP7wpN72c[Network UPS Tools (NUT Server) Ultimate Guide] '(Techno Tim)' + News articles and Press releases -------------------------------- From 450222e038ace90eeba30daf4eb1d7c7a996a650 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 17:07:04 +0100 Subject: [PATCH 28/70] documentation.txt: add a blog by James Ridgway --- docs/documentation.txt | 1 + docs/nut.dict | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/documentation.txt b/docs/documentation.txt index b482827bba..b8d946aa00 100644 --- a/docs/documentation.txt +++ b/docs/documentation.txt @@ -92,6 +92,7 @@ These are writeups by users of the software. - link:http://deschis.blogspot.com/2006/07/cum-se-configureaz-un-ups-apollo-seria.html[Cum se configurează un UPS Apollo seria 1000F pe Linux] '(deschis, Romanian)' - link:http://buffalo.nas-central.org/wiki/Install_a_UPS_%28nut%29[Install a UPS (nut) on a Buffalo NAS] '(various authors)' - link:http://blog.pointbre.com/2903/nutnetwork-ups-tool-korean-guidebook.html[NUT Korean GuideBook] '(PointBre)' +- link:https://www.jamesridgway.co.uk/monitoring-eaton-5sc-ups-scripts-and-integration-network-tools-home-assistant/amp/[USB UPS, notifications, and Home Assistant] '(James Ridgway)' Video articles are also available: diff --git a/docs/nut.dict b/docs/nut.dict index 8221b9b8e7..8fd7692a02 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2861 utf-8 +personal_ws-1.1 en 2862 utf-8 AAS ACFAIL ACFREQ @@ -963,6 +963,7 @@ Repotec's Repoteck Richthof Rickard +Ridgway Riihikallio Rik RntmK From 765640a5cb222a5f591076f98aeffc31ac802328 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 17:10:48 +0100 Subject: [PATCH 29/70] NEWS: plea to package maintainers to share their customizations into common uptream --- UPGRADING | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/UPGRADING b/UPGRADING index 7ff3c3cf08..f184a86864 100644 --- a/UPGRADING +++ b/UPGRADING @@ -10,6 +10,13 @@ check this file to see if you need to make changes to your system. Changes from 2.7.4 to 2.7.5 --------------------------- +- Note to distribution packagers: this version hopefully learns from many + past mistakes, so many custom patches may be no longer needed. If some + remain, please consider making pull requests for upstream NUT codebase + to share the fixes consistently across the ecosystem. Also note that + some new types of drivers (so package groups with unique dependencies) + could have appeared since your packaging was written (e.g. with modbus). + - Due to changes needed to resolve build warnings, mostly about mismatching data types for some variables, some structure definitions and API signatures of several routines had to be changed for argument types, return types, From a6ad5c9463a404b02a686614cd83d267fe0abc85 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 18:02:11 +0100 Subject: [PATCH 30/70] drivers: bump versions for all drivers, they could have been refactored during fightwarn (so might add regressions) without regard to versioning --- drivers/al175.c | 2 +- drivers/apc-ats-mib.c | 2 +- drivers/apc-hid.c | 2 +- drivers/apc-mib.c | 2 +- drivers/apc-pdu-mib.c | 2 +- drivers/apcsmart-old.c | 2 +- drivers/apcsmart.h | 2 +- drivers/apcupsd-ups.c | 2 +- drivers/arduino-hid.c | 2 +- drivers/asem.c | 2 +- drivers/baytech-mib.c | 4 ++-- drivers/bcmxcp.c | 2 +- drivers/bcmxcp_ser.c | 2 +- drivers/bcmxcp_usb.c | 2 +- drivers/belkin-hid.c | 2 +- drivers/belkin.c | 2 +- drivers/belkinunv.c | 2 +- drivers/bestfcom.c | 2 +- drivers/bestfortress.c | 2 +- drivers/bestpower-mib.c | 2 +- drivers/bestuferrups.c | 2 +- drivers/bestups.c | 2 +- drivers/blazer_ser.c | 2 +- drivers/blazer_usb.c | 2 +- drivers/clone-outlet.c | 2 +- drivers/clone.c | 2 +- drivers/compaq-mib.c | 2 +- drivers/cps-hid.c | 2 +- drivers/cyberpower-mib.c | 2 +- drivers/delta_ups-hid.c | 2 +- drivers/delta_ups-mib.c | 2 +- drivers/dummy-ups.c | 2 +- drivers/eaton-ats16-nm2-mib.c | 2 +- drivers/eaton-ats16-nmc-mib.c | 2 +- drivers/eaton-ats30-mib.c | 2 +- drivers/eaton-pdu-genesis2-mib.c | 2 +- drivers/eaton-pdu-marlin-mib.c | 2 +- drivers/eaton-pdu-pulizzi-mib.c | 2 +- drivers/eaton-pdu-revelation-mib.c | 2 +- drivers/emerson-avocent-pdu-mib.c | 2 +- drivers/etapro.c | 2 +- drivers/everups.c | 2 +- drivers/explore-hid.c | 2 +- drivers/gamatronic.c | 2 +- drivers/generic_modbus.c | 2 +- drivers/genericups.c | 2 +- drivers/hpe-pdu-mib.c | 2 +- drivers/huawei-mib.c | 2 +- drivers/huawei-ups2000.c | 2 +- drivers/idowell-hid.c | 2 +- drivers/ietf-mib.c | 2 +- drivers/isbmex.c | 2 +- drivers/ivtscd.c | 2 +- drivers/legrand-hid.c | 2 +- drivers/libshut.c | 2 +- drivers/libusb0.c | 2 +- drivers/libusb1.c | 2 +- drivers/liebert-esp2.c | 2 +- drivers/liebert-hid.c | 2 +- drivers/liebert.c | 2 +- drivers/macosx-ups.c | 2 +- drivers/masterguard.c | 2 +- drivers/metasys.c | 2 +- drivers/mge-hid.c | 2 +- drivers/mge-mib.c | 2 +- drivers/mge-utalk.c | 2 +- drivers/microdowell.c | 2 +- drivers/microsol-apc.c | 2 +- drivers/netvision-mib.c | 2 +- drivers/netxml-ups.c | 2 +- drivers/nut-ipmipsu.c | 2 +- drivers/nutdrv_atcl_usb.c | 2 +- drivers/nutdrv_qx.c | 2 +- drivers/nutdrv_siemens_sitop.c | 2 +- drivers/oneac.c | 2 +- drivers/openups-hid.c | 2 +- drivers/optiups.c | 2 +- drivers/phoenixcontact_modbus.c | 2 +- drivers/pijuice.c | 2 +- drivers/powercom-hid.c | 2 +- drivers/powercom.c | 2 +- drivers/powerman-pdu.c | 2 +- drivers/powerpanel.c | 2 +- drivers/powervar-hid.c | 2 +- drivers/powerware-mib.c | 2 +- drivers/raritan-pdu-mib.c | 2 +- drivers/raritan-px2-mib.c | 2 +- drivers/rhino.c | 2 +- drivers/richcomm_usb.c | 2 +- drivers/riello_ser.c | 2 +- drivers/riello_usb.c | 2 +- drivers/safenet.c | 2 +- drivers/salicru-hid.c | 2 +- drivers/skel.c | 2 +- drivers/snmp-ups.c | 2 +- drivers/solis.c | 2 +- drivers/tripplite-hid.c | 2 +- drivers/tripplite.c | 2 +- drivers/tripplite_usb.c | 2 +- drivers/tripplitesu.c | 2 +- drivers/upscode2.c | 2 +- drivers/usbhid-ups.c | 2 +- drivers/victronups.c | 2 +- drivers/xppc-mib.c | 2 +- 104 files changed, 105 insertions(+), 105 deletions(-) diff --git a/drivers/al175.c b/drivers/al175.c index 4045dbb526..f014435df2 100644 --- a/drivers/al175.c +++ b/drivers/al175.c @@ -52,7 +52,7 @@ typedef uint8_t byte_t; #define DRIVER_NAME "Eltek AL175/COMLI driver" -#define DRIVER_VERSION "0.12" +#define DRIVER_VERSION "0.13" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/apc-ats-mib.c b/drivers/apc-ats-mib.c index 58b0a659e6..3f567590b7 100644 --- a/drivers/apc-ats-mib.c +++ b/drivers/apc-ats-mib.c @@ -24,7 +24,7 @@ #include "apc-ats-mib.h" -#define APC_ATS_MIB_VERSION "0.4" +#define APC_ATS_MIB_VERSION "0.5" #define APC_ATS_SYSOID ".1.3.6.1.4.1.318.1.3.11" #define APC_ATS_OID_MODEL_NAME ".1.3.6.1.4.1.318.1.1.8.1.5.0" diff --git a/drivers/apc-hid.c b/drivers/apc-hid.c index ca40d8f39e..4482216db7 100644 --- a/drivers/apc-hid.c +++ b/drivers/apc-hid.c @@ -31,7 +31,7 @@ #include "apc-hid.h" #include "usb-common.h" -#define APC_HID_VERSION "APC HID 0.96" +#define APC_HID_VERSION "APC HID 0.97" /* APC */ #define APC_VENDORID 0x051d diff --git a/drivers/apc-mib.c b/drivers/apc-mib.c index 44538b098c..e0294a2fcf 100644 --- a/drivers/apc-mib.c +++ b/drivers/apc-mib.c @@ -26,7 +26,7 @@ #include "apc-mib.h" -#define APCC_MIB_VERSION "1.4" +#define APCC_MIB_VERSION "1.5" #define APC_UPS_DEVICE_MODEL ".1.3.6.1.4.1.318.1.1.1.1.1.1.0" /* FIXME: Find a better oid_auto_check vs sysOID for this one? */ diff --git a/drivers/apc-pdu-mib.c b/drivers/apc-pdu-mib.c index 7ddfe7addb..38963d577e 100644 --- a/drivers/apc-pdu-mib.c +++ b/drivers/apc-pdu-mib.c @@ -23,7 +23,7 @@ #include "apc-pdu-mib.h" -#define APC_PDU_MIB_VERSION "0.3" +#define APC_PDU_MIB_VERSION "0.4" #define APC_PDU_MIB_SYSOID_RPDU ".1.3.6.1.4.1.318.1.3.4.4" #define APC_PDU_MIB_SYSOID_RPDU2 ".1.3.6.1.4.1.318.1.3.4.5" diff --git a/drivers/apcsmart-old.c b/drivers/apcsmart-old.c index 4ba4b95843..34a82a56ec 100644 --- a/drivers/apcsmart-old.c +++ b/drivers/apcsmart-old.c @@ -25,7 +25,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "APC Smart protocol driver" -#define DRIVER_VERSION "2.1" +#define DRIVER_VERSION "2.2" static upsdrv_info_t table_info = { "APC command table", diff --git a/drivers/apcsmart.h b/drivers/apcsmart.h index 4326a995cd..fe7bd1ad29 100644 --- a/drivers/apcsmart.h +++ b/drivers/apcsmart.h @@ -24,7 +24,7 @@ #define NUT_APCSMART_H_SEEN 1 #define DRIVER_NAME "APC Smart protocol driver" -#define DRIVER_VERSION "3.1" +#define DRIVER_VERSION "3.2" #define ALT_CABLE_1 "940-0095B" diff --git a/drivers/apcupsd-ups.c b/drivers/apcupsd-ups.c index 1f14332bfb..29d20dd331 100644 --- a/drivers/apcupsd-ups.c +++ b/drivers/apcupsd-ups.c @@ -29,7 +29,7 @@ #include "attribute.h" #define DRIVER_NAME "apcupsd network client UPS driver" -#define DRIVER_VERSION "0.5" +#define DRIVER_VERSION "0.6" #define POLL_INTERVAL_MIN 10 diff --git a/drivers/arduino-hid.c b/drivers/arduino-hid.c index 28ba731bb2..5b74c12802 100644 --- a/drivers/arduino-hid.c +++ b/drivers/arduino-hid.c @@ -32,7 +32,7 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define ARDUINO_HID_VERSION "Arduino HID 0.1" +#define ARDUINO_HID_VERSION "Arduino HID 0.2" /* FIXME: experimental flag to be put in upsdrv_info */ /* Arduino */ diff --git a/drivers/asem.c b/drivers/asem.c index 9ecf7b3753..7b0af43476 100644 --- a/drivers/asem.c +++ b/drivers/asem.c @@ -67,7 +67,7 @@ #endif #define DRIVER_NAME "ASEM" -#define DRIVER_VERSION "0.10" +#define DRIVER_VERSION "0.11" /* Valid on ASEM PB1300 UPS */ #define BQ2060_ADDRESS 0x0B diff --git a/drivers/baytech-mib.c b/drivers/baytech-mib.c index 2da0a59bde..6dfdca8050 100644 --- a/drivers/baytech-mib.c +++ b/drivers/baytech-mib.c @@ -23,8 +23,8 @@ #include "baytech-mib.h" -/* FIXME: should be "X.Y[Z]"! */ -#define BAYTECH_MIB_VERSION "4032" +/* NOTE: last badly versioned release was "4032" but should be "X.Y[Z]"! */ +#define BAYTECH_MIB_VERSION "0.4033" /* Baytech MIB */ #define BAYTECH_OID_MIB ".1.3.6.1.4.1.4779" diff --git a/drivers/bcmxcp.c b/drivers/bcmxcp.c index b191d4babb..e0ea90499b 100644 --- a/drivers/bcmxcp.c +++ b/drivers/bcmxcp.c @@ -118,7 +118,7 @@ TODO List: #include "bcmxcp.h" #define DRIVER_NAME "BCMXCP UPS driver" -#define DRIVER_VERSION "0.31" +#define DRIVER_VERSION "0.32" #define MAX_NUT_NAME_LENGTH 128 #define NUT_OUTLET_POSITION 7 diff --git a/drivers/bcmxcp_ser.c b/drivers/bcmxcp_ser.c index f5b7ccf48b..58595f390b 100644 --- a/drivers/bcmxcp_ser.c +++ b/drivers/bcmxcp_ser.c @@ -6,7 +6,7 @@ #include "nut_stdint.h" #define SUBDRIVER_NAME "RS-232 communication subdriver" -#define SUBDRIVER_VERSION "0.20" +#define SUBDRIVER_VERSION "0.21" /* communication driver description structure */ upsdrv_info_t comm_upsdrv_info = { diff --git a/drivers/bcmxcp_usb.c b/drivers/bcmxcp_usb.c index 93dce58ce9..49cf8ade58 100644 --- a/drivers/bcmxcp_usb.c +++ b/drivers/bcmxcp_usb.c @@ -11,7 +11,7 @@ #include #define SUBDRIVER_NAME "USB communication subdriver" -#define SUBDRIVER_VERSION "0.26" +#define SUBDRIVER_VERSION "0.27" /* communication driver description structure */ upsdrv_info_t comm_upsdrv_info = { diff --git a/drivers/belkin-hid.c b/drivers/belkin-hid.c index 60baa3f3c7..c1aaccf1eb 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.17" +#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.18" /* Belkin */ #define BELKIN_VENDORID 0x050d diff --git a/drivers/belkin.c b/drivers/belkin.c index 2a2b3b9f9f..6757fc7e3e 100644 --- a/drivers/belkin.c +++ b/drivers/belkin.c @@ -28,7 +28,7 @@ #include "belkin.h" #define DRIVER_NAME "Belkin Smart protocol driver" -#define DRIVER_VERSION "0.24" +#define DRIVER_VERSION "0.25" static ssize_t init_communication(void); static ssize_t get_belkin_reply(char *buf); diff --git a/drivers/belkinunv.c b/drivers/belkinunv.c index 76f61ed1f1..0a46be4951 100644 --- a/drivers/belkinunv.c +++ b/drivers/belkinunv.c @@ -94,7 +94,7 @@ #include "serial.h" #define DRIVER_NAME "Belkin 'Universal UPS' driver" -#define DRIVER_VERSION "0.07" +#define DRIVER_VERSION "0.08" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/bestfcom.c b/drivers/bestfcom.c index 2002cc04fc..c53aa953f2 100644 --- a/drivers/bestfcom.c +++ b/drivers/bestfcom.c @@ -45,7 +45,7 @@ #include "serial.h" #define DRIVER_NAME "Best Ferrups/Fortress driver" -#define DRIVER_VERSION "0.12" +#define DRIVER_VERSION "0.13" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/bestfortress.c b/drivers/bestfortress.c index 23d49751d1..97300f673d 100644 --- a/drivers/bestfortress.c +++ b/drivers/bestfortress.c @@ -35,7 +35,7 @@ #endif #define DRIVER_NAME "Best Fortress UPS driver" -#define DRIVER_VERSION "0.05" +#define DRIVER_VERSION "0.06" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/bestpower-mib.c b/drivers/bestpower-mib.c index ff58fdbfdd..8512dfeb79 100644 --- a/drivers/bestpower-mib.c +++ b/drivers/bestpower-mib.c @@ -22,7 +22,7 @@ #include "bestpower-mib.h" -#define BESTPOWER_MIB_VERSION "0.2" +#define BESTPOWER_MIB_VERSION "0.3" #define BESTPOWER_OID_MODEL_NAME ".1.3.6.1.4.1.2947.1.1.2.0" /* diff --git a/drivers/bestuferrups.c b/drivers/bestuferrups.c index cbc52f7e59..8bed32bfc6 100644 --- a/drivers/bestuferrups.c +++ b/drivers/bestuferrups.c @@ -33,7 +33,7 @@ #include "serial.h" #define DRIVER_NAME "Best Ferrups Series ME/RE/MD driver" -#define DRIVER_VERSION "0.03" +#define DRIVER_VERSION "0.04" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/bestups.c b/drivers/bestups.c index 6cd8c4edbd..c0d56d7b48 100644 --- a/drivers/bestups.c +++ b/drivers/bestups.c @@ -28,7 +28,7 @@ #include "serial.h" #define DRIVER_NAME "Best UPS driver" -#define DRIVER_VERSION "1.06" +#define DRIVER_VERSION "1.07" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/blazer_ser.c b/drivers/blazer_ser.c index 8b6aca6eed..a906181b35 100644 --- a/drivers/blazer_ser.c +++ b/drivers/blazer_ser.c @@ -31,7 +31,7 @@ #include "blazer.h" #define DRIVER_NAME "Megatec/Q1 protocol serial driver" -#define DRIVER_VERSION "1.57" +#define DRIVER_VERSION "1.58" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/blazer_usb.c b/drivers/blazer_usb.c index e8234bec60..78e271bf6d 100644 --- a/drivers/blazer_usb.c +++ b/drivers/blazer_usb.c @@ -34,7 +34,7 @@ #include "blazer.h" #define DRIVER_NAME "Megatec/Q1 protocol USB driver" -#define DRIVER_VERSION "0.13" +#define DRIVER_VERSION "0.14" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/clone-outlet.c b/drivers/clone-outlet.c index 48fd4c8f86..81374358ad 100644 --- a/drivers/clone-outlet.c +++ b/drivers/clone-outlet.c @@ -26,7 +26,7 @@ #include #define DRIVER_NAME "clone outlet UPS Driver" -#define DRIVER_VERSION "0.01" +#define DRIVER_VERSION "0.02" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/clone.c b/drivers/clone.c index 3e53ddedf8..ab0824d9da 100644 --- a/drivers/clone.c +++ b/drivers/clone.c @@ -28,7 +28,7 @@ #include #define DRIVER_NAME "Clone UPS driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/compaq-mib.c b/drivers/compaq-mib.c index db72861bb9..e379320c27 100644 --- a/drivers/compaq-mib.c +++ b/drivers/compaq-mib.c @@ -30,7 +30,7 @@ #include "compaq-mib.h" -#define CPQPOWER_MIB_VERSION "1.64" +#define CPQPOWER_MIB_VERSION "1.65" #define DEFAULT_ONDELAY "30" #define DEFAULT_OFFDELAY "20" diff --git a/drivers/cps-hid.c b/drivers/cps-hid.c index d746ed2e12..06fc595bd3 100644 --- a/drivers/cps-hid.c +++ b/drivers/cps-hid.c @@ -29,7 +29,7 @@ #include "cps-hid.h" #include "usb-common.h" -#define CPS_HID_VERSION "CyberPower HID 0.5" +#define CPS_HID_VERSION "CyberPower HID 0.6" /* Cyber Power Systems */ #define CPS_VENDORID 0x0764 diff --git a/drivers/cyberpower-mib.c b/drivers/cyberpower-mib.c index 5a35cbc9f3..1a186585e6 100644 --- a/drivers/cyberpower-mib.c +++ b/drivers/cyberpower-mib.c @@ -24,7 +24,7 @@ #include "cyberpower-mib.h" -#define CYBERPOWER_MIB_VERSION "0.3" +#define CYBERPOWER_MIB_VERSION "0.4" #define CYBERPOWER_OID_MODEL_NAME ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0" /* CPS-MIB::ups */ diff --git a/drivers/delta_ups-hid.c b/drivers/delta_ups-hid.c index 80078292f8..49d5af93fb 100644 --- a/drivers/delta_ups-hid.c +++ b/drivers/delta_ups-hid.c @@ -30,7 +30,7 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define DELTA_UPS_HID_VERSION "Delta UPS HID 0.5" +#define DELTA_UPS_HID_VERSION "Delta UPS HID 0.6" /* Delta UPS */ #define DELTA_UPS_VENDORID 0x05dd diff --git a/drivers/delta_ups-mib.c b/drivers/delta_ups-mib.c index a3c7e6ccc5..f1741c0e33 100644 --- a/drivers/delta_ups-mib.c +++ b/drivers/delta_ups-mib.c @@ -25,7 +25,7 @@ #include "delta_ups-mib.h" -#define DELTA_UPS_MIB_VERSION "0.2" +#define DELTA_UPS_MIB_VERSION "0.4" #define DELTA_UPS_SYSOID ".1.3.6.1.4.1.2254.2.4" diff --git a/drivers/dummy-ups.c b/drivers/dummy-ups.c index d489ba3fad..857f5d5e23 100644 --- a/drivers/dummy-ups.c +++ b/drivers/dummy-ups.c @@ -42,7 +42,7 @@ #include "dummy-ups.h" #define DRIVER_NAME "Device simulation and repeater driver" -#define DRIVER_VERSION "0.14" +#define DRIVER_VERSION "0.15" /* driver description structure */ upsdrv_info_t upsdrv_info = diff --git a/drivers/eaton-ats16-nm2-mib.c b/drivers/eaton-ats16-nm2-mib.c index 723dc0d7c6..0e0aa175a9 100644 --- a/drivers/eaton-ats16-nm2-mib.c +++ b/drivers/eaton-ats16-nm2-mib.c @@ -25,7 +25,7 @@ #include "eaton-ats16-nm2-mib.h" -#define EATON_ATS16_NM2_MIB_VERSION "0.19" +#define EATON_ATS16_NM2_MIB_VERSION "0.20" #define EATON_ATS16_NM2_SYSOID ".1.3.6.1.4.1.534.10.2" /* newer Network-M2 */ #define EATON_ATS16_NM2_MODEL ".1.3.6.1.4.1.534.10.2.1.2.0" diff --git a/drivers/eaton-ats16-nmc-mib.c b/drivers/eaton-ats16-nmc-mib.c index 0824b7490d..bc9c7a9f3a 100644 --- a/drivers/eaton-ats16-nmc-mib.c +++ b/drivers/eaton-ats16-nmc-mib.c @@ -25,7 +25,7 @@ #include "eaton-ats16-nmc-mib.h" -#define EATON_ATS16_NMC_MIB_VERSION "0.18" +#define EATON_ATS16_NMC_MIB_VERSION "0.19" #define EATON_ATS16_NMC_SYSOID ".1.3.6.1.4.1.705.1" /* legacy NMC */ #define EATON_ATS16_NMC_MODEL ".1.3.6.1.4.1.534.10.2.1.2.0" diff --git a/drivers/eaton-ats30-mib.c b/drivers/eaton-ats30-mib.c index 7a80187b56..ec03aab22f 100644 --- a/drivers/eaton-ats30-mib.c +++ b/drivers/eaton-ats30-mib.c @@ -24,7 +24,7 @@ #include "eaton-ats30-mib.h" -#define EATON_ATS30_MIB_VERSION "0.02" +#define EATON_ATS30_MIB_VERSION "0.03" #define EATON_ATS30_SYSOID ".1.3.6.1.4.1.534.10.1" #define EATON_ATS30_MODEL ".1.3.6.1.4.1.534.10.1.2.1.0" diff --git a/drivers/eaton-pdu-genesis2-mib.c b/drivers/eaton-pdu-genesis2-mib.c index 78e5748091..24e881f1cf 100644 --- a/drivers/eaton-pdu-genesis2-mib.c +++ b/drivers/eaton-pdu-genesis2-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-genesis2-mib.h" -#define EATON_APHEL_GENESIS2_MIB_VERSION "0.50" +#define EATON_APHEL_GENESIS2_MIB_VERSION "0.51" /* APHEL-GENESIS-II-MIB (monitored ePDU) * ************************************* diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 9d1d12c4dd..fe22ff803d 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -34,7 +34,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.57" +#define EATON_MARLIN_MIB_VERSION "0.58" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" diff --git a/drivers/eaton-pdu-pulizzi-mib.c b/drivers/eaton-pdu-pulizzi-mib.c index aabdc508b1..52fa09a78c 100644 --- a/drivers/eaton-pdu-pulizzi-mib.c +++ b/drivers/eaton-pdu-pulizzi-mib.c @@ -42,7 +42,7 @@ /* Pulizzi Switched ePDU */ -#define EATON_PULIZZI_SW_MIB_VERSION "0.3" +#define EATON_PULIZZI_SW_MIB_VERSION "0.4" #define PULIZZI_SW_OID_MIB ".1.3.6.1.4.1.20677.3.1.1" #define PULIZZI_SW_OID_MODEL_NAME ".1.3.6.1.4.1.20677.2.1.1.0" diff --git a/drivers/eaton-pdu-revelation-mib.c b/drivers/eaton-pdu-revelation-mib.c index 7d417106c2..c38e566246 100644 --- a/drivers/eaton-pdu-revelation-mib.c +++ b/drivers/eaton-pdu-revelation-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-revelation-mib.h" -#define EATON_APHEL_REVELATION_MIB_VERSION "0.50" +#define EATON_APHEL_REVELATION_MIB_VERSION "0.51" /* APHEL PDU-MIB - Revelation MIB (Managed ePDU) * ********************************************* */ diff --git a/drivers/emerson-avocent-pdu-mib.c b/drivers/emerson-avocent-pdu-mib.c index 4aca232c1d..33ff172991 100644 --- a/drivers/emerson-avocent-pdu-mib.c +++ b/drivers/emerson-avocent-pdu-mib.c @@ -25,7 +25,7 @@ #include "emerson-avocent-pdu-mib.h" -#define EMERSON_AVOCENT_MIB_VERSION "1.1" +#define EMERSON_AVOCENT_MIB_VERSION "1.2" #define EMERSON_AVOCENT_SYSOID ".1.3.6.1.4.1.10418.17.1.7" #define EMERSON_AVOCENT_OID_MODEL_NAME ".1.3.6.1.4.1.10418.17.2.1.2.0" diff --git a/drivers/etapro.c b/drivers/etapro.c index 03ebc7c37e..85b88d5964 100644 --- a/drivers/etapro.c +++ b/drivers/etapro.c @@ -55,7 +55,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "ETA PRO driver" -#define DRIVER_VERSION "0.04" +#define DRIVER_VERSION "0.05" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/everups.c b/drivers/everups.c index cd2f7881f5..2338e4dc78 100644 --- a/drivers/everups.c +++ b/drivers/everups.c @@ -21,7 +21,7 @@ #include "serial.h" #define DRIVER_NAME "Ever UPS driver" -#define DRIVER_VERSION "0.03" +#define DRIVER_VERSION "0.04" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/explore-hid.c b/drivers/explore-hid.c index 465fd7ff2d..f9e86906c7 100644 --- a/drivers/explore-hid.c +++ b/drivers/explore-hid.c @@ -25,7 +25,7 @@ #include "usbhid-ups.h" #include "explore-hid.h" -#define EXPLORE_HID_VERSION "EXPLORE HID 0.1" +#define EXPLORE_HID_VERSION "EXPLORE HID 0.2" static usage_tables_t explore_utab[] = { hid_usage_lkp, diff --git a/drivers/gamatronic.c b/drivers/gamatronic.c index 084cf64f88..b0be56db45 100644 --- a/drivers/gamatronic.c +++ b/drivers/gamatronic.c @@ -33,7 +33,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "Gamatronic UPS driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/generic_modbus.c b/drivers/generic_modbus.c index 44d99168cf..478e838b04 100644 --- a/drivers/generic_modbus.c +++ b/drivers/generic_modbus.c @@ -26,7 +26,7 @@ #include #define DRIVER_NAME "NUT Generic Modbus driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" /* variables */ static modbus_t *mbctx = NULL; /* modbus memory context */ diff --git a/drivers/genericups.c b/drivers/genericups.c index 637cd08916..d6568ddad2 100644 --- a/drivers/genericups.c +++ b/drivers/genericups.c @@ -27,7 +27,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "Generic contact-closure UPS driver" -#define DRIVER_VERSION "1.37" +#define DRIVER_VERSION "1.38" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/hpe-pdu-mib.c b/drivers/hpe-pdu-mib.c index 3f0206b7cd..70a0c7a206 100644 --- a/drivers/hpe-pdu-mib.c +++ b/drivers/hpe-pdu-mib.c @@ -24,7 +24,7 @@ #include "hpe-pdu-mib.h" #include "dstate.h" -#define HPE_EPDU_MIB_VERSION "0.31" +#define HPE_EPDU_MIB_VERSION "0.32" #define HPE_EPDU_MIB_SYSOID ".1.3.6.1.4.1.232.165.7" #define HPE_EPDU_OID_MODEL_NAME ".1.3.6.1.4.1.232.165.7.1.2.1.3.0" diff --git a/drivers/huawei-mib.c b/drivers/huawei-mib.c index 9de1255ff9..00cd6e4ed7 100644 --- a/drivers/huawei-mib.c +++ b/drivers/huawei-mib.c @@ -21,7 +21,7 @@ #include "huawei-mib.h" -#define HUAWEI_MIB_VERSION "0.2" +#define HUAWEI_MIB_VERSION "0.3" #define HUAWEI_SYSOID ".1.3.6.1.4.1.8072.3.2.10" #define HUAWEI_UPSMIB ".1.3.6.1.4.1.2011" diff --git a/drivers/huawei-ups2000.c b/drivers/huawei-ups2000.c index c0cb6f5337..c144fcc26d 100644 --- a/drivers/huawei-ups2000.c +++ b/drivers/huawei-ups2000.c @@ -61,7 +61,7 @@ #include "serial.h" #define DRIVER_NAME "NUT Huawei UPS2000 (1kVA-3kVA) RS-232 Modbus driver" -#define DRIVER_VERSION "0.01" +#define DRIVER_VERSION "0.02" #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) #define MODBUS_SLAVE_ID 1 diff --git a/drivers/idowell-hid.c b/drivers/idowell-hid.c index 402b236f68..f96958f72f 100644 --- a/drivers/idowell-hid.c +++ b/drivers/idowell-hid.c @@ -30,7 +30,7 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define IDOWELL_HID_VERSION "iDowell HID 0.1" +#define IDOWELL_HID_VERSION "iDowell HID 0.2" /* FIXME: experimental flag to be put in upsdrv_info */ /* iDowell */ diff --git a/drivers/ietf-mib.c b/drivers/ietf-mib.c index e6bab56fe9..3c6b922315 100644 --- a/drivers/ietf-mib.c +++ b/drivers/ietf-mib.c @@ -26,7 +26,7 @@ #include "ietf-mib.h" -#define IETF_MIB_VERSION "1.52" +#define IETF_MIB_VERSION "1.53" /* SNMP OIDs set */ #define IETF_OID_UPS_MIB "1.3.6.1.2.1.33.1." diff --git a/drivers/isbmex.c b/drivers/isbmex.c index 9ef4788b82..8762562efc 100644 --- a/drivers/isbmex.c +++ b/drivers/isbmex.c @@ -27,7 +27,7 @@ #include #define DRIVER_NAME "ISBMEX UPS driver" -#define DRIVER_VERSION "0.06" +#define DRIVER_VERSION "0.07" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/ivtscd.c b/drivers/ivtscd.c index 3ebe689a02..1c3cee73c6 100644 --- a/drivers/ivtscd.c +++ b/drivers/ivtscd.c @@ -24,7 +24,7 @@ #include "attribute.h" #define DRIVER_NAME "IVT Solar Controller driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/legrand-hid.c b/drivers/legrand-hid.c index b06ecca5ae..371555328b 100644 --- a/drivers/legrand-hid.c +++ b/drivers/legrand-hid.c @@ -28,7 +28,7 @@ #include "main.h" #include "usb-common.h" -#define LEGRAND_HID_VERSION "Legrand HID 0.1" +#define LEGRAND_HID_VERSION "Legrand HID 0.2" /* Legrand VendorID and ProductID */ #define LEGRAND_VID 0x1cb0 /* Legrand */ diff --git a/drivers/libshut.c b/drivers/libshut.c index 2b85be4757..4376d588a4 100644 --- a/drivers/libshut.c +++ b/drivers/libshut.c @@ -43,7 +43,7 @@ #include "common.h" /* for xmalloc, upsdebugx prototypes */ #define SHUT_DRIVER_NAME "SHUT communication driver" -#define SHUT_DRIVER_VERSION "0.85" +#define SHUT_DRIVER_VERSION "0.86" /* communication driver description structure */ upsdrv_info_t comm_upsdrv_info = { diff --git a/drivers/libusb0.c b/drivers/libusb0.c index c7e9a4c025..adf098ba31 100644 --- a/drivers/libusb0.c +++ b/drivers/libusb0.c @@ -34,7 +34,7 @@ #include "nut_libusb.h" #define USB_DRIVER_NAME "USB communication driver (libusb 0.1)" -#define USB_DRIVER_VERSION "0.35" +#define USB_DRIVER_VERSION "0.42" /* driver description structure */ upsdrv_info_t comm_upsdrv_info = { diff --git a/drivers/libusb1.c b/drivers/libusb1.c index 67408b9ac4..dd07435c33 100644 --- a/drivers/libusb1.c +++ b/drivers/libusb1.c @@ -33,7 +33,7 @@ #include "nut_stdint.h" #define USB_DRIVER_NAME "USB communication driver (libusb 1.0)" -#define USB_DRIVER_VERSION "0.9" +#define USB_DRIVER_VERSION "0.42" /* driver description structure */ upsdrv_info_t comm_upsdrv_info = { diff --git a/drivers/liebert-esp2.c b/drivers/liebert-esp2.c index 4bb1cbcb8e..f8e8e8567c 100644 --- a/drivers/liebert-esp2.c +++ b/drivers/liebert-esp2.c @@ -28,7 +28,7 @@ #define IsBitSet(val, bit) ((val) & (1 << (bit))) #define DRIVER_NAME "Liebert ESP-II serial UPS driver" -#define DRIVER_VERSION "0.04" +#define DRIVER_VERSION "0.05" #define UPS_SHUTDOWN_DELAY 12 /* it means UPS will be shutdown 120 sec */ #define SHUTDOWN_CMD_LEN 8 diff --git a/drivers/liebert-hid.c b/drivers/liebert-hid.c index be8817d77f..1f05ebdd48 100644 --- a/drivers/liebert-hid.c +++ b/drivers/liebert-hid.c @@ -26,7 +26,7 @@ #include "liebert-hid.h" #include "usb-common.h" -#define LIEBERT_HID_VERSION "Phoenixtec/Liebert HID 0.3" +#define LIEBERT_HID_VERSION "Phoenixtec/Liebert HID 0.4" /* FIXME: experimental flag to be put in upsdrv_info */ /* Phoenixtec Power Co., Ltd */ diff --git a/drivers/liebert.c b/drivers/liebert.c index 4df8b74a65..65bb539700 100644 --- a/drivers/liebert.c +++ b/drivers/liebert.c @@ -27,7 +27,7 @@ #include "attribute.h" #define DRIVER_NAME "Liebert MultiLink UPS driver" -#define DRIVER_VERSION "1.02" +#define DRIVER_VERSION "1.03" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/macosx-ups.c b/drivers/macosx-ups.c index 393a416f03..94b8b01e3f 100644 --- a/drivers/macosx-ups.c +++ b/drivers/macosx-ups.c @@ -29,7 +29,7 @@ #include "IOKit/ps/IOPSKeys.h" #define DRIVER_NAME "Mac OS X UPS meta-driver" -#define DRIVER_VERSION "1.2" +#define DRIVER_VERSION "1.3" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/masterguard.c b/drivers/masterguard.c index 450d1bd19a..89609ba2e7 100644 --- a/drivers/masterguard.c +++ b/drivers/masterguard.c @@ -23,7 +23,7 @@ #include "serial.h" #define DRIVER_NAME "MASTERGUARD UPS driver" -#define DRIVER_VERSION "0.24" +#define DRIVER_VERSION "0.25" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/metasys.c b/drivers/metasys.c index 057ae0af3e..9c307adec1 100644 --- a/drivers/metasys.c +++ b/drivers/metasys.c @@ -28,7 +28,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "Metasystem UPS driver" -#define DRIVER_VERSION "0.07" +#define DRIVER_VERSION "0.08" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index f57b0c4a77..b07c5d82e7 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -38,7 +38,7 @@ #include "mge-hid.h" #include "nut_float.h" -#define MGE_HID_VERSION "MGE HID 1.44" +#define MGE_HID_VERSION "MGE HID 1.45" /* (prev. MGE Office Protection Systems, prev. MGE UPS SYSTEMS) */ /* Eaton */ diff --git a/drivers/mge-mib.c b/drivers/mge-mib.c index aac74cbdf9..e987c5612f 100644 --- a/drivers/mge-mib.c +++ b/drivers/mge-mib.c @@ -27,7 +27,7 @@ #include "mge-mib.h" -#define MGE_MIB_VERSION "0.52" +#define MGE_MIB_VERSION "0.53" /* TODO: * - MGE PDU MIB and sysOID (".1.3.6.1.4.1.705.2") */ diff --git a/drivers/mge-utalk.c b/drivers/mge-utalk.c index 57142b92e9..19c36616e5 100644 --- a/drivers/mge-utalk.c +++ b/drivers/mge-utalk.c @@ -66,7 +66,7 @@ /* --------------------------------------------------------------- */ #define DRIVER_NAME "MGE UPS SYSTEMS/U-Talk driver" -#define DRIVER_VERSION "0.93" +#define DRIVER_VERSION "0.94" /* driver description structure */ diff --git a/drivers/microdowell.c b/drivers/microdowell.c index e6e376538a..846764e84b 100644 --- a/drivers/microdowell.c +++ b/drivers/microdowell.c @@ -42,7 +42,7 @@ #define MAX_SHUTDOWN_DELAY_LEN 5 #define DRIVER_NAME "MICRODOWELL UPS driver" -#define DRIVER_VERSION "0.01" +#define DRIVER_VERSION "0.02" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/microsol-apc.c b/drivers/microsol-apc.c index 0f04318ef9..20e0cd3466 100644 --- a/drivers/microsol-apc.c +++ b/drivers/microsol-apc.c @@ -35,7 +35,7 @@ #include "microsol-apc.h" #define DRIVER_NAME "APC Back-UPS BR series UPS driver" -#define DRIVER_VERSION "0.68" +#define DRIVER_VERSION "0.69" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/netvision-mib.c b/drivers/netvision-mib.c index 9affa6a0ec..db035985c6 100644 --- a/drivers/netvision-mib.c +++ b/drivers/netvision-mib.c @@ -25,7 +25,7 @@ #include "netvision-mib.h" -#define NETVISION_MIB_VERSION "0.42" +#define NETVISION_MIB_VERSION "0.43" #define NETVISION_SYSOID ".1.3.6.1.4.1.4555.1.1.1" diff --git a/drivers/netxml-ups.c b/drivers/netxml-ups.c index 2ceea4ab95..330104a175 100644 --- a/drivers/netxml-ups.c +++ b/drivers/netxml-ups.c @@ -42,7 +42,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "network XML UPS" -#define DRIVER_VERSION "0.43" +#define DRIVER_VERSION "0.44" /** *_OBJECT query multi-part body boundary */ #define FORM_POST_BOUNDARY "NUT-NETXML-UPS-OBJECTS" diff --git a/drivers/nut-ipmipsu.c b/drivers/nut-ipmipsu.c index b8020d999c..c0dd658a4f 100644 --- a/drivers/nut-ipmipsu.c +++ b/drivers/nut-ipmipsu.c @@ -27,7 +27,7 @@ #include "nut-ipmi.h" #define DRIVER_NAME "IPMI PSU driver" -#define DRIVER_VERSION "0.30" +#define DRIVER_VERSION "0.31" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/nutdrv_atcl_usb.c b/drivers/nutdrv_atcl_usb.c index a7da0cd56c..4d51a4b164 100644 --- a/drivers/nutdrv_atcl_usb.c +++ b/drivers/nutdrv_atcl_usb.c @@ -28,7 +28,7 @@ /* driver version */ #define DRIVER_NAME "'ATCL FOR UPS' USB driver" -#define DRIVER_VERSION "1.15" +#define DRIVER_VERSION "1.16" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index 6414688ea4..f1addea839 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -38,7 +38,7 @@ * */ -#define DRIVER_VERSION "0.31" +#define DRIVER_VERSION "0.32" #include "config.h" #include "main.h" diff --git a/drivers/nutdrv_siemens_sitop.c b/drivers/nutdrv_siemens_sitop.c index 6cde560ca3..1c1e9efdd1 100644 --- a/drivers/nutdrv_siemens_sitop.c +++ b/drivers/nutdrv_siemens_sitop.c @@ -56,7 +56,7 @@ #include "nut_stdint.h" #define DRIVER_NAME "Siemens SITOP UPS500 series driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" #define RX_BUFFER_SIZE 100 diff --git a/drivers/oneac.c b/drivers/oneac.c index cf243c374b..916fc72928 100644 --- a/drivers/oneac.c +++ b/drivers/oneac.c @@ -47,7 +47,7 @@ int setcmd(const char* varname, const char* setvalue); int instcmd(const char *cmdname, const char *extra); #define DRIVER_NAME "Oneac EG/ON/OZ/OB UPS driver" -#define DRIVER_VERSION "0.80" +#define DRIVER_VERSION "0.81" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/openups-hid.c b/drivers/openups-hid.c index 4656c4544a..d8be70d4cb 100644 --- a/drivers/openups-hid.c +++ b/drivers/openups-hid.c @@ -28,7 +28,7 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define OPENUPS_HID_VERSION "openUPS HID 0.4" +#define OPENUPS_HID_VERSION "openUPS HID 0.5" /* Minibox */ #define OPENUPS_VENDORID 0x04d8 diff --git a/drivers/optiups.c b/drivers/optiups.c index c0797171ca..13eedd5010 100644 --- a/drivers/optiups.c +++ b/drivers/optiups.c @@ -27,7 +27,7 @@ #include "serial.h" #define DRIVER_NAME "Opti-UPS driver" -#define DRIVER_VERSION "1.01" +#define DRIVER_VERSION "1.02" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/phoenixcontact_modbus.c b/drivers/phoenixcontact_modbus.c index 583a84231f..fb4b24e3b3 100644 --- a/drivers/phoenixcontact_modbus.c +++ b/drivers/phoenixcontact_modbus.c @@ -24,7 +24,7 @@ #include #define DRIVER_NAME "NUT PhoenixContact Modbus driver" -#define DRIVER_VERSION "0.01" +#define DRIVER_VERSION "0.02" #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) #define MODBUS_SLAVE_ID 192 diff --git a/drivers/pijuice.c b/drivers/pijuice.c index 23f39a4165..a1b1db1845 100644 --- a/drivers/pijuice.c +++ b/drivers/pijuice.c @@ -218,7 +218,7 @@ static inline __u8* i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 l #define NOMINAL_BATTERY_VOLTAGE 4.18 #define DRIVER_NAME "PiJuice UPS driver" -#define DRIVER_VERSION "0.9" +#define DRIVER_VERSION "0.10" static uint8_t i2c_address = 0x14; static uint8_t shutdown_delay = 30; diff --git a/drivers/powercom-hid.c b/drivers/powercom-hid.c index 9fd7a675b5..a3973ffc05 100644 --- a/drivers/powercom-hid.c +++ b/drivers/powercom-hid.c @@ -25,7 +25,7 @@ #include "powercom-hid.h" #include "usb-common.h" -#define POWERCOM_HID_VERSION "PowerCOM HID 0.5" +#define POWERCOM_HID_VERSION "PowerCOM HID 0.6" /* FIXME: experimental flag to be put in upsdrv_info */ /* PowerCOM */ diff --git a/drivers/powercom.c b/drivers/powercom.c index f244d91fac..6e58a3b98c 100644 --- a/drivers/powercom.c +++ b/drivers/powercom.c @@ -86,7 +86,7 @@ #include "math.h" #define DRIVER_NAME "PowerCom protocol UPS driver" -#define DRIVER_VERSION "0.18" +#define DRIVER_VERSION "0.19" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/powerman-pdu.c b/drivers/powerman-pdu.c index 1611d3ce5b..df4e91f3e5 100644 --- a/drivers/powerman-pdu.c +++ b/drivers/powerman-pdu.c @@ -23,7 +23,7 @@ #include /* pm_err_t and other beasts */ #define DRIVER_NAME "Powerman PDU client driver" -#define DRIVER_VERSION "0.11" +#define DRIVER_VERSION "0.12" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/powerpanel.c b/drivers/powerpanel.c index f327c97673..6c677b8ef9 100644 --- a/drivers/powerpanel.c +++ b/drivers/powerpanel.c @@ -36,7 +36,7 @@ static subdriver_t *subdriver[] = { }; #define DRIVER_NAME "CyberPower text/binary protocol UPS driver" -#define DRIVER_VERSION "0.27" +#define DRIVER_VERSION "0.28" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/powervar-hid.c b/drivers/powervar-hid.c index e9d7427a88..a37978aa48 100755 --- a/drivers/powervar-hid.c +++ b/drivers/powervar-hid.c @@ -32,7 +32,7 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define POWERVAR_HID_VERSION "Powervar HID 0.19" +#define POWERVAR_HID_VERSION "Powervar HID 0.20" /* FIXME: experimental flag to be put in upsdrv_info */ /* Powervar */ diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 66d97bcd62..2521a8e811 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -25,7 +25,7 @@ #include "powerware-mib.h" -#define PW_MIB_VERSION "0.93" +#define PW_MIB_VERSION "0.94" /* TODO: more sysOID and MIBs support: * diff --git a/drivers/raritan-pdu-mib.c b/drivers/raritan-pdu-mib.c index 8ca4da0b2e..65b1d2a788 100644 --- a/drivers/raritan-pdu-mib.c +++ b/drivers/raritan-pdu-mib.c @@ -25,7 +25,7 @@ #include "raritan-pdu-mib.h" -#define RARITAN_MIB_VERSION "0.6" +#define RARITAN_MIB_VERSION "0.7" /* Raritan MIB * this one uses the same MIB as Eaton Revelation, diff --git a/drivers/raritan-px2-mib.c b/drivers/raritan-px2-mib.c index 058616d82d..c49b046610 100644 --- a/drivers/raritan-px2-mib.c +++ b/drivers/raritan-px2-mib.c @@ -23,7 +23,7 @@ #include "raritan-px2-mib.h" -#define RARITAN_PX2_MIB_VERSION "0.2" +#define RARITAN_PX2_MIB_VERSION "0.3" #define RARITAN_PX2_MIB_SYSOID ".1.3.6.1.4.1.13742.6" #define RARITAN_PX2_OID_MODEL_NAME ".1.3.6.1.4.1.13742.6.3.2.1.1.3.1" diff --git a/drivers/rhino.c b/drivers/rhino.c index 2e4dd420ec..c99770d9a6 100644 --- a/drivers/rhino.c +++ b/drivers/rhino.c @@ -37,7 +37,7 @@ #include "timehead.h" #define DRIVER_NAME "Microsol Rhino UPS driver" -#define DRIVER_VERSION "0.51" +#define DRIVER_VERSION "0.52" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/richcomm_usb.c b/drivers/richcomm_usb.c index 99af7913b5..f052225c74 100644 --- a/drivers/richcomm_usb.c +++ b/drivers/richcomm_usb.c @@ -29,7 +29,7 @@ /* driver version */ #define DRIVER_NAME "Richcomm dry-contact to USB driver" -#define DRIVER_VERSION "0.09" +#define DRIVER_VERSION "0.10" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/riello_ser.c b/drivers/riello_ser.c index 75941b8062..d5eeb28757 100644 --- a/drivers/riello_ser.c +++ b/drivers/riello_ser.c @@ -43,7 +43,7 @@ #include "riello.h" #define DRIVER_NAME "Riello serial driver" -#define DRIVER_VERSION "0.03" +#define DRIVER_VERSION "0.04" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 0c99145d32..a0ed97eea0 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -36,7 +36,7 @@ #include "riello.h" #define DRIVER_NAME "Riello USB driver" -#define DRIVER_VERSION "0.05" +#define DRIVER_VERSION "0.06" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/safenet.c b/drivers/safenet.c index 4d3c63d160..2715db85b6 100644 --- a/drivers/safenet.c +++ b/drivers/safenet.c @@ -41,7 +41,7 @@ #include "safenet.h" #define DRIVER_NAME "Generic SafeNet UPS driver" -#define DRIVER_VERSION "1.6" +#define DRIVER_VERSION "1.7" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/salicru-hid.c b/drivers/salicru-hid.c index b362e9a68d..c93f52a845 100644 --- a/drivers/salicru-hid.c +++ b/drivers/salicru-hid.c @@ -32,7 +32,7 @@ #include "main.h" /* for getval() */ #include "usb-common.h" -#define SALICRU_HID_VERSION "Salicru HID 0.2" +#define SALICRU_HID_VERSION "Salicru HID 0.3" /* FIXME: experimental flag to be put in upsdrv_info */ /* Salicru */ diff --git a/drivers/skel.c b/drivers/skel.c index f3e0dba44d..f6d4cb39f7 100644 --- a/drivers/skel.c +++ b/drivers/skel.c @@ -22,7 +22,7 @@ /* #define IGNCHARS "" */ #define DRIVER_NAME "Skeleton UPS driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index d63ebc140b..a3470188f0 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -150,7 +150,7 @@ static const char *mibname; static const char *mibvers; #define DRIVER_NAME "Generic SNMP UPS driver" -#define DRIVER_VERSION "1.17" +#define DRIVER_VERSION "1.18" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/solis.c b/drivers/solis.c index 6a066dca7f..5d18472a9c 100644 --- a/drivers/solis.c +++ b/drivers/solis.c @@ -48,7 +48,7 @@ #include "timehead.h" #define DRIVER_NAME "Microsol Solis UPS driver" -#define DRIVER_VERSION "0.67" +#define DRIVER_VERSION "0.68" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/tripplite-hid.c b/drivers/tripplite-hid.c index 692a951bd4..20d51526a2 100644 --- a/drivers/tripplite-hid.c +++ b/drivers/tripplite-hid.c @@ -29,7 +29,7 @@ #include "tripplite-hid.h" #include "usb-common.h" -#define TRIPPLITE_HID_VERSION "TrippLite HID 0.83" +#define TRIPPLITE_HID_VERSION "TrippLite HID 0.84" /* FIXME: experimental flag to be put in upsdrv_info */ diff --git a/drivers/tripplite.c b/drivers/tripplite.c index f015917705..672c734631 100644 --- a/drivers/tripplite.c +++ b/drivers/tripplite.c @@ -117,7 +117,7 @@ #include #define DRIVER_NAME "Tripp-Lite SmartUPS driver" -#define DRIVER_VERSION "0.92" +#define DRIVER_VERSION "0.93" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/tripplite_usb.c b/drivers/tripplite_usb.c index 800d4c2efb..8b18786cd1 100644 --- a/drivers/tripplite_usb.c +++ b/drivers/tripplite_usb.c @@ -136,7 +136,7 @@ #include "usb-common.h" #define DRIVER_NAME "Tripp Lite OMNIVS / SMARTPRO driver" -#define DRIVER_VERSION "0.31" +#define DRIVER_VERSION "0.32" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/tripplitesu.c b/drivers/tripplitesu.c index e0e6e1fbcf..05e89725c3 100644 --- a/drivers/tripplitesu.c +++ b/drivers/tripplitesu.c @@ -125,7 +125,7 @@ #include "serial.h" #define DRIVER_NAME "Tripp Lite SmartOnline driver" -#define DRIVER_VERSION "0.05" +#define DRIVER_VERSION "0.06" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/upscode2.c b/drivers/upscode2.c index a2b73e19c4..50a4764a8f 100644 --- a/drivers/upscode2.c +++ b/drivers/upscode2.c @@ -43,7 +43,7 @@ #include "nut_float.h" #define DRIVER_NAME "UPScode II UPS driver" -#define DRIVER_VERSION "0.89" +#define DRIVER_VERSION "0.90" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index 5d9de373f1..69361ab22c 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -28,7 +28,7 @@ */ #define DRIVER_NAME "Generic HID driver" -#define DRIVER_VERSION "0.44" +#define DRIVER_VERSION "0.45" #include "main.h" #include "libhid.h" diff --git a/drivers/victronups.c b/drivers/victronups.c index cdec6540ba..f4f6ad6045 100644 --- a/drivers/victronups.c +++ b/drivers/victronups.c @@ -32,7 +32,7 @@ #include "serial.h" #define DRIVER_NAME "GE/IMV/Victron UPS driver" -#define DRIVER_VERSION "0.20" +#define DRIVER_VERSION "0.21" /* driver description structure */ upsdrv_info_t upsdrv_info = { diff --git a/drivers/xppc-mib.c b/drivers/xppc-mib.c index 5e353bcc45..706a550173 100644 --- a/drivers/xppc-mib.c +++ b/drivers/xppc-mib.c @@ -24,7 +24,7 @@ #include "xppc-mib.h" -#define XPPC_MIB_VERSION "0.2" +#define XPPC_MIB_VERSION "0.3" #define XPPC_SYSOID ".1.3.6.1.4.1.935" From d46d51538ae0ac87a17c5f8b5568e7f11721485a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 5 Feb 2022 21:44:13 +0100 Subject: [PATCH 31/70] docs/support.txt: detail abot GitHub issues and PRs, and IRC channel --- docs/nut.dict | 3 ++- docs/support.txt | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/nut.dict b/docs/nut.dict index 8fd7692a02..1b118fcadb 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2862 utf-8 +personal_ws-1.1 en 2863 utf-8 AAS ACFAIL ACFREQ @@ -466,6 +466,7 @@ IPBX IPC IPs IPv +IRC IRIX ITEMP ITy diff --git a/docs/support.txt b/docs/support.txt index 2088889de9..0cb07afce2 100644 --- a/docs/support.txt +++ b/docs/support.txt @@ -95,6 +95,11 @@ for more information, and the chapter on how to link:../developer-guide.chunked/ar01s03.html#_submitting_patches[submit patches]. endif::website[] +Note that the currently preferable way for ultimate submission of improvements +is to link:https://github.com/networkupstools/nut/pulls[post a pull request] +from your GitHub fork of NUT. Benefits of PRs include automated testing and +merge-conflict detection and resolution, as well as tracking discussion that +is often needed to better understand, integrate or document the patch. Discuss packaging and related topics ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,3 +115,33 @@ ifndef::website[] linkdoc:packager-guide[NUT Packager Guide] endif::website[] for more information. + + +IRC (Internet Relay Chat) +------------------------- + +Yes, we're open! + +There is an official `#nut` channel on https://libera.chat/ network. + +Feel free to hang out with whoever is on-line at the moment, or watch reports +from the NUT CI farm as they come. + +Please don't forget the basics of netiquette, such as that any help is done +on a best-effort basis, people have other obligations, and are not always +there even if their chat client is, and that respect and politeness are the +norm (this includes doing some research before asking, and explaining the +context where it is not trivial). + + +GitHub Issues +------------- + +See https://github.com/networkupstools/nut/issues for another venue of +asking (and answering) questions, as well as proposing improvements. + +To report new Devices Dumps Library entries, posting an issue is okay, but +posting a link:https://github.com/networkupstools/nut-ddl/pulls[pull request] +is a lot better -- easier for maintainers to review and merge any time. +For some more detailed instructions about useful DDL reports, please see +link:https://networkupstools.org/ddl/#_file_naming_convention[NUT DDL page]. From b0c0f188d3e9eef9842edec292b37c27477432a3 Mon Sep 17 00:00:00 2001 From: Dimitris Economou Date: Sun, 6 Feb 2022 22:09:07 +0200 Subject: [PATCH 32/70] fix enc size write on pipeifd, fix parent select on child's pipefd --- clients/upssched.c | 73 +++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/clients/upssched.c b/clients/upssched.c index b885015b5c..2c68fe10a3 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -497,15 +497,15 @@ static int sock_read(conn_t *conn) if ((ret == -1) && (errno == EAGAIN)) return 0; + if (ret == 0) /* nothing to parse yet */ + continue; + /* some other problem */ return -1; /* error */ } ret = pconf_char(&conn->ctx, ch); - if (ret == 0) /* nothing to parse yet */ - continue; - if (ret == -1) { upslogx(LOG_NOTICE, "Parse error on sock: %s", conn->ctx.errmsg); @@ -691,32 +691,16 @@ static int check_parent(const char *cmd, const char *arg2) exit(EXIT_FAILURE); } -static void read_timeout(int sig) -{ - NUT_UNUSED_VARIABLE(sig); - - /* ignore this */ - return; -} - -static void setup_sigalrm(void) -{ - struct sigaction sa; - sigset_t nut_upssched_sigmask; - - sigemptyset(&nut_upssched_sigmask); - sa.sa_mask = nut_upssched_sigmask; - sa.sa_flags = 0; - sa.sa_handler = read_timeout; - sigaction(SIGALRM, &sa, NULL); -} - static void sendcmd(const char *cmd, const char *arg1, const char *arg2) { int i, pipefd; ssize_t ret; size_t enclen; char buf[SMALLBUF], enc[SMALLBUF + 8]; + int ret_s; + struct timeval tv; + fd_set fdread; + /* insanity */ if (!arg1) @@ -757,30 +741,39 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) /* we're connected now */ - ret = write(pipefd, enc, enclen); + ret = write(pipefd, enc, sizeof(enc)); /* if we can't send the whole thing, loop back and try again */ - if ((ret < 1) || (ret != (ssize_t) enclen)) { + if ((ret < 1) || (ret != sizeof(enc))) { upslogx(LOG_ERR, "write failed, trying again"); close(pipefd); continue; } - /* ugh - probably should use select here... */ - setup_sigalrm(); - - alarm(2); - ret = read(pipefd, buf, sizeof(buf)); - alarm(0); - -#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wstrict-prototypes" -#endif - signal(SIGALRM, SIG_IGN); -#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) -# pragma GCC diagnostic pop -#endif + /* select on child's pipe fd */ + do { + /* set timeout every time before call select() */ + tv.tv_sec = 1; + tv.tv_usec = 0; + + FD_ZERO(&fdread); + FD_SET(pipefd, &fdread); + + ret_s = select(pipefd + 1, &fdread, NULL, NULL, &tv); + switch(ret_s) { + /* select error */ + case -1: + upslogx(LOG_DEBUG, "parent select error: %s", strerror(errno)); + break; + /* nothing to read */ + case 0: + break; + /* available data to read */ + default: + ret = read(pipefd, buf, sizeof(buf)); + break; + } + } while (ret_s <= 0); close(pipefd); From 550064930e369fb3a322c3b28ffff8b4acf53532 Mon Sep 17 00:00:00 2001 From: Dimitris Economou Date: Sun, 6 Feb 2022 23:12:03 +0200 Subject: [PATCH 33/70] check zero bytes read from O_NDELAY socket --- clients/upssched.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/clients/upssched.c b/clients/upssched.c index 2c68fe10a3..d8c3a6e4c0 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -497,8 +497,11 @@ static int sock_read(conn_t *conn) if ((ret == -1) && (errno == EAGAIN)) return 0; - if (ret == 0) /* nothing to parse yet */ - continue; + /* O_NDELAY with zero bytes means nothing to read but + since read() follows a succesful select() with + ready file descriptor, ret shouldn't be 0. */ + if (ret == 0) + continue; /* some other problem */ return -1; /* error */ @@ -506,6 +509,9 @@ static int sock_read(conn_t *conn) ret = pconf_char(&conn->ctx, ch); + if (ret == 0) /* nothing to parse yet */ + continue; + if (ret == -1) { upslogx(LOG_NOTICE, "Parse error on sock: %s", conn->ctx.errmsg); From 131f685d6eecc22543e4ce46f68036af43255363 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 6 Feb 2022 22:31:37 +0100 Subject: [PATCH 34/70] docs/packager-guide.txt: mention ipmi and modbus drivers as separate packaging goals --- docs/packager-guide.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/packager-guide.txt b/docs/packager-guide.txt index d97b4fb06d..20b10bcc07 100644 --- a/docs/packager-guide.txt +++ b/docs/packager-guide.txt @@ -171,6 +171,8 @@ FIXME: make a dependency graph - <> - <> - <> +- <> +- <> - <> - <> @@ -261,6 +263,22 @@ nut-xml - Size: - Deps: +[[pkg-nut-ipmi]] +nut-ipmi +^^^^^^^ +- Desc: +- Files: +- Size: +- Deps: + +[[pkg-nut-modbus]] +nut-modbus +^^^^^^^ +- Desc: +- Files: +- Size: +- Deps: + [[pkg-nut-clients]] nut-clients ^^^^^^^^^^^ From 242c7696d7757baf6a46a792b5c08afb83fb4306 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 7 Feb 2022 12:34:25 +0100 Subject: [PATCH 35/70] gen-usbhid-subdriver.sh: suggest "fix_report_desc" in subdriver_t (follow-up to PR #1245) --- scripts/subdriver/gen-usbhid-subdriver.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/subdriver/gen-usbhid-subdriver.sh b/scripts/subdriver/gen-usbhid-subdriver.sh index 322153323d..956891eb1f 100755 --- a/scripts/subdriver/gen-usbhid-subdriver.sh +++ b/scripts/subdriver/gen-usbhid-subdriver.sh @@ -296,6 +296,7 @@ subdriver_t ${LDRIVER}_subdriver = { ${LDRIVER}_format_model, ${LDRIVER}_format_mfr, ${LDRIVER}_format_serial, + fix_report_desc, /* may optionally be customized, see cps-hid.c for example */ }; EOF From 6b0e6a7638eef0bd12ae06ee186c4b0bd244c5e2 Mon Sep 17 00:00:00 2001 From: Dimitris Economou Date: Mon, 7 Feb 2022 13:47:36 +0200 Subject: [PATCH 36/70] fix code alignemnt, casting sizeof with ssize_t --- clients/upssched.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/clients/upssched.c b/clients/upssched.c index d8c3a6e4c0..878959230a 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -702,7 +702,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) int i, pipefd; ssize_t ret; size_t enclen; - char buf[SMALLBUF], enc[SMALLBUF + 8]; + char buf[SMALLBUF], enc[SMALLBUF + 8]; int ret_s; struct timeval tv; fd_set fdread; @@ -750,7 +750,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) ret = write(pipefd, enc, sizeof(enc)); /* if we can't send the whole thing, loop back and try again */ - if ((ret < 1) || (ret != sizeof(enc))) { + if ((ret < 1) || (ret != (ssize_t )sizeof(enc))) { upslogx(LOG_ERR, "write failed, trying again"); close(pipefd); continue; @@ -758,27 +758,27 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) /* select on child's pipe fd */ do { - /* set timeout every time before call select() */ - tv.tv_sec = 1; - tv.tv_usec = 0; - - FD_ZERO(&fdread); - FD_SET(pipefd, &fdread); - - ret_s = select(pipefd + 1, &fdread, NULL, NULL, &tv); - switch(ret_s) { - /* select error */ - case -1: - upslogx(LOG_DEBUG, "parent select error: %s", strerror(errno)); - break; - /* nothing to read */ - case 0: - break; - /* available data to read */ - default: - ret = read(pipefd, buf, sizeof(buf)); - break; - } + /* set timeout every time before call select() */ + tv.tv_sec = 1; + tv.tv_usec = 0; + + FD_ZERO(&fdread); + FD_SET(pipefd, &fdread); + + ret_s = select(pipefd + 1, &fdread, NULL, NULL, &tv); + switch(ret_s) { + /* select error */ + case -1: + upslogx(LOG_DEBUG, "parent select error: %s", strerror(errno)); + break; + /* nothing to read */ + case 0: + break; + /* available data to read */ + default: + ret = read(pipefd, buf, sizeof(buf)); + break; + } } while (ret_s <= 0); close(pipefd); From cf2b82f7f217b72b47c005799f2b024ccc73b5ac Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 11:56:35 +0100 Subject: [PATCH 37/70] clients/upssched.c: whitespace and comment fixes --- clients/upssched.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/clients/upssched.c b/clients/upssched.c index 878959230a..daa1036db6 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -498,8 +498,8 @@ static int sock_read(conn_t *conn) return 0; /* O_NDELAY with zero bytes means nothing to read but - since read() follows a succesful select() with - ready file descriptor, ret shouldn't be 0. */ + * since read() follows a succesful select() with + * ready file descriptor, ret shouldn't be 0. */ if (ret == 0) continue; @@ -509,7 +509,7 @@ static int sock_read(conn_t *conn) ret = pconf_char(&conn->ctx, ch); - if (ret == 0) /* nothing to parse yet */ + if (ret == 0) /* nothing to parse yet */ continue; if (ret == -1) { @@ -703,10 +703,9 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) ssize_t ret; size_t enclen; char buf[SMALLBUF], enc[SMALLBUF + 8]; - int ret_s; - struct timeval tv; - fd_set fdread; - + int ret_s; + struct timeval tv; + fd_set fdread; /* insanity */ if (!arg1) @@ -722,6 +721,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) snprintf(enc, sizeof(enc), "%s\n", buf); + /* Sanity checks, for static analyzers to sleep well */ enclen = strlen(buf); if (enclen >= SSIZE_MAX) { /* Can't compare enclen to ret below */ @@ -735,7 +735,6 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) pipefd = check_parent(cmd, arg2); if (pipefd == PARENT_STARTED) { - /* loop back and try to connect now */ usleep(250000); continue; @@ -771,14 +770,16 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) case -1: upslogx(LOG_DEBUG, "parent select error: %s", strerror(errno)); break; + /* nothing to read */ case 0: break; + /* available data to read */ default: ret = read(pipefd, buf, sizeof(buf)); break; - } + } } while (ret_s <= 0); close(pipefd); @@ -795,7 +796,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) upslogx(LOG_ERR, "read confirmation got [%s]", buf); /* try again ... */ - } + } /* loop until MAX_TRIES if no success above */ fatalx(EXIT_FAILURE, "Unable to connect to daemon and unable to start daemon"); } From c585aacc97c635c7a249293f0a981f97bc3aa868 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 11:59:26 +0100 Subject: [PATCH 38/70] clients/upssched.c: sendcmd(): rectify enclen/buflen sanity checks and usage --- clients/upssched.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/clients/upssched.c b/clients/upssched.c index daa1036db6..f35fe09ec7 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -701,7 +701,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) { int i, pipefd; ssize_t ret; - size_t enclen; + size_t enclen, buflen; char buf[SMALLBUF], enc[SMALLBUF + 8]; int ret_s; struct timeval tv; @@ -722,8 +722,9 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) snprintf(enc, sizeof(enc), "%s\n", buf); /* Sanity checks, for static analyzers to sleep well */ - enclen = strlen(buf); - if (enclen >= SSIZE_MAX) { + enclen = strlen(enc); + buflen = strlen(buf); + if (enclen >= SSIZE_MAX || buflen >= SSIZE_MAX) { /* Can't compare enclen to ret below */ fatalx(EXIT_FAILURE, "Unable to connect to daemon: buffered message too large"); } @@ -746,10 +747,10 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) /* we're connected now */ - ret = write(pipefd, enc, sizeof(enc)); + ret = write(pipefd, enc, enclen); /* if we can't send the whole thing, loop back and try again */ - if ((ret < 1) || (ret != (ssize_t )sizeof(enc))) { + if ((ret < 1) || (ret != (ssize_t)enclen)) { upslogx(LOG_ERR, "write failed, trying again"); close(pipefd); continue; From d12fd47864b3f984cab874c9f6b68326d0ee1041 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 12:09:29 +0100 Subject: [PATCH 39/70] configure.ac: move "--with-drivers=name[,name...]" handling to before we check for third-party dependencies --- configure.ac | 59 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index 6938af14a9..e5fa3e7ea6 100644 --- a/configure.ac +++ b/configure.ac @@ -487,7 +487,34 @@ dnl note that options with further investigation methods are listed dnl a bit below to be grouped with their additional with/enable help. NUT_ARG_WITH([dev], [build and install the development files], [no]) -NUT_ARG_WITH([serial], [build and install serial drivers], [yes]) + +dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs, +dnl so the help string depends on the version used +AC_MSG_CHECKING(which drivers to build) +AC_ARG_WITH(drivers, + AS_HELP_STRING([m4_version_prereq(2.62, + [@<:@--with-drivers=driver@<:@,driver@:>@@:>@], + [[[[--with-drivers=driver@<:@,driver@:>@]]]])], + [Only build specific drivers (all)]), +[ + case "${withval}" in + yes|no) + AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt) + ;; + *) + DRIVER_BUILD_LIST="`echo ${withval} | sed "s/,/ /g"`" + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + ;; + esac +], [ + DRIVER_BUILD_LIST="all" + AC_MSG_RESULT(all available) +]) +AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all") + +if test "${DRIVER_BUILD_LIST}" != "all"; then + NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}]) +fi dnl The NUT legacy option was --with-doc; however to simplify configuration dnl in some common packaging frameworks, we also allow --with-docs as @@ -510,6 +537,8 @@ dnl To help find warning/error details in a wall of text, see --enable-Wcolor ha dnl ---------------------------------------------------------------------- dnl Check for presence and compiler flags of various libraries +NUT_ARG_WITH([serial], [build and install serial drivers], [yes]) + dnl These checks are performed unconditionally, even if the corresponding dnl --with-* options are not given. This is because we cannot predict dnl what will be in the --with-drivers argument. @@ -1477,34 +1506,6 @@ AC_ARG_WITH(logfacility, AC_DEFINE_UNQUOTED(LOG_FACILITY, ${LOGFACILITY}, [Desired syslog facility - see syslog(3)]) AC_MSG_RESULT(${LOGFACILITY}) -dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs, -dnl so the help string depends on the version used -AC_MSG_CHECKING(which drivers to build) -AC_ARG_WITH(drivers, - AS_HELP_STRING([m4_version_prereq(2.62, - [@<:@--with-drivers=driver@<:@,driver@:>@@:>@], - [[[[--with-drivers=driver@<:@,driver@:>@]]]])], - [Only build specific drivers (all)]), -[ - case "${withval}" in - yes|no) - AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt) - ;; - *) - DRIVER_BUILD_LIST=`echo ${withval} | sed "s/,/ /g"` - AC_MSG_RESULT(${DRIVER_BUILD_LIST}) - ;; - esac -], [ - DRIVER_BUILD_LIST="all" - AC_MSG_RESULT(all available) -]) -AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all") - -if test "${DRIVER_BUILD_LIST}" != "all"; then - NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}]) -fi - AC_MSG_CHECKING(which driver man pages to install) if test "${WITH_MANS}" = "yes"; then if test "${DRIVER_BUILD_LIST}" = "all"; then From 59b0c9e411d13c1448616a67994f748496bf6879 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 12:47:54 +0100 Subject: [PATCH 40/70] drivers/Makefile.am: parameterize POWERMAN_DRIVERLIST and IPMI_DRIVERLIST like others --- drivers/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/Makefile.am b/drivers/Makefile.am index 77d5258bf5..16900cbb46 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -52,6 +52,8 @@ NEONXML_DRIVERLIST = netxml-ups MACOSX_DRIVERLIST = macosx-ups MODBUS_DRIVERLIST = phoenixcontact_modbus generic_modbus huawei-ups2000 LINUX_I2C_DRIVERLIST = asem pijuice +POWERMAN_DRIVERLIST = powerman-pdu +IPMI_DRIVERLIST = nut-ipmipsu # distribute all drivers, even ones that are not built by default EXTRA_PROGRAMS = $(SERIAL_DRIVERLIST) $(USB_DRIVERLIST) $(SERIAL_USB_DRIVERLIST) @@ -80,10 +82,10 @@ if WITH_NEON driverexec_PROGRAMS += $(NEONXML_DRIVERLIST) endif if WITH_LIBPOWERMAN - driverexec_PROGRAMS += powerman-pdu + driverexec_PROGRAMS += $(POWERMAN_DRIVERLIST) endif if WITH_IPMI - driverexec_PROGRAMS += nut-ipmipsu + driverexec_PROGRAMS += $(IPMI_DRIVERLIST) endif if WITH_MACOSX driverexec_PROGRAMS += $(MACOSX_DRIVERLIST) From de56c3b21cebf06173b7e1200966b83076269db3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 14:42:15 +0100 Subject: [PATCH 41/70] configure.ac: move --with-drivers=... handling to before --with-all, and consult drivers/Makefile.am for list names to require certain dependencies --- configure.ac | 214 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 186 insertions(+), 28 deletions(-) diff --git a/configure.ac b/configure.ac index e5fa3e7ea6..a918ea681a 100644 --- a/configure.ac +++ b/configure.ac @@ -451,6 +451,192 @@ NUT_CHECK_PYTHON NUT_CHECK_PYTHON2 NUT_CHECK_PYTHON3 +dnl ---------------------------------------------------------------------- +dnl check for --with-drivers=all (or --with-drivers=name[,name...]) flag + +dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs +dnl (square brackets), so the help string depends on the version used +AC_MSG_CHECKING(which drivers to build) +AC_ARG_WITH(drivers, + AS_HELP_STRING([m4_version_prereq(2.62, + [@<:@--with-drivers=driver@<:@,driver@:>@@:>@], + [[[[--with-drivers=driver@<:@,driver@:>@]]]])], + [Only build specific drivers (all)]), +[ + case "${withval}" in + yes|no|'') + AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt) + ;; + all) + dnl Explicit request to build all drivers (unless specified), or fail + DRIVER_BUILD_LIST="all" + if test -z "${with_serial}"; then with_serial="yes"; fi + if test -z "${with_usb}"; then with_usb="yes"; fi + if test -z "${with_snmp}"; then with_snmp="yes"; fi + if test -z "${with_neon}"; then with_neon="yes"; fi + if test -z "${with_powerman}"; then with_powerman="yes"; fi + if test -z "${with_modbus}"; then with_modbus="yes"; fi + if test -z "${with_ipmi}"; then with_ipmi="yes"; fi + if test -z "${with_linux_i2c}"; then with_linux_i2c="yes"; fi + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + ;; + auto) + dnl Explicit request to build all drivers that we can + DRIVER_BUILD_LIST="all" + if test -z "${with_serial}"; then with_serial="${withval}"; fi + if test -z "${with_usb}"; then with_usb="${withval}"; fi + if test -z "${with_snmp}"; then with_snmp="${withval}"; fi + if test -z "${with_neon}"; then with_neon="${withval}"; fi + if test -z "${with_powerman}"; then with_powerman="${withval}"; fi + if test -z "${with_modbus}"; then with_modbus="${withval}"; fi + if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi + if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + ;; + *) + DRIVER_BUILD_LIST="`echo ${withval} | sed 's/,/ /g'`" + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + + AS_IF([test -n "$DRIVER_BUILD_LIST"], + [dnl DRVLIST is occasionally synced with drivers/Makefile.am + dnl NOTE: Currently "USB_DRIVERLIST" is not used standalone: + DRVLIST_NAMES=" + SERIAL_DRIVERLIST USB_LIBUSB_DRIVERLIST SERIAL_USB_DRIVERLIST + SNMP_DRIVERLIST NEONXML_DRIVERLIST + MACOSX_DRIVERLIST MODBUS_DRIVERLIST LINUX_I2C_DRIVERLIST + POWERMAN_DRIVERLIST IPMI_DRIVERLIST" + + get_drvlist() ( + dnl Note escaped brackets - "against" m4 parser + m4_version_prereq(2.62, + [LB="@<:@"; RB="@:>@"], + [LB="[["; RB="]]"] + ) + SPACE="`printf "$LB"' \t'"$RB"`" + SPACES="${SPACE}*" + sed -e "s/${SPACES}""$LB"'+'"$RB"'*='"${SPACES}/=/" \ + -e "s/^${SPACES}//" < drivers/Makefile.am \ + | { + C=false; V=false + while read LINE ; do + case "$LINE" in + *'\') C=true; if $V ; then echo "$LINE" ; fi ;; + *) C=false; V=false ;; + esac + case "$LINE" in + "$1"=*) + echo "$LINE" | sed -e 's,^'"$LB"'^='"$RB"'*=,,' -e 's,\$,,' + V=$C + ;; + esac + done + } | tr '\n' ' ' | sed -e "s,${SPACE}${SPACES}, ," -e "s,${SPACES}\$,," + ) + + for DRVLIST_NAME in $DRVLIST_NAMES; do + OUT="`get_drvlist "$DRVLIST_NAME"`" \ + && test -n "$OUT" || OUT="" + eval $DRVLIST_NAME="\$OUT" + AC_MSG_NOTICE([Will check custom driver selection against $DRVLIST_NAME="$OUT"]) + done + + dnl Note: do not quote the expansion below to keep it multi-token: + for DRV in $DRIVER_BUILD_LIST ; do + + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([= Checking DRV="$DRV"]) + for DRVLIST_NAME in $DRVLIST_NAMES; do + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([== Checking DRVLIST_NAME="$DRVLIST_NAME"]) + eval DRVLIST="\${$DRVLIST_NAME}" + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([== Contents DRVLIST="$DRVLIST"]) + + for DN in $DRVLIST ; do + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([=== Checking DN="$DN"]) + AS_IF([test x"$DN" = x"$DRV"], [ + AS_CASE(["$DRVLIST_NAME"], + + [SERIAL_DRIVERLIST], [ + AS_IF([test -z "${with_serial}"], + [AC_MSG_NOTICE([Requiring --with-serial=yes for driver "$DRV"]) + with_serial=yes] + )], + [USB_LIBUSB_DRIVERLIST], [ + AS_IF([test -z "${with_usb}"], + [AC_MSG_NOTICE([Requiring --with-usb=yes for driver "$DRV"]) + with_usb=yes] + )], + [SERIAL_USB_DRIVERLIST], [ + dnl e.g. nutdrv_qx that can do both + AS_IF([test -z "${with_usb}"], + [AC_MSG_NOTICE([Requiring --with-usb=yes for driver "$DRV"]) + with_usb=yes] + ) + AS_IF([test -z "${with_serial}"], + [AC_MSG_NOTICE([Requiring --with-serial=yes for driver "$DRV"]) + with_serial=yes] + )], + [SNMP_DRIVERLIST], [ + AS_IF([test -z "${with_snmp}"], + [AC_MSG_NOTICE([Requiring --with-snmp=yes for driver "$DRV"]) + with_snmp=yes] + )], + [NEONXML_DRIVERLIST], [ + AS_IF([test -z "${with_neon}"], + [AC_MSG_NOTICE([Requiring --with-neon=yes for driver "$DRV"]) + with_neon=yes] + )], + [MACOSX_DRIVERLIST], [ + dnl NOTE: This one is a bit special, + dnl just one certain driver so far + AS_IF([test -z "${with_macosx_ups}"], + [AC_MSG_NOTICE([Requiring --with-macosx-ups=yes for driver "$DRV"]) + with_macosx_ups=yes] + )], + [MODBUS_DRIVERLIST], [ + AS_IF([test -z "${with_modbus}"], + [AC_MSG_NOTICE([Requiring --with-modbus=yes for driver "$DRV"]) + with_modbus=yes] + )], + [LINUX_I2C_DRIVERLIST], [ + AS_IF([test -z "${with_linux_i2c}"], + [AC_MSG_NOTICE([Requiring --with-linux-i2c=yes for driver "$DRV"]) + with_linux_i2c=yes] + )], + [POWERMAN_DRIVERLIST], [ + AS_IF([test -z "${with_powerman}"], + [AC_MSG_NOTICE([Requiring --with-powerman=yes for driver "$DRV"]) + with_powerman=yes] + )], + [IPMI_DRIVERLIST], [ + AS_IF([test -z "${with_ipmi}"], + [AC_MSG_NOTICE([Requiring --with-ipmi=yes for driver "$DRV"]) + with_ipmi=yes] + )], + + [AC_MSG_WARN([Unhandled DRVLIST_NAME=$DRVLIST_NAME])] + ) + break + dnl Break once, maybe a driver hits several categories + ]) + done + done + + done + ]) + + ;; + esac +], [ + dnl Implicit request to build whatever is enabled; + dnl do not force --with-all here: + DRIVER_BUILD_LIST="all" + AC_MSG_RESULT(all available) +]) +AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all") + +if test "${DRIVER_BUILD_LIST}" != "all"; then + NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}]) +fi + dnl ---------------------------------------------------------------------- dnl check for --with-all (or --without-all, or --with-all=auto) flag @@ -488,34 +674,6 @@ dnl a bit below to be grouped with their additional with/enable help. NUT_ARG_WITH([dev], [build and install the development files], [no]) -dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs, -dnl so the help string depends on the version used -AC_MSG_CHECKING(which drivers to build) -AC_ARG_WITH(drivers, - AS_HELP_STRING([m4_version_prereq(2.62, - [@<:@--with-drivers=driver@<:@,driver@:>@@:>@], - [[[[--with-drivers=driver@<:@,driver@:>@]]]])], - [Only build specific drivers (all)]), -[ - case "${withval}" in - yes|no) - AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt) - ;; - *) - DRIVER_BUILD_LIST="`echo ${withval} | sed "s/,/ /g"`" - AC_MSG_RESULT(${DRIVER_BUILD_LIST}) - ;; - esac -], [ - DRIVER_BUILD_LIST="all" - AC_MSG_RESULT(all available) -]) -AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all") - -if test "${DRIVER_BUILD_LIST}" != "all"; then - NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}]) -fi - dnl The NUT legacy option was --with-doc; however to simplify configuration dnl in some common packaging frameworks, we also allow --with-docs as dnl a second-class citizen (if both are set, the old option name wins). From 827bd330c30d2fe641ae713cd4947daefaadb3cc Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 15:04:35 +0100 Subject: [PATCH 42/70] configure.ac: improve handling of platform-dependent (linux-i2c, macosx) drivers - do not default to require them everywhere --- configure.ac | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a918ea681a..de87d1e188 100644 --- a/configure.ac +++ b/configure.ac @@ -477,7 +477,21 @@ AC_ARG_WITH(drivers, if test -z "${with_powerman}"; then with_powerman="yes"; fi if test -z "${with_modbus}"; then with_modbus="yes"; fi if test -z "${with_ipmi}"; then with_ipmi="yes"; fi - if test -z "${with_linux_i2c}"; then with_linux_i2c="yes"; fi + + dnl Platform-dependent snowflakes that are required or auto: + if test -z "${with_linux_i2c}"; then + case ${target_os} in + linux*) with_linux_i2c="yes";; + *) with_linux_i2c="auto";; + esac + fi + if test -z "${with_macosx_ups}"; then + if test -d /System/Library/Frameworks/IOKit.framework/ ; then + with_macosx_ups="yes" + else + with_macosx_ups="auto" + fi + fi AC_MSG_RESULT(${DRIVER_BUILD_LIST}) ;; auto) @@ -491,6 +505,7 @@ AC_ARG_WITH(drivers, if test -z "${with_modbus}"; then with_modbus="${withval}"; fi if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + if test -z "${with_macosx_ups}"; then with_macosx_ups="${withval}"; fi AC_MSG_RESULT(${DRIVER_BUILD_LIST}) ;; *) @@ -647,17 +662,36 @@ AC_ARG_WITH(all, if test -n "${withval}"; then dnl Note: we allow "no" as a positive value, because dnl this is what the user expects from --without-all + dnl Note: these settings do not touch generation of + dnl "--with-docs=...", that is handled separately if test -z "${with_serial}"; then with_serial="${withval}"; fi if test -z "${with_usb}"; then with_usb="${withval}"; fi if test -z "${with_snmp}"; then with_snmp="${withval}"; fi if test -z "${with_neon}"; then with_neon="${withval}"; fi if test -z "${with_powerman}"; then with_powerman="${withval}"; fi if test -z "${with_modbus}"; then with_modbus="${withval}"; fi + if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi + + dnl Platform-dependent snowflakes that are required or auto: + if test -z "${with_linux_i2c}"; then + with_linux_i2c="${withval}" + case ${target_os} in + linux*) ;; + *) test x"${withval}" = xno || with_linux_i2c="auto" ;; + esac + fi + if test -z "${with_macosx_ups}"; then + with_macosx_ups="${withval}" + if ! test -d /System/Library/Frameworks/IOKit.framework/ ; then + test x"${withval}" = xno || with_macosx_ups="auto" + fi + fi + + dnl These are not driver families, but other features: if test -z "${with_cgi}"; then with_cgi="${withval}"; fi if test -z "${with_dev}"; then with_dev="${withval}"; fi if test -z "${with_avahi}"; then with_avahi="${withval}"; fi - if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi - if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + AC_MSG_RESULT("${withval}") else AC_MSG_RESULT(not given) @@ -952,6 +986,9 @@ if test "${nut_with_macosx_ups}" != no; then if test -d /System/Library/Frameworks/IOKit.framework/ ; then nut_with_macosx_ups="yes" else + if test "${nut_with_macosx_ups}" = yes; then + AC_MSG_ERROR([macosx-ups was required but can not be fulfilled for this build: not MacOS]) + fi nut_with_macosx_ups="no" fi fi @@ -1005,6 +1042,9 @@ if test "${nut_with_linux_i2c}" != no; then ]) ;; * ) + if test "${nut_with_linux_i2c}" = yes; then + AC_MSG_ERROR([i2c was required but can not be fulfilled for this build: not linux]) + fi nut_with_linux_i2c="no" ;; esac From 88866837d3cd18b12c13aa29c99a0e55b9261138 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 8 Feb 2022 15:13:28 +0100 Subject: [PATCH 43/70] configure.ac: error out for unhandled --with-drivers=xxx names --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index de87d1e188..25b08a32e4 100644 --- a/configure.ac +++ b/configure.ac @@ -558,6 +558,7 @@ AC_ARG_WITH(drivers, dnl Note: do not quote the expansion below to keep it multi-token: for DRV in $DRIVER_BUILD_LIST ; do + DRV_HITS="" dnl #DEVEL-DEBUG# AC_MSG_NOTICE([= Checking DRV="$DRV"]) for DRVLIST_NAME in $DRVLIST_NAMES; do dnl #DEVEL-DEBUG# AC_MSG_NOTICE([== Checking DRVLIST_NAME="$DRVLIST_NAME"]) @@ -567,6 +568,7 @@ AC_ARG_WITH(drivers, for DN in $DRVLIST ; do dnl #DEVEL-DEBUG# AC_MSG_NOTICE([=== Checking DN="$DN"]) AS_IF([test x"$DN" = x"$DRV"], [ + DRV_HITS="$DRV_HITS $DRVLIST_NAME" AS_CASE(["$DRVLIST_NAME"], [SERIAL_DRIVERLIST], [ @@ -633,6 +635,8 @@ AC_ARG_WITH(drivers, dnl Break once, maybe a driver hits several categories ]) done + AS_IF([test -z "${DRV_HITS}"], + [AC_MSG_ERROR([Requested driver '$DRV' is not defined in drivers/Makefile.am (or configure.ac has a bug/lag detecting driver lists)])]) done done From 767de03fe9fa8746ef21c576a9f3cb5992f92540 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 09:44:15 +0100 Subject: [PATCH 44/70] drivers/everups.c: whitespace fixes; clarify this is a serial driver (as opposed to ever-hid.c for USB devices) --- drivers/everups.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/everups.c b/drivers/everups.c index 2338e4dc78..63ccea879d 100644 --- a/drivers/everups.c +++ b/drivers/everups.c @@ -1,4 +1,4 @@ -/* everups.c - support for Ever UPS models +/* everups.c - support for Ever UPS models (serial) Copyright (C) 2001 Bartek Szady @@ -20,7 +20,7 @@ #include "main.h" #include "serial.h" -#define DRIVER_NAME "Ever UPS driver" +#define DRIVER_NAME "Ever UPS driver (serial)" #define DRIVER_VERSION "0.04" /* driver description structure */ @@ -64,9 +64,9 @@ static int InitUpsType(void) static const char *GetTypeUpsName(void) { - switch(upstype) - { - case 67: return "NET 500-DPC"; + switch(upstype) + { + case 67: return "NET 500-DPC"; case 68: return "NET 700-DPC"; case 69: return "NET 1000-DPC"; case 70: return "NET 1400-DPC"; From afa5feea0c343633ce62d1cc7b18a244ac237ec1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 09:55:05 +0100 Subject: [PATCH 45/70] drivers/ever-hid.c: adjust to upstream changes: config.h goes first, PID/VID are unsigned, got a fix_report_desc() default --- drivers/ever-hid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 247c8c52b9..2c385234f3 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -24,6 +24,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be first */ + #include "usbhid-ups.h" #include "ever-hid.h" #include "main.h" /* for getval() */ @@ -44,9 +46,8 @@ static usb_device_id_t ever_usb_device_table[] = { { USB_DEVICE(STMICRO_VENDORID, 0xa113), NULL }, { USB_DEVICE(EVER_VENDORID, 0xffff), NULL}, - /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; /* --------------------------------------------------------------- */ @@ -649,4 +650,5 @@ subdriver_t ever_subdriver = { ever_format_model, ever_format_mfr, ever_format_serial, + fix_report_desc, }; From bfcf9c24f6316221a64c9006426074c73662896e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 09:55:35 +0100 Subject: [PATCH 46/70] drivers/ever-hid.c: wrap some long lines for readability --- drivers/ever-hid.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 2c385234f3..bcaf2fcce3 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -59,7 +59,9 @@ static const char *ever_format_hardware_fun(double value) /*TODO - add exception handling for v1.0b0B */ const char* hard_rev[27] = {"0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; static char model[10]; - snprintf(model, sizeof(model), "rev.%sv%02d", (&hard_rev[ ((unsigned int)value & 0xFF00)>>8 ])[0], (unsigned int)value & 0xFF ); + snprintf(model, sizeof(model), "rev.%sv%02d", + (&hard_rev[ ((unsigned int)value & 0xFF00)>>8 ])[0], + (unsigned int)value & 0xFF ); return model; } @@ -67,7 +69,10 @@ static const char *ever_format_version_fun(double value) { /*upsdebugx(1, "UPS ups_firmware_conversion_fun VALUE: %d", (long)value ); */ static char model[10]; - snprintf(model, sizeof(model), "v%X.%Xb%02d", ((unsigned int)value & 0xF000)>>12, ((unsigned int)value & 0xF00)>>8, ((int)value & 0xFF) ); + snprintf(model, sizeof(model), "v%X.%Xb%02d", + ((unsigned int)value & 0xF000)>>12, + ((unsigned int)value & 0xF00)>>8, + ((int)value & 0xFF) ); return model; } @@ -119,7 +124,8 @@ static const char *ever_ip_address_fun(double value) /*skip first element which is a report id */ for (i = 1; i < len; i++) { - n = snprintfcat(line, sizeof(line), n ? ".%d" : "%d", ((unsigned char *)buf)[i]); + n = snprintfcat(line, sizeof(line), n ? ".%d" : "%d", + ((unsigned char *)buf)[i]); } return line; From ac6a6e1b753b5d95a2ed2b4e0fa41497f06442be Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:29:20 +0100 Subject: [PATCH 47/70] drivers/ever-hid.c: fix trailing whitespaces --- drivers/ever-hid.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index bcaf2fcce3..4b0f621ce1 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -57,7 +57,7 @@ static usb_device_id_t ever_usb_device_table[] = { static const char *ever_format_hardware_fun(double value) { /*TODO - add exception handling for v1.0b0B */ - const char* hard_rev[27] = {"0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; + const char* hard_rev[27] = {"0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; static char model[10]; snprintf(model, sizeof(model), "rev.%sv%02d", (&hard_rev[ ((unsigned int)value & 0xFF00)>>8 ])[0], @@ -102,7 +102,7 @@ static const char *ever_ip_address_fun(double value) static int report_counter = 1; int report_id = 211; - if(report_counter == 1) + if(report_counter == 1) report_id = 211; /* notification dest ip */ else if(report_counter == 2) report_id = 230; /* ip address */ @@ -111,7 +111,7 @@ static const char *ever_ip_address_fun(double value) else if(report_counter == 4) report_id = 232; /* default gateway */ - report_counter== 4 ? report_counter=1 : report_counter++; + report_counter== 4 ? report_counter=1 : report_counter++; int len = reportbuf->len[report_id]; const void *buf = reportbuf->data[report_id]; @@ -122,7 +122,7 @@ static const char *ever_ip_address_fun(double value) int i; /* number of bytes output from buffer */ /*skip first element which is a report id */ - for (i = 1; i < len; i++) + for (i = 1; i < len; i++) { n = snprintfcat(line, sizeof(line), n ? ".%d" : "%d", ((unsigned char *)buf)[i]); @@ -145,7 +145,7 @@ static const char *ever_packets_fun(double value) else if(report_counter == 4 ) report_id = 218; - report_counter== 4 ? report_counter=1 : report_counter++; + report_counter== 4 ? report_counter=1 : report_counter++; int len = reportbuf->len[report_id]; const unsigned char *buf = reportbuf->data[report_id]; @@ -178,7 +178,6 @@ static const char* ever_workmode_fun(double value) /*skip first element which is a report id */ snprintfcat(line, sizeof(line), "%d", buf[1]); - int workmode = atoi(line); @@ -201,9 +200,8 @@ static const char* ever_workmode_fun(double value) return "EMERGENCY"; default: return "UNKNOWN"; - } - + } static const char* ever_messages_fun(double value) @@ -235,13 +233,13 @@ static const char* ever_messages_fun(double value) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BOOST_BLOCKED"); if(messages & 0x20) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "BUCK_BLOCKED"); - if(messages & 0x40) + if(messages & 0x40) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "CHARGING"); - if(messages & 0x80) + if(messages & 0x80) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "FAN_ON"); - if(messages & 0x100) + if(messages & 0x100) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "EPO_BLOCKED"); - if(messages & 0x200) + if(messages & 0x200) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "NEED_REPLACMENT"); if(messages & 0x400 || messages & 0x800) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "OVERHEAT"); @@ -277,11 +275,11 @@ static const char* ever_alarms_fun(double value) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "EPO"); if(alarms & 0x20) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "INERNAL_ERROR"); - if(alarms & 0x40) + if(alarms & 0x40) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "REVERSE_POWER_SUPPLY"); - if(alarms & 0x80) + if(alarms & 0x80) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "NO_INETERNAL_COMM"); - if(alarms & 0x100) + if(alarms & 0x100) n = snprintfcat(line, sizeof(line), n ? " %s" : "%s", "CRITICAL_BATT_VOLTAGE"); return line; @@ -300,7 +298,7 @@ static const char* ever_on_off_fun(double value) int workmode = atoi(line); - if(workmode != 0x04 && workmode != 0x08) + if(workmode != 0x04 && workmode != 0x08) return "off"; return "!off"; @@ -601,8 +599,8 @@ static hid_info_t ever_hid2nut[] = { /* ever workmodes, messages & alarms */ { "status.workmode", 0, 0, "UPS.EVER1.EVER97.EVER98", NULL, "%s", 0, ever_workmode }, - { "status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, - { "status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, + { "status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, + { "status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, /* instant commands */ { "load.off.delay", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, From ad95cbe3fe23c9eb2039b85821e0949b55ee8bce Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:30:13 +0100 Subject: [PATCH 48/70] drivers/ever-hid.c: fix switch/case whitespaces --- drivers/ever-hid.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 4b0f621ce1..66c38394d2 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -186,18 +186,25 @@ static const char* ever_workmode_fun(double value) { case 1: return "UNKNOWN"; + case 2: return "STOP"; + case 4: return "ONLINE"; + case 8: return "ONBATTERY"; + case 16: return "WATCH"; + case 32: return "WAITING"; + case 64: return "EMERGENCY"; + default: return "UNKNOWN"; } @@ -629,20 +636,20 @@ static int ever_claim(HIDDevice_t *hd) switch (status) { - case POSSIBLY_SUPPORTED: - /* by default, reject, unless the productid option is given */ - if (getval("productid")) { + case POSSIBLY_SUPPORTED: + /* by default, reject, unless the productid option is given */ + if (getval("productid")) { + return 1; + } + possibly_supported("Ever", hd); + return 0; + + case SUPPORTED: return 1; - } - possibly_supported("Ever", hd); - return 0; - case SUPPORTED: - return 1; - - case NOT_SUPPORTED: - default: - return 0; + case NOT_SUPPORTED: + default: + return 0; } } From 98fce188bbc32429af13faba6fe8f2d0e9b85e14 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:29:53 +0100 Subject: [PATCH 49/70] drivers/ever-hid.c: ever_alarms_fun(), ever_workmode_fun(): define "workmode" on top of function --- drivers/ever-hid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 66c38394d2..4b2696bc4b 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -171,6 +171,7 @@ static const char *ever_packets_fun(double value) static const char* ever_workmode_fun(double value) { int workmode_report_id = 74; + int workmode = -1; const unsigned char *buf = reportbuf->data[workmode_report_id]; static char line[100]; @@ -179,8 +180,7 @@ static const char* ever_workmode_fun(double value) /*skip first element which is a report id */ snprintfcat(line, sizeof(line), "%d", buf[1]); - - int workmode = atoi(line); + workmode = atoi(line); switch(workmode) { @@ -295,6 +295,7 @@ static const char* ever_alarms_fun(double value) static const char* ever_on_off_fun(double value) { int workmode_report_id = 74; + int workmode = -1; const unsigned char *buf = reportbuf->data[workmode_report_id]; static char line[100]; @@ -303,7 +304,7 @@ static const char* ever_on_off_fun(double value) /*skip first element which is a report id */ snprintfcat(line, sizeof(line), "%d", buf[1]); - int workmode = atoi(line); + workmode = atoi(line); if(workmode != 0x04 && workmode != 0x08) return "off"; From da7bea9fe594f498eab511b608db322ef7b3fd32 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:30:38 +0100 Subject: [PATCH 50/70] drivers/ever-hid.c: use complete struct initializers for info_lkp_t tables; use sentinels; mark static --- drivers/ever-hid.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 4b2696bc4b..4462ca32ae 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -312,40 +312,49 @@ static const char* ever_on_off_fun(double value) return "!off"; } -info_lkp_t ever_format_hardware[] = { - { 0, NULL, ever_format_hardware_fun} +static info_lkp_t ever_format_hardware[] = { + { 0, NULL, ever_format_hardware_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_format_version[] = { - { 0, NULL, ever_format_version_fun} +static info_lkp_t ever_format_version[] = { + { 0, NULL, ever_format_version_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_mac_address[] = { - { 0, NULL, ever_mac_address_fun} +static info_lkp_t ever_mac_address[] = { + { 0, NULL, ever_mac_address_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_ip_address[] = { - { 0, NULL, ever_ip_address_fun} +static info_lkp_t ever_ip_address[] = { + { 0, NULL, ever_ip_address_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_packets[] = { - { 0, NULL, ever_packets_fun} +static info_lkp_t ever_packets[] = { + { 0, NULL, ever_packets_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_workmode[] = { - { 0, NULL, ever_workmode_fun} +static info_lkp_t ever_workmode[] = { + { 0, NULL, ever_workmode_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_messages[] = { - { 0, NULL, ever_messages_fun} +static info_lkp_t ever_messages[] = { + { 0, NULL, ever_messages_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_alarms[] = { - { 0, NULL, ever_alarms_fun} +static info_lkp_t ever_alarms[] = { + { 0, NULL, ever_alarms_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t ever_on_off_info[] = { - { 0, NULL, ever_on_off_fun} +static info_lkp_t ever_on_off_info[] = { + { 0, NULL, ever_on_off_fun, NULL }, + { 0, NULL, NULL, NULL } }; From 213b6dab721e97705fc31d867b4a3cd1d74b81ca Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:35:28 +0100 Subject: [PATCH 51/70] drivers/ever-hid.c: mark NUT_UNUSED_VARIABLE(double value) where appropriate --- drivers/ever-hid.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 4462ca32ae..d1c4c867be 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -78,6 +78,7 @@ static const char *ever_format_version_fun(double value) static const char *ever_mac_address_fun(double value) { + NUT_UNUSED_VARIABLE(value); int mac_adress_report_id = 210; int len = reportbuf->len[mac_adress_report_id]; @@ -99,6 +100,8 @@ static const char *ever_mac_address_fun(double value) static const char *ever_ip_address_fun(double value) { + NUT_UNUSED_VARIABLE(value); + static int report_counter = 1; int report_id = 211; @@ -133,6 +136,8 @@ static const char *ever_ip_address_fun(double value) static const char *ever_packets_fun(double value) { + NUT_UNUSED_VARIABLE(value); + static int report_counter = 1; int report_id = 215; @@ -170,6 +175,8 @@ static const char *ever_packets_fun(double value) static const char* ever_workmode_fun(double value) { + NUT_UNUSED_VARIABLE(value); + int workmode_report_id = 74; int workmode = -1; const unsigned char *buf = reportbuf->data[workmode_report_id]; @@ -213,6 +220,8 @@ static const char* ever_workmode_fun(double value) static const char* ever_messages_fun(double value) { + NUT_UNUSED_VARIABLE(value); + int messages_report_id = 75; const unsigned char *buf = reportbuf->data[messages_report_id]; @@ -259,6 +268,8 @@ static const char* ever_messages_fun(double value) static const char* ever_alarms_fun(double value) { + NUT_UNUSED_VARIABLE(value); + int alarms_report_id = 76; const unsigned char *buf = reportbuf->data[alarms_report_id]; @@ -294,6 +305,8 @@ static const char* ever_alarms_fun(double value) static const char* ever_on_off_fun(double value) { + NUT_UNUSED_VARIABLE(value); + int workmode_report_id = 74; int workmode = -1; const unsigned char *buf = reportbuf->data[workmode_report_id]; From 48f2af1c38bda98a5d35f0c4c1e8ccc3ef43b286 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:35:39 +0100 Subject: [PATCH 52/70] drivers/ever-hid.c: print unsigned int as %u --- drivers/ever-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index d1c4c867be..98b2670119 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -59,7 +59,7 @@ static const char *ever_format_hardware_fun(double value) /*TODO - add exception handling for v1.0b0B */ const char* hard_rev[27] = {"0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; static char model[10]; - snprintf(model, sizeof(model), "rev.%sv%02d", + snprintf(model, sizeof(model), "rev.%sv%02u", (&hard_rev[ ((unsigned int)value & 0xFF00)>>8 ])[0], (unsigned int)value & 0xFF ); return model; From bd598febd7124507794992bc274201bdf23d117f Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 10:39:37 +0100 Subject: [PATCH 53/70] drivers/ever-hid.{c,h}: update (C) heading --- drivers/ever-hid.c | 2 ++ drivers/ever-hid.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index 98b2670119..c7f0611071 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -5,6 +5,8 @@ * 2005 - 2006 Peter Selinger * 2008 - 2009 Arjen de Korte * 2013 Charles Lepple + * 2017 EVER Power Systems [https://ever.eu/] + * 2020 - 2022 Jim Klimov * * Note: this subdriver was initially generated as a "stub" by the * gen-usbhid-subdriver script. It must be customized. diff --git a/drivers/ever-hid.h b/drivers/ever-hid.h index 2643580799..bf47bc1997 100644 --- a/drivers/ever-hid.h +++ b/drivers/ever-hid.h @@ -4,6 +4,8 @@ * 2003 - 2009 Arnaud Quette * 2005 - 2006 Peter Selinger * 2008 - 2009 Arjen de Korte + * 2017 EVER Power Systems [https://ever.eu/] + * 2020 - 2022 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 From a7e4b0bb2d216abb03d9fe85629e68129d5efdd0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 11:13:52 +0100 Subject: [PATCH 54/70] drivers/ever-hid.c: tag non-standard NUT variable/command names as "experimental.*" to help identify lacking mappings and rename some into standard data points --- drivers/ever-hid.c | 304 +++++++++++++++++++++++++++++---------------- 1 file changed, 200 insertions(+), 104 deletions(-) diff --git a/drivers/ever-hid.c b/drivers/ever-hid.c index c7f0611071..866fff96c3 100644 --- a/drivers/ever-hid.c +++ b/drivers/ever-hid.c @@ -495,123 +495,213 @@ static usage_tables_t ever_utab[] = { static hid_info_t ever_hid2nut[] = { - { "battery.batteryid", 0, 0, "UPS.BatterySystem.Battery.BatteryID", NULL, "%.0f", 0, NULL }, - { "battery.systemid", 0, 0, "UPS.BatterySystem.BatterySystemID", NULL, "%.0f", 0, NULL }, - { "battery.chargerid", 0, 0, "UPS.BatterySystem.Charger.ChargerID", NULL, "%.0f", 0, NULL }, - { "battery.input_flowid", 0, 0, "UPS.BatterySystem.Input.FlowID", NULL, "%.0f", 0, NULL }, - { "battery.input_id", 0, 0, "UPS.BatterySystem.Input.InputID", NULL, "%.0f", 0, NULL }, - { "battery.output_flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, - { "battery.output_id", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, + /* Note: fields marked with "experimental." prefix were proposed without + * an exact match vs. docs/nut-names.txt definitions. PRs are welcome to + * analyze and map those values into standard NUT variable names, or to + * raise discussion on mailing lists and define new names via consensus. + * There is a lot of interesting info listed below. + * + * Note: mappings that were applied below (as committed 2022-02-09) may + * be wrong and are based mostly on cursory reading of original names. + * In particular, not sure if the skipped "id.*" fields were identifiers + * or some "internal device" etc. + */ + + /* experimental: "NUT variable names" do not currently have + * any battery.*id data points: */ + { "experimental.battery.batteryid", 0, 0, "UPS.BatterySystem.Battery.BatteryID", NULL, "%.0f", 0, NULL }, + { "experimental.battery.systemid", 0, 0, "UPS.BatterySystem.BatterySystemID", NULL, "%.0f", 0, NULL }, + { "experimental.battery.chargerid", 0, 0, "UPS.BatterySystem.Charger.ChargerID", NULL, "%.0f", 0, NULL }, + { "experimental.battery.input_flowid", 0, 0, "UPS.BatterySystem.Input.FlowID", NULL, "%.0f", 0, NULL }, + { "experimental.battery.input_id", 0, 0, "UPS.BatterySystem.Input.InputID", NULL, "%.0f", 0, NULL }, + { "experimental.battery.output_flowid", 0, 0, "UPS.BatterySystem.Output.FlowID", NULL, "%.0f", 0, NULL }, + { "experimental.battery.output_id", 0, 0, "UPS.BatterySystem.Output.OutputID", NULL, "%.0f", 0, NULL }, + + /* experimental: "NUT variable names" do not currently have + * any id (nor version) data points for FW/HW of components: */ /* not implemented*/ - /* { "id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model }, */ - { "id.firmware_version_inverter", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, - { "id.firmware_version_interfaces", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, - { "id.hardware_version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, - { "id.protocol_version_inverter", 0, 0, "UPS.EVER1.EVER16", NULL, "%s", 0, ever_format_version }, - { "id.protocol_version_interfaces", 0, 0, "UPS.EVER1.EVER17", NULL, "%s", 0, ever_format_version }, - { "inverter_info.heatsink_temperature", 0, 0, "UPS.EVER1.EVER42", NULL, "%s", 0, kelvin_celsius_conversion }, - { "inverter_info.battery_temperature", 0, 0, "UPS.EVER1.EVER43", NULL, "%s", 0, kelvin_celsius_conversion }, - { "ups_info.output_powerfactor", 0, 0, "UPS.EVER1.EVER44", NULL, "%.0f", 0, NULL }, - { "control.ups_on", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER46", NULL, "%.0f", 0, NULL }, - { "control.clear_fault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER47", NULL, "%.0f", 0, NULL }, - { "control.clear_battery_fault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER48", NULL, "%.0f", 0, NULL }, - { "control.epo_blocked", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER50", NULL, "%.0f", 0, NULL }, - { "control.green_mode", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER51", NULL, "%.0f", 0, NULL }, - { "control.button_sound", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER52", NULL, "%.0f", 0, NULL }, - { "control.audible_alarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, - { "config.output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, + /* { "experimental.id.ups_type", 0, 0, "UPS.EVER1.EVER12", NULL, "%s", 0, ever_format_model }, */ + { "experimental.id.firmware_version_inverter", 0, 0, "UPS.EVER1.EVER13", NULL, "%s", 0, ever_format_version }, + { "experimental.id.firmware_version_interfaces", 0, 0, "UPS.EVER1.EVER14", NULL, "%s", 0, ever_format_version }, + { "experimental.id.hardware_version", 0, 0, "UPS.EVER1.EVER15", NULL, "%s", 0, ever_format_hardware }, + { "experimental.id.protocol_version_inverter", 0, 0, "UPS.EVER1.EVER16", NULL, "%s", 0, ever_format_version }, + { "experimental.id.protocol_version_interfaces", 0, 0, "UPS.EVER1.EVER17", NULL, "%s", 0, ever_format_version }, + + /* WAS: "experimental.inverter_info.heatsink_temperature" */ + { "ups.temperature", 0, 0, "UPS.EVER1.EVER42", NULL, "%s", 0, kelvin_celsius_conversion }, + /* WAS: "experimental.inverter_info.battery_temperature" */ + { "battery.temperature", 0, 0, "UPS.EVER1.EVER43", NULL, "%s", 0, kelvin_celsius_conversion }, + /* WAS: "experimental.ups_info.output_powerfactor" */ + { "powerfactor", 0, 0, "UPS.EVER1.EVER44", NULL, "%.0f", 0, NULL }, + + /* experimental: Should these be HU_TYPE_CMD entries? + * Or are they really settings? */ + { "experimental.control.ups_on", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER46", NULL, "%.0f", 0, NULL }, + { "experimental.control.clear_fault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER47", NULL, "%.0f", 0, NULL }, + { "experimental.control.clear_battery_fault", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER45.EVER48", NULL, "%.0f", 0, NULL }, + { "experimental.control.epo_blocked", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER50", NULL, "%.0f", 0, NULL }, + { "experimental.control.green_mode", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER51", NULL, "%.0f", 0, NULL }, + { "experimental.control.button_sound", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER52", NULL, "%.0f", 0, NULL }, + { "experimental.control.audible_alarm", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER49.EVER53", NULL, "%.0f", 0, NULL }, + + /* WAS: "experimental.config.output_voltage" */ + { "output.voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER54", NULL, "%.0f", 0, NULL }, + /* not implemented*/ /* - { "config.min_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, - { "config.max_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, - { "config.min_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, - { "config.max_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL }, + { "experimental.config.min_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER55", NULL, "%.0f", 0, NULL }, + { "experimental.config.max_output_voltage", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.EVER1.EVER56", NULL, "%.0f", 0, NULL }, + { "experimental.config.min_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER57", NULL, "%.1f", 0, NULL }, + { "experimental.config.max_output_frequency", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.EVER1.EVER58", NULL, "%.1f", 0, NULL }, */ - { "config.overload_clearance_threshold", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER59", NULL, "%.0f", 0, NULL }, - { "config.stb_charge", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER60", NULL, "%.0f", 0, NULL }, - { "config.number_of_ebms", ST_FLAG_RW | ST_FLAG_STRING, 1, "UPS.EVER1.EVER61", NULL, "%.0f", 0, NULL }, - { "statistics.mains_loss_counter", 0, 0, "UPS.EVER1.EVER62", NULL, "%.0f", 0, NULL }, - { "statistics.lowering_AVR_trigger_counter", 0, 0, "UPS.EVER1.EVER63", NULL, "%.0f", 0, NULL }, - { "statistics.rising_AVR_trigger_counter", 0, 0, "UPS.EVER1.EVER64", NULL, "%.0f", 0, NULL }, - { "statistics.overload_counter", 0, 0, "UPS.EVER1.EVER65", NULL, "%.0f", 0, NULL }, - { "statistics.short_circuit_counter", 0, 0, "UPS.EVER1.EVER66", NULL, "%.0f", 0, NULL }, - { "statistics.discharge_counter", 0, 0, "UPS.EVER1.EVER67", NULL, "%.0f", 0, NULL }, - { "statistics.overheat_counter", 0, 0, "UPS.EVER1.EVER68", NULL, "%.0f", 0, NULL }, - { "statistics.mains_operation_time", 0, 0, "UPS.EVER1.EVER69", NULL, "%.0f", 0, NULL }, - { "statistics.autonomous_operation_time", 0, 0, "UPS.EVER1.EVER70", NULL, "%.0f", 0, NULL }, - { "statistics.overload_operation_time", 0, 0, "UPS.EVER1.EVER71", NULL, "%.0f", 0, NULL }, - { "networkcard.mac_address", 0, 0, "UPS.EVER1.EVER72", NULL, "%s", 0, ever_mac_address }, - { "networkcard.notification_destination_ip", 0, 0, "UPS.EVER1.EVER73", NULL, "%s", 0, ever_ip_address }, - { "networkcard.send_packets", 0, 0, "UPS.EVER1.EVER77", NULL, "%s", 0, ever_packets }, - { "networkcard.received_packets", 0, 0, "UPS.EVER1.EVER78", NULL, "%s", 0, ever_packets }, - { "networkcard.send_packets_err", 0, 0, "UPS.EVER1.EVER79", NULL, "%s", 0, ever_packets }, - { "networkcard.received_packets_err", 0, 0, "UPS.EVER1.EVER80", NULL, "%s", 0, ever_packets }, - { "networkcard.config_dhcp_enabled", 0, 0, "UPS.EVER1.EVER85.EVER86", NULL, "%.0f", 0, NULL }, - { "networkcard.config_ethernet_enabled", 0, 0, "UPS.EVER1.EVER85.EVER87", NULL, "%.0f", 0, NULL }, - { "networkcard.config_http_enabled", 0, 0, "UPS.EVER1.EVER85.EVER88", NULL, "%.0f", 0, NULL }, - { "networkcard.config_snmp_enabled", 0, 0, "UPS.EVER1.EVER85.EVER89", NULL, "%.0f", 0, NULL }, - { "networkcard.config_snmp_trap_enabled", 0, 0, "UPS.EVER1.EVER85.EVER90", NULL, "%.0f", 0, NULL }, - { "networkcard.config_readonly", 0, 0, "UPS.EVER1.EVER85.EVER91", NULL, "%.0f", 0, NULL }, - { "networkcard.config_restart_eth", 0, 0, "UPS.EVER1.EVER85.EVER96", NULL, "%.0f", 0, NULL }, - { "networkcard.ip_address", 0, 0, "UPS.EVER1.EVER93", NULL, "%s", 0, ever_ip_address }, - { "networkcard.network_mask", 0, 0, "UPS.EVER1.EVER94", NULL, "%s", 0, ever_ip_address }, - { "networkcard.default_gateway", 0, 0, "UPS.EVER1.EVER95", NULL, "%s", 0, ever_ip_address }, - { "id.config_active_power", 0, 0, "UPS.Flow.ConfigActivePower", NULL, "%.0f", 0, NULL }, - { "id.config_apparent_power", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, - { "ups.config_frequency", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, - { "ups.config_voltage", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, - { "ups.flow_id", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", 0, NULL }, - { "outlet.outlet_id", 0, 0, "UPS.OutletSystem.Outlet.OutletID", NULL, "%.0f", 0, NULL }, - { "outlet.present", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Present", NULL, "%.0f", 0, yes_no_info }, - { "outlet.switchable", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Switchable", NULL, "%.0f", 0, yes_no_info }, - { "outlet.switch_on_off", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.SwitchOn/Off", NULL, "%.0f", 0, NULL }, - { "outlet.undefined", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Undefined", NULL, "%.0f", 0, NULL }, - { "outlet.switch_off_control", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOffControl", NULL, "%.0f", 0, NULL }, - { "outlet.switch_on_control", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOnControl", NULL, "%.0f", 0, NULL }, - { "outlet.system_id", 0, 0, "UPS.OutletSystem.OutletSystemID", NULL, "%.0f", 0, NULL }, - { "powerconverter.input_flow_id", 0, 0, "UPS.PowerConverter.Input.FlowID", NULL, "%.0f", 0, NULL }, - { "powerconverter.input_frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.0f", 0, NULL }, - { "powerconverter.input_id", 0, 0, "UPS.PowerConverter.Input.InputID", NULL, "%.0f", 0, NULL }, - { "powerconverter.input_voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_active_power", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_apparent_power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_flowid", 0, 0, "UPS.PowerConverter.Output.FlowID", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_id", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_percent_load", 0, 0, "UPS.PowerConverter.Output.PercentLoad", NULL, "%.0f", 0, NULL }, - { "powerconverter.output_voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, - { "powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", 0, NULL }, - { "powersummary.capacity_granularity_1", 0, 0, "UPS.PowerSummary.CapacityGranularity1", NULL, "%.0f", 0, NULL }, - { "powersummary.capacity_granularity_2", 0, 0, "UPS.PowerSummary.CapacityGranularity2", NULL, "%.0f", 0, NULL }, - { "powersummary.capacity_mode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, - { "powersummary.delay_before_shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL }, - { "powersummary.design_capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, - { "powersummary.flow_id", 0, 0, "UPS.PowerSummary.FlowID", NULL, "%.0f", 0, NULL }, - { "powersummary.full_charge_capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, - { "powersummary.idevice_chemistry", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%.0f", 0, NULL }, - { "powersummary.percent_load", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL }, - { "powersummary.rechargeable", 0, 0, "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL }, - { "powersummary.remaining_capacity", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, - { "powersummary.remaining_time_limit", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", 0, NULL }, - { "powersummary.run_time_to_empty", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, - { "powersummary.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, - { "powersummary.delay_before_shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + /* experimental: what units is this counted in? + * is "ups.load.high" a suitable mapping here? or "battery.voltage.high"? + */ + { "experimental.config.overload_clearance_threshold", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER59", NULL, "%.0f", 0, NULL }, + { "experimental.config.stb_charge", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.EVER1.EVER60", NULL, "%.0f", 0, NULL }, + /* WAS: "experimental.config.number_of_ebms" + * Should this be a string? rw? + */ + { "battery.packs.external", ST_FLAG_RW | ST_FLAG_STRING, 1, "UPS.EVER1.EVER61", NULL, "%.0f", 0, NULL }, + + { "experimental.statistics.mains_loss_counter", 0, 0, "UPS.EVER1.EVER62", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.lowering_AVR_trigger_counter", 0, 0, "UPS.EVER1.EVER63", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.rising_AVR_trigger_counter", 0, 0, "UPS.EVER1.EVER64", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.overload_counter", 0, 0, "UPS.EVER1.EVER65", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.short_circuit_counter", 0, 0, "UPS.EVER1.EVER66", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.discharge_counter", 0, 0, "UPS.EVER1.EVER67", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.overheat_counter", 0, 0, "UPS.EVER1.EVER68", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.mains_operation_time", 0, 0, "UPS.EVER1.EVER69", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.autonomous_operation_time", 0, 0, "UPS.EVER1.EVER70", NULL, "%.0f", 0, NULL }, + { "experimental.statistics.overload_operation_time", 0, 0, "UPS.EVER1.EVER71", NULL, "%.0f", 0, NULL }, + + { "experimental.networkcard.mac_address", 0, 0, "UPS.EVER1.EVER72", NULL, "%s", 0, ever_mac_address }, + { "experimental.networkcard.notification_destination_ip", 0, 0, "UPS.EVER1.EVER73", NULL, "%s", 0, ever_ip_address }, + { "experimental.networkcard.send_packets", 0, 0, "UPS.EVER1.EVER77", NULL, "%s", 0, ever_packets }, + { "experimental.networkcard.received_packets", 0, 0, "UPS.EVER1.EVER78", NULL, "%s", 0, ever_packets }, + { "experimental.networkcard.send_packets_err", 0, 0, "UPS.EVER1.EVER79", NULL, "%s", 0, ever_packets }, + { "experimental.networkcard.received_packets_err", 0, 0, "UPS.EVER1.EVER80", NULL, "%s", 0, ever_packets }, + { "experimental.networkcard.config_dhcp_enabled", 0, 0, "UPS.EVER1.EVER85.EVER86", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.config_ethernet_enabled", 0, 0, "UPS.EVER1.EVER85.EVER87", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.config_http_enabled", 0, 0, "UPS.EVER1.EVER85.EVER88", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.config_snmp_enabled", 0, 0, "UPS.EVER1.EVER85.EVER89", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.config_snmp_trap_enabled", 0, 0, "UPS.EVER1.EVER85.EVER90", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.config_readonly", 0, 0, "UPS.EVER1.EVER85.EVER91", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.config_restart_eth", 0, 0, "UPS.EVER1.EVER85.EVER96", NULL, "%.0f", 0, NULL }, + { "experimental.networkcard.ip_address", 0, 0, "UPS.EVER1.EVER93", NULL, "%s", 0, ever_ip_address }, + { "experimental.networkcard.network_mask", 0, 0, "UPS.EVER1.EVER94", NULL, "%s", 0, ever_ip_address }, + { "experimental.networkcard.default_gateway", 0, 0, "UPS.EVER1.EVER95", NULL, "%s", 0, ever_ip_address }, + + /* WAS: "experimental.id.config_active_power" */ + { "ups.realpower.nominal", 0, 0, "UPS.Flow.ConfigActivePower", NULL, "%.0f", 0, NULL }, + /* WAS: "experimental.id.config_apparent_power" + * Other HID subdrivers use "ups.power.nominal" mostly (often HU_FLAG_STATIC); + * once of each: "ups.realpower.nominal", "ups.realpower". + * Is this even a run-time value or a hardware property? + */ + { "ups.power.nominal", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", 0, NULL }, + + /* WAS: "experimental.ups.config_frequency" + * Here and next: is this about input or output?.. + * Other drivers have "input.frequency.nominal" on numbered Flows + * As a "nominal", should it be HU_FLAG_SEMI_STATIC or HU_FLAG_STATIC maybe? + * Note there are non-nominal values in "powerconverter" below, + * so the questions here may be somewhat irrelevant... + */ + { "output.frequency.nominal", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", 0, NULL }, + /* WAS: "experimental.ups.config_voltage" */ + { "output.voltage.nominal", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "experimental.ups.flow_id", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", 0, NULL }, + + /* NOTE: NUT variable names define "outlet.n.*" names for numbering all + * separately manageable outlets; the numberless value (or outlet.0.*) + * is reserved to represent common properties of all outlets, if there + * are more than one outlet (group). + * Mapping below arbitrarily assigns n=1 but really this should be tied + * to actual outlet counts (see %i mappings in other drivers). + */ + /* WAS: experimental.outlet.outlet_id */ + { "outlet.1.id", 0, 0, "UPS.OutletSystem.Outlet.OutletID", NULL, "%.0f", 0, NULL }, + /* WAS: */ + { "experimental.outlet.1.present", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Present", NULL, "%.0f", 0, yes_no_info }, + { "outlet.1.switchable", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Switchable", NULL, "%.0f", 0, yes_no_info }, + /* WAS: experimental.outlet.switch_on_off */ + { "outlet.1.status", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.SwitchOn/Off", NULL, "%.0f", 0, NULL }, + { "experimental.outlet.1.undefined", 0, 0, "UPS.OutletSystem.Outlet.PresentStatus.Undefined", NULL, "%.0f", 0, NULL }, + { "experimental.outlet.1.system_id", 0, 0, "UPS.OutletSystem.OutletSystemID", NULL, "%.0f", 0, NULL }, + /* experimental: Should these be HU_TYPE_CMD entries? + * Or are they really settings? */ + { "experimental.outlet.1.switch_off_control", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOffControl", NULL, "%.0f", 0, NULL }, + { "experimental.outlet.1.switch_on_control", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.OutletSystem.Outlet.SwitchOnControl", NULL, "%.0f", 0, NULL }, + + { "experimental.powerconverter.input_flow_id", 0, 0, "UPS.PowerConverter.Input.FlowID", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.input_frequency */ + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.0f", 0, NULL }, + { "experimental.powerconverter.input_id", 0, 0, "UPS.PowerConverter.Input.InputID", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.input_voltage */ + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.output_active_power */ + { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.output_apparent_power */ + { "ups.power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.output_current */ + { "output.current", 0, 0, "UPS.PowerConverter.Output.Current", NULL, "%.0f", 0, NULL }, + { "experimental.powerconverter.output_flowid", 0, 0, "UPS.PowerConverter.Output.FlowID", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.output_frequency */ + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", 0, NULL }, + { "experimental.powerconverter.output_id", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.output_percent_load + * Note: several original readings map into "ups.load", first served wins + */ + { "ups.load", 0, 0, "UPS.PowerConverter.Output.PercentLoad", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powerconverter.output_voltage */ + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", 0, NULL }, + { "experimental.powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", 0, NULL }, + { "experimental.powersummary.capacity_granularity_1", 0, 0, "UPS.PowerSummary.CapacityGranularity1", NULL, "%.0f", 0, NULL }, + { "experimental.powersummary.capacity_granularity_2", 0, 0, "UPS.PowerSummary.CapacityGranularity2", NULL, "%.0f", 0, NULL }, + /* WAS: */ + { "experimental.powersummary.capacity_mode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.delay_before_shutdown */ + { "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL }, + /* WAS: experimental.powersummary.design_capacity */ + { "battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, + { "experimental.powersummary.flow_id", 0, 0, "UPS.PowerSummary.FlowID", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.full_charge_capacity */ + { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.idevice_chemistry */ + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.percent_load + * Note: several original readings map into "ups.load", first served wins + */ + { "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL }, + { "experimental.powersummary.rechargeable", 0, 0, "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.remaining_capacity */ + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.remaining_time_limit */ + { "battery.runtime.low", ST_FLAG_RW | ST_FLAG_NUMBER, 0, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.run_time_to_empty */ + { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.voltage */ + { "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.0f", 0, NULL }, + /* WAS: experimental.powersummary.delay_before_shutdown */ + { "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, + /* not implemented*/ /* { "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.AwaitingPower", NULL, NULL, HU_FLAG_QUICK_POLL, awaitingpower_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, 0, nobattery_info }, + /* not implemented*/ - /* { "ups.presentstatus.belowremainingcapacitylimit", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, "%.0f", 0, NULL }, */ + /* { "experimental.ups.presentstatus.belowremainingcapacitylimit", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, "%.0f", 0, NULL }, */ /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Boost", NULL, NULL, 0, boost_info }, */ /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Buck", NULL, NULL, 0, trim_info }, */ /* { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.CommunicationLost", NULL, NULL, 0, commfault_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, /* not implemented*/ - /* { "ups.powersummary.presentstatus.good", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, "%.0f", 0, NULL }, */ - /* { "ups.powersummary.presentstatus.internalfailure", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, "%.0f", 0, NULL }, */ + /* { "experimental.ups.powersummary.presentstatus.good", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, "%.0f", 0, NULL }, */ + /* { "experimental.ups.powersummary.presentstatus.internalfailure", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, "%.0f", 0, NULL }, */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, @@ -630,11 +720,17 @@ static hid_info_t ever_hid2nut[] = { { "BOOL", 0, 0, "UPS.EVER1.EVER97.EVER102", NULL, "%s", 0, ever_on_off_info }, /* ever workmodes, messages & alarms */ - { "status.workmode", 0, 0, "UPS.EVER1.EVER97.EVER98", NULL, "%s", 0, ever_workmode }, - { "status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, - { "status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, + { "experimental.status.workmode", 0, 0, "UPS.EVER1.EVER97.EVER98", NULL, "%s", 0, ever_workmode }, + { "experimental.status.messages", 0, 0, "UPS.EVER1.EVER18.EVER28", NULL, NULL, 0, ever_messages }, + { "experimental.status.alarms", 0, 0, "UPS.EVER1.EVER32.EVER33", NULL, NULL, 0, ever_alarms }, /* instant commands */ + /* experimental: With the same fields here, are the commands different? + * Per NUT command names, should be: documented load.off stays off, like + * shutdown.stayoff, but shutdown.return may return if wall power comes back! + * In many drivers, similar command with "-1" instead of DEFAULT_OFFDELAY + * serves as a shutdown.stop (to abort a pending shutdown). + */ { "load.off.delay", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, { "shutdown.return", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, From c851c709a0df4ec1e0725865c3b4b55b67be03bd Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 14:04:14 +0100 Subject: [PATCH 55/70] docs/packager-guide.txt: fix title for pkg-nut-modbus --- docs/packager-guide.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/packager-guide.txt b/docs/packager-guide.txt index 20b10bcc07..98e5977f5f 100644 --- a/docs/packager-guide.txt +++ b/docs/packager-guide.txt @@ -273,7 +273,7 @@ nut-ipmi [[pkg-nut-modbus]] nut-modbus -^^^^^^^ +^^^^^^^^^^ - Desc: - Files: - Size: From c911e825c59bb7a4cfb366aa88f7f7d8113883f3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 14:04:02 +0100 Subject: [PATCH 56/70] docs/packager-guide.txt: update for nut-linux-i2c and nut-macosx-ups platform-dependent package groups --- docs/packager-guide.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/packager-guide.txt b/docs/packager-guide.txt index 98e5977f5f..4730dcb2bb 100644 --- a/docs/packager-guide.txt +++ b/docs/packager-guide.txt @@ -174,6 +174,9 @@ FIXME: make a dependency graph - <> - <> +- <> (platform-dependent) +- <> (platform-dependent) + - <> - <> - <> (or nut-control-center or Ultimate NUT Tool...) @@ -279,6 +282,22 @@ nut-modbus - Size: - Deps: +[[pkg-nut-linux-i2c]] +nut-linux-i2c +^^^^^^^^^^^^^ +- Desc: (platform-dependent) +- Files: +- Size: +- Deps: + +[[pkg-nut-macosx-ups]] +nut-macosx-ups +^^^^^^^^^^^^^^ +- Desc: (platform-dependent) +- Files: +- Size: +- Deps: + [[pkg-nut-clients]] nut-clients ^^^^^^^^^^^ From 21906c3f83c1b4b7e2b1ad715f7078f03d84640c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 15:37:10 +0100 Subject: [PATCH 57/70] drivers/nutdrv_qx_masterguard.c: whitespace fixes (some long lines) --- drivers/nutdrv_qx_masterguard.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/nutdrv_qx_masterguard.c b/drivers/nutdrv_qx_masterguard.c index ad91ddcf61..39c088532a 100644 --- a/drivers/nutdrv_qx_masterguard.c +++ b/drivers/nutdrv_qx_masterguard.c @@ -49,7 +49,7 @@ static info_rw_t masterguard_r_slaveaddr[] = { static info_rw_t masterguard_r_batpacks[] = { { "0", NULL }, /* actually 1 for most models, see masterguard_model() */ - { "9", NULL }, /* varies across models, see masterguard_model() */ + { "9", NULL }, /* varies across models, see masterguard_model() */ { "" , NULL } }; @@ -73,7 +73,7 @@ static info_rw_t *masterguard_e_outvolts = NULL; /* set in masterguard_output_vo /* preprocess functions */ -/* set masterguard_my_slaveaddr (for masterguard_add_slaveaddr */ +/* set masterguard_my_slaveaddr (for masterguard_add_slaveaddr) */ static int masterguard_slaveaddr(item_t *item, char *value, const size_t valuelen) { if (strlen(item->value) != 2) { upsdebugx(2, "slaveaddr length not 2"); @@ -102,8 +102,9 @@ static int masterguard_series(item_t *item, char *value, const size_t valuelen) return 0; } -/* convert strangely formatted model name in WH output (spaces, -19 only after battery packs) to something readable */ -/* also set min/max battery packs according to model */ +/* Convert strangely formatted model name in WH output + * (spaces, -19 only after battery packs) to something readable + * Also set min/max battery packs according to model */ static int masterguard_model(item_t *item, char *value, const size_t valuelen) { char *model; int rack; @@ -495,7 +496,8 @@ static int masterguard_shutdown(item_t *item, char *value, const size_t valuelen } return 0; -ill: upsdebugx(2, "shutdown: illegal %s %s", name, val); +ill: + upsdebugx(2, "shutdown: illegal %s %s", name, val); return -1; } @@ -926,7 +928,9 @@ static char *masterguard_commands_e[] = { "Q", "Q1", "Q3", "PSR", "T", "TL", "S", "C", "CT", "WH", "DRC", "SRC", "FLT", "FCLR", "SS", "GS", "MSO", "PNV", "FOFF", "FON", "TUD", "GBS", "SSN", "GSN", "BUS", "V", "INVDC", "BUSP", "BUSN", NULL }; -/* claim function. fetch some mandatory values, disable unsupported commands, set enum for supported output voltages */ +/* claim function. fetch some mandatory values, + * disable unsupported commands, + * set enum for supported output voltages */ static int masterguard_claim(void) { item_t *item; /* mandatory values */ @@ -968,12 +972,16 @@ static int masterguard_claim(void) { upsdebugx(2, "claim: cannot find %s", *sp); return 0; } - /* since qx_process_answer() is not exported, there's no way to avoid sending the same command to the UPS again */ + /* since qx_process_answer() is not exported, there's no way + * to avoid sending the same command to the UPS again */ if (qx_process(item, NULL) < 0) { upsdebugx(2, "claim: cannot process %s", *sp); return 0; } - /* only call the preprocess function; don't call ups_infoval_set() because that does a dstate_setinfo() before dstate_setflags() is called (via qx_set_var() in qx_ups_walk() with QX_WALKMODE_INIT); that leads to r/w vars ending up r/o. */ + /* only call the preprocess function; don't call ups_infoval_set() + * because that does a dstate_setinfo() before dstate_setflags() + * is called (via qx_set_var() in qx_ups_walk() with QX_WALKMODE_INIT); + * that leads to r/w vars ending up r/o. */ if (item->preprocess == NULL ) { upsdebugx(2, "claim: no preprocess function for %s", *sp); return 0; From e1e85bf818ea7acc8887257f527bda1b5dca412b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 15:36:45 +0100 Subject: [PATCH 58/70] drivers/nutdrv_qx_masterguard.c: fix "ups.delay.return" => "ups.delay.start" --- drivers/nutdrv_qx_masterguard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nutdrv_qx_masterguard.c b/drivers/nutdrv_qx_masterguard.c index 39c088532a..58cc7f5d7d 100644 --- a/drivers/nutdrv_qx_masterguard.c +++ b/drivers/nutdrv_qx_masterguard.c @@ -25,7 +25,7 @@ #include "nutdrv_qx_masterguard.h" #include -#define MASTERGUARD_VERSION "Masterguard 0.01" +#define MASTERGUARD_VERSION "Masterguard 0.02" /* series (for un-SKIP) */ static char masterguard_my_series = '?'; @@ -489,7 +489,7 @@ static int masterguard_shutdown(item_t *item, char *value, const size_t valuelen } else { long ondelay; - ondelay = strtol((val = dstate_getinfo(name = "ups.delay.return")), &p, 10); + ondelay = strtol((val = dstate_getinfo(name = "ups.delay.start")), &p, 10); if (*p != '\0') goto ill; if (ondelay < 0 || ondelay > 9999*60) goto ill; snprintf(value, valuelen, "S%sR%04ld\r", offstr, ondelay); From 7ef2874e81952fac532014a8840a217cf1d636b6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 9 Feb 2022 16:00:11 +0100 Subject: [PATCH 59/70] drivers/nutdrv_qx_masterguard.c: rename non-standard dstate variables to "experimental.*" namespace Closes: NUT issue #1045 --- drivers/nutdrv_qx_masterguard.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/nutdrv_qx_masterguard.c b/drivers/nutdrv_qx_masterguard.c index 58cc7f5d7d..08168f69dd 100644 --- a/drivers/nutdrv_qx_masterguard.c +++ b/drivers/nutdrv_qx_masterguard.c @@ -685,7 +685,7 @@ static item_t masterguard_qx2nut[] = { { "ups.firmware", 0, NULL, "WH\r", "", 113, '(', "", 4, 8, "%s", QX_FLAG_STATIC, NULL, NULL, NULL }, { "ups.firmware.aux", 0, NULL, "WH\r", "", 113, '(', "", 10, 14, "%s", QX_FLAG_STATIC, NULL, NULL, NULL }, /* several values are deduced from the T field */ - { "series", 0, NULL, "WH\r", "", 113, '(', "", 16, 16, "%s", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_series }, + { "experimental.series", 0, NULL, "WH\r", "", 113, '(', "", 16, 16, "%s", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_series }, { "device.model", 0, NULL, "WH\r", "", 113, '(', "", 16, 45, "%s", QX_FLAG_STATIC, NULL, NULL, masterguard_model }, { "ups.power.nominal", 0, NULL, "WH\r", "", 113, '(', "", 16, 45, "%s", QX_FLAG_STATIC, NULL, NULL, masterguard_power }, /* not used, use GS instead because the value is settable @@ -693,12 +693,12 @@ static item_t masterguard_qx2nut[] = { */ { "input.voltage.nominal", 0, NULL, "WH\r", "", 113, '(', "", 49, 51, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, { "input.frequency.nominal", 0, NULL, "WH\r", "", 113, '(', "", 53, 57, "%.2f", QX_FLAG_STATIC, NULL, NULL, NULL }, - { "number_of_battery_cells", 0, NULL, "WH\r", "", 113, '(', "", 59, 61, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_numcells }, - { "nominal_cell_voltage", 0, NULL, "WH\r", "", 113, '(', "", 63, 67, "%.2f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, NULL }, + { "experimental.number_of_battery_cells", 0, NULL, "WH\r", "", 113, '(', "", 59, 61, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_numcells }, + { "experimental.nominal_cell_voltage", 0, NULL, "WH\r", "", 113, '(', "", 63, 67, "%.2f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, NULL }, { "battery.voltage.nominal", 0, NULL, "WH\r", "", 113, '(', "", 63, 67, "%.2f", QX_FLAG_STATIC, NULL, NULL, masterguard_battvolt}, - { "runtime_half", 0, NULL, "WH\r", "", 113, '(', "", 69, 74, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_mmm_ss }, - { "runtime_full", 0, NULL, "WH\r", "", 113, '(', "", 76, 81, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_mmm_ss }, - { "recharge_time", 0, NULL, "WH\r", "", 113, '(', "", 83, 85, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_hhh }, + { "experimental.runtime_half", 0, NULL, "WH\r", "", 113, '(', "", 69, 74, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_mmm_ss }, + { "experimental.runtime_full", 0, NULL, "WH\r", "", 113, '(', "", 76, 81, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_mmm_ss }, + { "experimental.recharge_time", 0, NULL, "WH\r", "", 113, '(', "", 83, 85, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_hhh }, /*!! what's the difference between low/high and low.critical/high.critical?? */ { "ambient.0.temperature.low", 0, NULL, "WH\r", "", 113, '(', "", 87, 88, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, { "ambient.0.temperature.high", 0, NULL, "WH\r", "", 113, '(', "", 90, 91, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, @@ -718,7 +718,7 @@ static item_t masterguard_qx2nut[] = { */ /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ { "input.voltage", 0, NULL, "Q3\r", "", 71, '(', "", 4, 8, "%.1f", 0, NULL, NULL, NULL }, - { "input_fault_voltage", 0, NULL, "Q3\r", "", 71, '(', "", 10, 14, "%.1f", QX_FLAG_NONUT, NULL, NULL, NULL }, + { "experimental.input_fault_voltage", 0, NULL, "Q3\r", "", 71, '(', "", 10, 14, "%.1f", QX_FLAG_NONUT, NULL, NULL, NULL }, { "output.voltage", 0, NULL, "Q3\r", "", 71, '(', "", 16, 20, "%.1f", 0, NULL, NULL, NULL }, { "ups.load", 0, NULL, "Q3\r", "", 71, '(', "", 22, 24, "%.0f", 0, NULL, NULL, NULL }, { "ups.power", 0, NULL, "Q3\r", "", 71, '(', "", 22, 24, "%.0f", 0, NULL, NULL, masterguard_ups_power }, @@ -814,7 +814,7 @@ static item_t masterguard_qx2nut[] = { * (220 230 240 */ /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ - { "output_voltages", 0, NULL, "MSO\r", "", 5, '(', "", 1, 0, "%s", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_output_voltages }, + { "experimental.output_voltages", 0, NULL, "MSO\r", "", 5, '(', "", 1, 0, "%s", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_output_voltages }, /* * > [PNV\r] @@ -837,11 +837,11 @@ static item_t masterguard_qx2nut[] = { * (01,9 0010 1780:14:57:19 7 0046 0000:21:14:41 0 0000 0000:00:00:00 0 0000 0000:00:00:00 0 0000 0000:00:00:00 */ /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ - { "fault_1", 0, NULL, "FLT,XX\r", "", 108, '(', "", 4, 23, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, - { "fault_2", 0, NULL, "FLT,XX\r", "", 108, '(', "", 25, 44, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, - { "fault_3", 0, NULL, "FLT,XX\r", "", 108, '(', "", 46, 65, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, - { "fault_4", 0, NULL, "FLT,XX\r", "", 108, '(', "", 67, 86, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, - { "fault_5", 0, NULL, "FLT,XX\r", "", 108, '(', "", 88, 107, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_1", 0, NULL, "FLT,XX\r", "", 108, '(', "", 4, 23, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_2", 0, NULL, "FLT,XX\r", "", 108, '(', "", 25, 44, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_3", 0, NULL, "FLT,XX\r", "", 108, '(', "", 46, 65, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_4", 0, NULL, "FLT,XX\r", "", 108, '(', "", 67, 86, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_5", 0, NULL, "FLT,XX\r", "", 108, '(', "", 88, 107, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, /* instant commands */ From a0b4c4e5afcfe16e1b63f27c1f41db777e362120 Mon Sep 17 00:00:00 2001 From: Nick Geoghegan Date: Wed, 9 Feb 2022 22:46:36 +0000 Subject: [PATCH 60/70] Fixes 530 --- drivers/riello_usb.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index a0ed97eea0..45d3d54ecf 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -36,7 +36,10 @@ #include "riello.h" #define DRIVER_NAME "Riello USB driver" -#define DRIVER_VERSION "0.06" +#define DRIVER_VERSION "0.07" + +#define DEFAULT_OFFDELAY 5 /*!< seconds (max 0xFF) */ +#define DEFAULT_BOOTDELAY 5 /*!< seconds (max 0xFF) */ /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -55,6 +58,10 @@ static uint8_t gpser_error_control; static uint8_t input_monophase; static uint8_t output_monophase; +/*! Time in seconds to delay before shutting down. */ +static unsigned int offdelay = DEFAULT_OFFDELAY; +static unsigned int bootdelay = DEFAULT_BOOTDELAY; + static TRielloData DevData; static usb_communication_subdriver_t *usb = &usb_subdriver; @@ -972,6 +979,13 @@ void upsdrv_initinfo(void) dstate_addcmd("test.battery.start"); dstate_addcmd("test.panel.start"); + dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.shutdown", 3); + dstate_setinfo("ups.delay.reboot", "%d", bootdelay); + dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.reboot", 3); + /* install handlers */ /* upsh.setvar = hid_set_value; setvar; */ @@ -1058,9 +1072,13 @@ 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); - dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + 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 < 0xFF) + dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + if (input_monophase) { dstate_setinfo("input.voltage", "%u", DevData.Uinp1); From 448fae430ee2f9dcd62a06c15671d8d63be2d5d6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 18:43:34 +0100 Subject: [PATCH 61/70] docs/man/Makefile.am: build and install nutdrv_siemens_sitop man pages --- docs/man/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am index 3c0fb6aecc..01b1c37964 100644 --- a/docs/man/Makefile.am +++ b/docs/man/Makefile.am @@ -398,6 +398,7 @@ SRC_SERIAL_PAGES = \ oneac.txt \ microdowell.txt \ microsol-apc.txt \ + nutdrv_siemens_sitop.txt \ optiups.txt \ powercom.txt \ powerpanel.txt \ @@ -441,6 +442,7 @@ MAN_SERIAL_PAGES = \ oneac.8 \ microdowell.8 \ microsol-apc.8 \ + nutdrv_siemens_sitop.8 \ optiups.8 \ powercom.8 \ powerpanel.8 \ @@ -488,6 +490,7 @@ HTML_SERIAL_MANS = \ oneac.html \ microdowell.html \ microsol-apc.html \ + nutdrv_siemens_sitop.html \ optiups.html \ powercom.html \ powerpanel.html \ From 793f1dff3999e56a2261d3d1be3fc01a506c3e17 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 14:01:29 +0100 Subject: [PATCH 62/70] configure.ac: fall back from pkg-config queries for "systemd" to try also "libsystemd" --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 25b08a32e4..36d8c338ec 100644 --- a/configure.ac +++ b/configure.ac @@ -1862,7 +1862,7 @@ AC_ARG_WITH([systemdsystemunitdir], case "${withval}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"], + [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" && [ -n "$systemdsystemunitdir" ] || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd`"], [AS_IF([test "${withval}" = yes], [AC_MSG_ERROR([--with-systemdsystemunitdir=${withval} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdsystemunitdir="" @@ -1895,7 +1895,7 @@ if test -n "${systemdsystemunitdir}"; then case "${systemdshutdowndir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`"], + [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`" && [ -n "$systemdshutdowndir" ] || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd`"], [AS_IF([test "${systemdshutdowndir}" = yes], [AC_MSG_ERROR([--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdshutdowndir="" @@ -1924,7 +1924,7 @@ AC_ARG_WITH([systemdtmpfilesdir], case "${systemdtmpfilesdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`"], + [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`" && [ -n "$systemdtmpfilesdir" ] || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd`"], [AS_IF([test "${systemdtmpfilesdir}" = yes], [AC_MSG_ERROR([--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdtmpfilesdir="" From a1572032226073415198f95e557d5f3dec002204 Mon Sep 17 00:00:00 2001 From: Nick Geoghegan Date: Thu, 10 Feb 2022 19:53:16 +0000 Subject: [PATCH 63/70] Updates riello_ser to version 0.07 --- drivers/riello_ser.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/riello_ser.c b/drivers/riello_ser.c index d5eeb28757..8c2714fdef 100644 --- a/drivers/riello_ser.c +++ b/drivers/riello_ser.c @@ -43,7 +43,10 @@ #include "riello.h" #define DRIVER_NAME "Riello serial driver" -#define DRIVER_VERSION "0.04" +#define DRIVER_VERSION "0.07" + +#define DEFAULT_OFFDELAY 5 +#define DEFAULT_BOOTDELAY 5 /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -63,6 +66,9 @@ static uint8_t typeRielloProtocol; static uint8_t input_monophase; static uint8_t output_monophase; +static unsigned int offdelay = DEFAULT_OFFDELAY; +static unsigned int bootdelay = DEFAULT_BOOTDELAY; + static TRielloData DevData; /********************************************************************** @@ -761,6 +767,14 @@ void upsdrv_initinfo(void) dstate_addcmd("shutdown.stop"); dstate_addcmd("test.battery.start"); + dstate_setinfo("ups.delay.shutdown", "%u", offdelay); + dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.shutdown", 3); + dstate_setinfo("ups.delay.reboot", "%u", bootdelay); + dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.reboot", 3); + + if (typeRielloProtocol == DEV_RIELLOGPSER) dstate_addcmd("test.panel.start"); @@ -813,9 +827,14 @@ 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); - dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + + 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 < 0xFF) + dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); if (input_monophase) { dstate_setinfo("input.voltage", "%u", DevData.Uinp1); From 52268eba6f63c26a1237670d27aa1c58e822281a Mon Sep 17 00:00:00 2001 From: Nick Geoghegan Date: Thu, 10 Feb 2022 20:06:09 +0000 Subject: [PATCH 64/70] Fixes formatting in riello_usb --- drivers/riello_usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 45d3d54ecf..d6f27e2be2 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -979,10 +979,10 @@ void upsdrv_initinfo(void) dstate_addcmd("test.battery.start"); dstate_addcmd("test.panel.start"); - dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + dstate_setinfo("ups.delay.shutdown", "%u", offdelay); dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.delay.shutdown", 3); - dstate_setinfo("ups.delay.reboot", "%d", bootdelay); + dstate_setinfo("ups.delay.reboot", "%u", bootdelay); dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.delay.reboot", 3); @@ -1076,6 +1076,7 @@ void upsdrv_updateinfo(void) 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); From b002263ea544c5f0b18269a52445d789b8553b7b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 22:15:55 +0100 Subject: [PATCH 65/70] configure.ac: fall back from pkg-config queries for "systemd" to try also "libsystemd" - fix calling "test" --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 36d8c338ec..ef8d13414c 100644 --- a/configure.ac +++ b/configure.ac @@ -1862,7 +1862,7 @@ AC_ARG_WITH([systemdsystemunitdir], case "${withval}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" && [ -n "$systemdsystemunitdir" ] || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd`"], + [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd`"], [AS_IF([test "${withval}" = yes], [AC_MSG_ERROR([--with-systemdsystemunitdir=${withval} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdsystemunitdir="" @@ -1895,7 +1895,7 @@ if test -n "${systemdsystemunitdir}"; then case "${systemdshutdowndir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`" && [ -n "$systemdshutdowndir" ] || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd`"], + [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`" && test -n "$systemdshutdowndir" || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd`"], [AS_IF([test "${systemdshutdowndir}" = yes], [AC_MSG_ERROR([--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdshutdowndir="" @@ -1924,7 +1924,7 @@ AC_ARG_WITH([systemdtmpfilesdir], case "${systemdtmpfilesdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`" && [ -n "$systemdtmpfilesdir" ] || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd`"], + [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`" && test -n "$systemdtmpfilesdir" || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd`"], [AS_IF([test "${systemdtmpfilesdir}" = yes], [AC_MSG_ERROR([--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdtmpfilesdir="" From 0fcdcdc4b96df9eeb5a3c919a6ec4c63a0e8ebfa Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 22:29:59 +0100 Subject: [PATCH 66/70] configure.ac: default to detection of systemdsystemunitdir (and systemdshutdowndir), non-fatal if not found --- configure.ac | 24 ++++++++++++------------ docs/configure.txt | 6 +++++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index ef8d13414c..d8b2beadbb 100644 --- a/configure.ac +++ b/configure.ac @@ -1850,16 +1850,15 @@ fi AC_MSG_RESULT([${solarispkg_ips}]) AM_CONDITIONAL(WITH_SOLARIS_PKG_IPS, test x"$solarispkg_ips" = x"yes") -dnl Note: Currently there is no automatic detection enabled - -dnl users have to ask they want systemd units installed. -dnl It may be changed based on popular demand to just always -dnl run the "case" below for ${systemdsystemunitdir} values, -dnl like we do for systemdtmpfilesdir further below. +dnl Note: Currently there is no reliable automatic detection - +dnl users have to ask they want systemd units installed, or +dnl risk auto-detection like seen below. AC_MSG_CHECKING(whether to install systemd unit files) AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto)]), -[ - case "${withval}" in + [systemdsystemunitdir="${withval}"], + [systemdsystemunitdir="auto"]) +case "${withval}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd`"], @@ -1874,8 +1873,7 @@ AC_ARG_WITH([systemdsystemunitdir], *) systemdsystemunitdir="${withval}" ;; - esac -], []) +esac if test -n "${systemdsystemunitdir}"; then AC_MSG_RESULT(using ${systemdsystemunitdir}) else @@ -1889,7 +1887,8 @@ dnl given AC_MSG_CHECKING(whether to install systemd shutdown files) AC_ARG_WITH([systemdshutdowndir], AS_HELP_STRING([--with-systemdshutdowndir=DIR], [Directory for systemd shutdown scripts (auto)]), - [systemdshutdowndir=${withval}]) + [systemdshutdowndir="${withval}"], + [systemdshutdowndir="auto"]) dnl Note: this option is enabled only if systemdsystemunitdir is not trivial if test -n "${systemdsystemunitdir}"; then case "${systemdshutdowndir}" in @@ -1916,11 +1915,12 @@ else fi dnl Note: if (systemd-)tmpfiles tech is present, it can be useful even for -dnl daemons starting not as systemd units +dnl daemons starting not as systemd units, to pre-create /var/run/nut etc. AC_MSG_CHECKING([whether to install systemd tmpfiles files]) AC_ARG_WITH([systemdtmpfilesdir], AS_HELP_STRING([--with-systemdtmpfilesdir=DIR], [Directory for systemd tmpfiles scripts (auto)]), - [systemdtmpfilesdir=${withval}]) + [systemdtmpfilesdir="${withval}"], + [systemdtmpfilesdir="auto"]) case "${systemdtmpfilesdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], diff --git a/docs/configure.txt b/docs/configure.txt index 281fd621d7..0c35a72550 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -344,7 +344,11 @@ Where to install Linux systemd unit definitions. Useless and harmless on other OSes, including Linux distributions without systemd, just adding a little noise to configure script output. -Use --with-systemdsystemunitdir to detect the settings using pkg-config. +Use --with-systemdsystemunitdir=auto (default) to detect the settings +using pkg-config if possible. + +Use --with-systemdsystemunitdir(=yes) to require detection of these +settings with pkg-config, or fail configuration if not possible. Use --with-systemdsystemunitdir=no to disable this feature altogether. From f7f4d8d3ac7f3e69c05b8565f7d87289e85c3c38 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 22:36:27 +0100 Subject: [PATCH 67/70] configure.ac: default to detection of systemdsystemunitdir (and systemdshutdowndir) - "auto" is not a final option --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d8b2beadbb..424419888c 100644 --- a/configure.ac +++ b/configure.ac @@ -1858,7 +1858,7 @@ AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto)]), [systemdsystemunitdir="${withval}"], [systemdsystemunitdir="auto"]) -case "${withval}" in +case "${systemdsystemunitdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd`"], @@ -1874,6 +1874,7 @@ case "${withval}" in systemdsystemunitdir="${withval}" ;; esac +if test "${systemdsystemunitdir}" = "auto" ; then systemdsystemunitdir=""; fi if test -n "${systemdsystemunitdir}"; then AC_MSG_RESULT(using ${systemdsystemunitdir}) else @@ -1908,6 +1909,7 @@ if test -n "${systemdsystemunitdir}"; then ;; esac fi +if test "${systemdshutdowndir}" = "auto" ; then systemdshutdowndir=""; fi if test -n "${systemdshutdowndir}"; then AC_MSG_RESULT(using ${systemdshutdowndir}) else @@ -1937,6 +1939,7 @@ case "${systemdtmpfilesdir}" in systemdtmpfilesdir="${withval}" ;; esac +if test "${systemdtmpfilesdir}" = "auto" ; then systemdtmpfilesdir=""; fi if test -n "${systemdtmpfilesdir}"; then AC_MSG_RESULT(using ${systemdtmpfilesdir}) else From f350c8a8f28f6e844db47a30243bcb0cde6deafb Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 22:43:16 +0100 Subject: [PATCH 68/70] configure.ac: avoid noise about pkg-config not finding (lib)systemd.pc on systems where it is not installed --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 424419888c..ae18c5b0c0 100644 --- a/configure.ac +++ b/configure.ac @@ -1861,7 +1861,7 @@ AC_ARG_WITH([systemdsystemunitdir], case "${systemdsystemunitdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd`"], + [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd 2>/dev/null`"], [AS_IF([test "${withval}" = yes], [AC_MSG_ERROR([--with-systemdsystemunitdir=${withval} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdsystemunitdir="" @@ -1895,7 +1895,7 @@ if test -n "${systemdsystemunitdir}"; then case "${systemdshutdowndir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd`" && test -n "$systemdshutdowndir" || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd`"], + [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd 2>/dev/null`" && test -n "$systemdshutdowndir" || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd 2>/dev/null`"], [AS_IF([test "${systemdshutdowndir}" = yes], [AC_MSG_ERROR([--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdshutdowndir="" @@ -1926,7 +1926,7 @@ AC_ARG_WITH([systemdtmpfilesdir], case "${systemdtmpfilesdir}" in yes|auto|"") AS_IF([test x"$have_PKG_CONFIG" = xyes], - [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd`" && test -n "$systemdtmpfilesdir" || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd`"], + [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd 2>/dev/null`" && test -n "$systemdtmpfilesdir" || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd 2>/dev/null`"], [AS_IF([test "${systemdtmpfilesdir}" = yes], [AC_MSG_ERROR([--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) systemdtmpfilesdir="" From 12b00309608e4ec28cd7787c1de57293e921678e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 10 Feb 2022 23:22:12 +0100 Subject: [PATCH 69/70] .github/pull_request_template.md: remind to update recipes for new man pages --- .github/pull_request_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 09956d27b8..084ac806ce 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -88,6 +88,7 @@ Also note below, a point about PR posting for NUT DDL - [ ] Updated `docs/acknowledgements.txt` (for vendor-backed device support) - [ ] Added or updated manual page information in `docs/man/*.txt` files + and corresponding recipe lists in `docs/man/Makefile.am` for new pages - [ ] Passed `make spellcheck`, updated spell-checking dictionary in the `docs/nut.dict` file if needed (did not remove any words -- the `make` From cb3363be2e71062bf3c97f34d0e520aff3841ca5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 11 Feb 2022 21:00:00 +0100 Subject: [PATCH 70/70] NEWS: added usbhid-ups "ever-hid" subdriver for NUT v2.7.5 --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index ac9220c69d..bd999749d6 100644 --- a/NEWS +++ b/NEWS @@ -149,6 +149,8 @@ Release notes for NUT 2.7.5 - what's new since 2.7.4: * add Arduino HID device support with new arduino-hid subdriver [PR #1044] * add new salicru-hid subdriver, tested with Salicru SPS Home 850 VA [PR #1199, issue #732] + * add new ever-hid subdriver to support EVER UPS devices (Sinline RT Series, + Sinline RT XL Series, ECO PRO AVR CDS Series) [PR #431] - usbhid-ups / mge-shut: compute a realpower output load approximation for Eaton UPS when the needed data is not present