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` diff --git a/NEWS b/NEWS index a8d1a8cae8..d7aad9d3b6 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 @@ -174,6 +176,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 47367b03ba..ba120d90ef 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, @@ -62,6 +69,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. diff --git a/ci_build.sh b/ci_build.sh index ced3554d63..bf95c42c93 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -1140,6 +1140,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 } @@ -1260,6 +1264,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 } 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..f35fe09ec7 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -497,13 +497,19 @@ static int sock_read(conn_t *conn) if ((ret == -1) && (errno == EAGAIN)) 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. */ + if (ret == 0) + continue; + /* some other problem */ return -1; /* error */ } ret = pconf_char(&conn->ctx, ch); - if (ret == 0) /* nothing to parse yet */ + if (ret == 0) /* nothing to parse yet */ continue; if (ret == -1) { @@ -691,32 +697,15 @@ 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]; + size_t enclen, buflen; + char buf[SMALLBUF], enc[SMALLBUF + 8]; + int ret_s; + struct timeval tv; + fd_set fdread; /* insanity */ if (!arg1) @@ -732,8 +721,10 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) snprintf(enc, sizeof(enc), "%s\n", buf); - enclen = strlen(buf); - if (enclen >= SSIZE_MAX) { + /* Sanity checks, for static analyzers to sleep well */ + 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"); } @@ -745,7 +736,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; @@ -760,27 +750,38 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) ret = write(pipefd, enc, enclen); /* if we can't send the whole thing, loop back and try again */ - if ((ret < 1) || (ret != (ssize_t) enclen)) { + if ((ret < 1) || (ret != (ssize_t)enclen)) { 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); @@ -796,7 +797,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"); } @@ -823,7 +824,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 +886,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/configure.ac b/configure.ac index ec315f6206..b4716db544 100644 --- a/configure.ac +++ b/configure.ac @@ -451,6 +451,211 @@ 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 + + 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) + 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 + if test -z "${with_macosx_ups}"; then with_macosx_ups="${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 + + 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"]) + 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"], [ + DRV_HITS="$DRV_HITS $DRVLIST_NAME" + 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 + 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 + ]) + + ;; + 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 @@ -462,24 +667,42 @@ dnl ### Not forced: lua, dmf_lua, snmp_dmf_lua 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_snmp_dmf}"; then with_snmp_dmf="${withval}"; fi +dnl NOTE: The LUA integration is experimental, so not forced as part of --with-all +dnl if test -z "${with_lua}"; then with_lua="${withval}"; fi +dnl if test -z "${with_dmf_lua}"; then with_dmf_lua="${withval}"; fi +dnl if test -z "${with_snmp_dmf_lua}"; then with_snmp_dmf_lua="${withval}"; fi if test -z "${with_neon}"; then with_neon="${withval}"; fi if test -z "${with_libxml2}"; then with_libxml2="${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 - if test -z "${with_dmf}"; then with_dmf="${withval}"; fi - if test -z "${with_snmp_dmf}"; then with_snmp_dmf="${withval}"; fi -dnl NOTE: The LUA integration is experimental, so not forced as part of --with-all -dnl if test -z "${with_lua}"; then with_lua="${withval}"; fi -dnl if test -z "${with_dmf_lua}"; then with_dmf_lua="${withval}"; fi -dnl if test -z "${with_snmp_dmf_lua}"; then with_snmp_dmf_lua="${withval}"; fi + AC_MSG_RESULT("${withval}") else AC_MSG_RESULT(not given) @@ -501,7 +724,6 @@ dnl Until then, also this is not activated by --with-all flag. NUT_ARG_WITH([nutconf], [build and install the nutconf tool (experimental, has compiler/coverage warnings)], [no]) NUT_ARG_WITH([dev], [build and install the development files], [no]) -NUT_ARG_WITH([serial], [build and install serial drivers], [yes]) dnl The NUT legacy option was --with-doc; however to simplify configuration dnl in some common packaging frameworks, we also allow --with-docs as @@ -524,6 +746,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. @@ -779,6 +1003,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 @@ -832,6 +1059,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 @@ -1518,34 +1748,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 diff --git a/docs/acknowledgements.txt b/docs/acknowledgements.txt index ececa2d7f9..7597bb224b 100644 --- a/docs/acknowledgements.txt +++ b/docs/acknowledgements.txt @@ -97,6 +97,9 @@ UPM models as usb-hid UPS. revived the 'sec' driver (as gamatronic), and expanded a bit genericups for its UPSs with alarm interface. +* 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 devices. The company also proposes NUT as an alternative to its software for diff --git a/docs/developers.txt b/docs/developers.txt index 702bd1fe55..57088290dc 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 ~~~~~~~~~~~~~~~ @@ -755,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 @@ -809,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 ~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/documentation.txt b/docs/documentation.txt index 8622b1e6cc..b8d946aa00 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)' @@ -92,6 +92,11 @@ 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: + +- link:https://www.youtube.com/watch?v=vyBP7wpN72c[Network UPS Tools (NUT Server) Ultimate Guide] '(Techno Tim)' News articles and Press releases -------------------------------- 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 diff --git a/docs/nut.dict b/docs/nut.dict index badc3bfd88..eab32f0839 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 2917 utf-8 +personal_ws-1.1 en 2918 utf-8 AAS ACFAIL ACFREQ @@ -158,6 +158,7 @@ CBLimit CCC CCCC CDC +CDS CELLPADDING CELLSPACING CERTHOST @@ -471,6 +472,7 @@ IPP IPSS IPs IPv +IRC IRIX ITEMP ITy @@ -973,6 +975,7 @@ Repotec's Repoteck Richthof Rickard +Ridgway Riihikallio Rik RntmK @@ -1085,6 +1088,7 @@ Sicon Sidorov Signetic Silvino +Sinline Sistem Sistemas Slackware @@ -2601,14 +2605,11 @@ strarr strcasecmp strcat strchr -strcmp strcpy strdup strerror strftime strlen -strncasecmp -strncmp struct structs sts diff --git a/docs/packager-guide.txt b/docs/packager-guide.txt index d97b4fb06d..4730dcb2bb 100644 --- a/docs/packager-guide.txt +++ b/docs/packager-guide.txt @@ -171,6 +171,11 @@ FIXME: make a dependency graph - <> - <> - <> +- <> +- <> + +- <> (platform-dependent) +- <> (platform-dependent) - <> - <> @@ -261,6 +266,38 @@ nut-xml - Size: - Deps: +[[pkg-nut-ipmi]] +nut-ipmi +^^^^^^^ +- Desc: +- Files: +- Size: +- Deps: + +[[pkg-nut-modbus]] +nut-modbus +^^^^^^^^^^ +- Desc: +- Files: +- 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 ^^^^^^^^^^^ 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]. diff --git a/drivers/Makefile.am b/drivers/Makefile.am index 57e2afee3b..67650a9f99 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -55,6 +55,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) @@ -83,10 +85,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) @@ -196,7 +198,7 @@ LIBUSB_IMPL = libusb1.c endif USBHID_UPS_SUBDRIVERS = apc-hid.c arduino-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 powervar-hid.c delta_ups-hid.c legrand-hid.c salicru-hid.c + openups-hid.c powervar-hid.c delta_ups-hid.c ever-hid.c legrand-hid.c salicru-hid.c usbhid_ups_SOURCES = usbhid-ups.c libhid.c $(LIBUSB_IMPL) hidparser.c \ usb-common.c $(USBHID_UPS_SUBDRIVERS) usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm @@ -362,7 +364,8 @@ dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h arduino-hid.h \ nutdrv_qx_megatec.h nutdrv_qx_megatec-old.h nutdrv_qx_mustek.h nutdrv_qx_q1.h nutdrv_qx_hunnox.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-nmc-mib.h eaton-ats16-nm2-mib.h apc-ats-mib.h raritan-px2-mib.h eaton-ats30-mib.h \ - apc-pdu-mib.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h eaton-pdu-marlin-helpers.h \ + apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h eaton-pdu-marlin-helpers.h \ + apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h \ eaton-pdu-pulizzi-mib.h eaton-pdu-revelation-mib.h emerson-avocent-pdu-mib.h legrand-hid.h \ hpe-pdu-mib.h powervar-hid.h delta_ups-hid.h generic_modbus.h salicru-hid.h 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 eadf8fb054..3679a67641 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 5fb6c003ee..8e0d290990 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 921956ac44..bcd4ac802e 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 eb1d7d0548..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", @@ -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/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 d630aa6833..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 @@ -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/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 f9ada115f5..ad6aae5ff5 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 04c5b696e4..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); @@ -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..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 = { @@ -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/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 3264e2ada0..fd3263ef8c 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 4389184d7b..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 = { @@ -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/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 9e8eebf4ab..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 = { @@ -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..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 = { @@ -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/compaq-mib.c b/drivers/compaq-mib.c index b8b0252aff..ee618485ec 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 82c333e4c0..551746f019 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 18a0baa332..9e408b749f 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/dstate.c b/drivers/dstate.c index d5d5034fb5..50e4e2283b 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/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-nmc-mib.c b/drivers/eaton-ats16-nmc-mib.c index 4390604bfe..9d5403fed8 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 3424755adb..3e26d14626 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-pulizzi-mib.c b/drivers/eaton-pdu-pulizzi-mib.c index a9c9db8a16..b4a8976fd7 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 40bb651b64..7c4e022048 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 dfc9da5dab..72459c1083 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/ever-hid.c b/drivers/ever-hid.c new file mode 100644 index 0000000000..866fff96c3 --- /dev/null +++ b/drivers/ever-hid.c @@ -0,0 +1,786 @@ +/* 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 + * 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. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" /* must be first */ + +#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 + +/* ST Microelectronics */ +#define STMICRO_VENDORID 0x0483 + +/* USB IDs device table */ +static usb_device_id_t ever_usb_device_table[] = { + + { USB_DEVICE(STMICRO_VENDORID, 0xa113), NULL }, + { USB_DEVICE(EVER_VENDORID, 0xffff), NULL}, + + /* Terminating entry */ + { 0, 0, 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%02u", + (&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) +{ + NUT_UNUSED_VARIABLE(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) +{ + NUT_UNUSED_VARIABLE(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) +{ + NUT_UNUSED_VARIABLE(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) +{ + NUT_UNUSED_VARIABLE(value); + + int workmode_report_id = 74; + int workmode = -1; + 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]); + + 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) +{ + NUT_UNUSED_VARIABLE(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 */ + + /* 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", "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", "BUCK_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) +{ + NUT_UNUSED_VARIABLE(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", "SHORT-CIRCUIT"); + 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) +{ + NUT_UNUSED_VARIABLE(value); + + int workmode_report_id = 74; + int workmode = -1; + 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]); + + workmode = atoi(line); + + if(workmode != 0x04 && workmode != 0x08) + return "off"; + + return "!off"; +} + +static info_lkp_t ever_format_hardware[] = { + { 0, NULL, ever_format_hardware_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_format_version[] = { + { 0, NULL, ever_format_version_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_mac_address[] = { + { 0, NULL, ever_mac_address_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_ip_address[] = { + { 0, NULL, ever_ip_address_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_packets[] = { + { 0, NULL, ever_packets_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_workmode[] = { + { 0, NULL, ever_workmode_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_messages[] = { + { 0, NULL, ever_messages_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_alarms[] = { + { 0, NULL, ever_alarms_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ever_on_off_info[] = { + { 0, NULL, ever_on_off_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + + +/* 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[] = { + + /* 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*/ + /* { "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*/ + /* + { "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 }, + */ + /* 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*/ + /* { "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*/ + /* { "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 }, + /* 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 }, + + { "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 */ + { "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 }, + + /* 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, + fix_report_desc, +}; diff --git a/drivers/ever-hid.h b/drivers/ever-hid.h new file mode 100644 index 0000000000..bf47bc1997 --- /dev/null +++ b/drivers/ever-hid.h @@ -0,0 +1,32 @@ +/* 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 + * 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 + * 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/everups.c b/drivers/everups.c index cd2f7881f5..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,8 +20,8 @@ #include "main.h" #include "serial.h" -#define DRIVER_NAME "Ever UPS driver" -#define DRIVER_VERSION "0.03" +#define DRIVER_NAME "Ever UPS driver (serial)" +#define DRIVER_VERSION "0.04" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -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"; 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 ed4a0b6285..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 = { @@ -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/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 2caeed0308..3133b7aba7 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 8eefc06d5e..16aa8d494f 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 83e9e35eec..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 @@ -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/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 b1de168115..8763efecc5 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 8f1e357530..fa4a2bb7d0 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/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..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 = { @@ -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/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 de66cbb2e7..d30f7412bf 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 d8de4a3f71..df8af1485a 100644 --- a/drivers/mge-mib.c +++ b/drivers/mge-mib.c @@ -27,7 +27,7 @@ #include "mge-mib.h" -#define MGE_MIB_VERSION "0.54" +#define MGE_MIB_VERSION "0.55" /* 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 cc211bfc61..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 */ @@ -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 51c539a0eb..487f78cb1e 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -1254,7 +1254,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])); } @@ -1266,7 +1266,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])); } @@ -1286,7 +1286,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])); } @@ -1324,7 +1324,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])); } @@ -1336,7 +1336,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/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 8dc3b9dc39..e49057f4d3 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 f9ed8c74cb..e741649ffe 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 31529430b0..b354fef705 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" @@ -4000,7 +4000,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_masterguard.c b/drivers/nutdrv_qx_masterguard.c index ad91ddcf61..08168f69dd 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 = '?'; @@ -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; @@ -488,14 +489,15 @@ 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); } return 0; -ill: upsdebugx(2, "shutdown: illegal %s %s", name, val); +ill: + upsdebugx(2, "shutdown: illegal %s %s", name, val); return -1; } @@ -683,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 @@ -691,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 }, @@ -716,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 }, @@ -812,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] @@ -835,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 */ @@ -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; 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/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 8d0a499b7f..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 = { @@ -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/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 c092a85a7a..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 = { @@ -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..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 = { @@ -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/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 f4829b398c..aa52db3d8a 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "1.00" +#define PW_MIB_VERSION "1.01" /* TODO: more sysOID and MIBs support: * diff --git a/drivers/raritan-pdu-mib.c b/drivers/raritan-pdu-mib.c index 119ee677fd..210619b20b 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 772873788e..af8966255a 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..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.03" +#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); diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 0c99145d32..d6f27e2be2 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.05" +#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", "%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); + /* install handlers */ /* upsh.setvar = hid_set_value; setvar; */ @@ -1058,9 +1072,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); 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 eda5c1968c..7cf004c406 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -189,7 +189,7 @@ static const char *mibvers; #else # define DRIVER_NAME "Generic SNMP UPS driver" #endif /* WITH_DMFMIB */ -#define DRIVER_VERSION "1.17" +#define DRIVER_VERSION "1.18" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -905,13 +905,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 ((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", 2) == 0) { + else if (strcmp(version, "v3") == 0) { #ifdef __clang__ # pragma clang diagnostic pop #endif @@ -968,21 +968,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 (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 && authProtocol[3] == '\0') { + if (strcmp(authProtocol, "SHA") == 0) { g_snmp_sess.securityAuthProto = usmHMACSHA1AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/sizeof(oid); } @@ -1051,17 +1045,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 (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 && privProtocol[3] == '\0') { + if (strcmp(privProtocol, "AES") == 0) { g_snmp_sess.securityPrivProto = usmAESPrivProtocol; g_snmp_sess.securityPrivProtoLen = NUT_securityPrivProtoLen; } @@ -3992,7 +3984,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/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 ab67664498..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 = { @@ -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/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 fe923c346b..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 = { @@ -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/usbhid-ups.c b/drivers/usbhid-ups.c index 5d9de373f1..f08700d4db 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" @@ -47,6 +47,7 @@ #include "belkin-hid.h" #include "cps-hid.h" #include "delta_ups-hid.h" + #include "ever-hid.h" #include "idowell-hid.h" #include "legrand-hid.h" #include "liebert-hid.h" @@ -69,6 +70,7 @@ static subdriver_t *subdriver_list[] = { &belkin_subdriver, &cps_subdriver, &delta_ups_subdriver, + &ever_subdriver, &idowell_subdriver, &legrand_subdriver, &liebert_subdriver, diff --git a/drivers/victronups.c b/drivers/victronups.c index 71fa29345e..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 = { @@ -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/drivers/xppc-mib.c b/drivers/xppc-mib.c index 9b08d3808d..f386ba5495 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" 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 diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules index fa44253a94..e709b7e15c 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}="ST Microelectronics" ATTRS{idVendor}=="04b3", ENV{UPOWER_VENDOR}="IBM" ATTRS{idVendor}=="04d8", ENV{UPOWER_VENDOR}="Minibox" ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin" @@ -39,6 +40,7 @@ ATTRS{idVendor}=="1cb0", ENV{UPOWER_VENDOR}="Legrand" ATTRS{idVendor}=="2341", ENV{UPOWER_VENDOR}="Arduino" ATTRS{idVendor}=="2A03", ENV{UPOWER_VENDOR}="Arduino" ATTRS{idVendor}=="2b2d", ENV{UPOWER_VENDOR}="AEG" +ATTRS{idVendor}=="2e51", ENV{UPOWER_VENDOR}="Ever" ATTRS{idVendor}=="2e66", ENV{UPOWER_VENDOR}="Salicru" ATTRS{idVendor}=="4234", ENV{UPOWER_VENDOR}="Powervar" @@ -64,6 +66,9 @@ ATTRS{idVendor}=="0463", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups # Dell ATTRS{idVendor}=="047c", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" +# ST Microelectronics +ATTRS{idVendor}=="0483", ATTRS{idProduct}=="a113", ENV{UPOWER_BATTERY_TYPE}="ups" + # IBM ATTRS{idVendor}=="04b3", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" @@ -172,6 +177,9 @@ ATTRS{idVendor}=="2A03", ATTRS{idProduct}=="8040", 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" + # Salicru ATTRS{idVendor}=="2e66", ATTRS{idProduct}=="0201", ENV{UPOWER_BATTERY_TYPE}="ups" ATTRS{idVendor}=="2e66", ATTRS{idProduct}=="0202", ENV{UPOWER_BATTERY_TYPE}="ups" 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 d49c954ee0..0da36716f0 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -592,10 +592,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 4b4a436736..1f95b3a25d 100644 --- a/tools/nut-scanner/scan_snmp.c +++ b/tools/nut-scanner/scan_snmp.c @@ -798,14 +798,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 (strcmp(sec->authProtocol, "SHA") == 0) { snmp_sess->securityAuthProto = nut_usmHMACSHA1AuthProtocol; snmp_sess->securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/ @@ -841,7 +835,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 @@ -898,10 +892,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 (strcmp(sec->privProtocol, "AES") == 0) { snmp_sess->securityPrivProto = nut_usmAESPrivProtocol; snmp_sess->securityPrivProtoLen = sizeof(usmAESPrivProtocol)/ @@ -930,7 +922,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