-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2117 from jimklimov/issue-2063
Follow-up for `apc_modbus` driver
- Loading branch information
Showing
2 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
# is to just pick out some strings relevant for tracking config changes. | ||
# | ||
# Copyright (C) 2016-2020 Eaton | ||
# Copyright (C) 2020-2022 Jim Klimov <[email protected]> | ||
# Copyright (C) 2020-2023 Jim Klimov <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -171,7 +171,7 @@ fi | |
# Cache needed bits of ups.conf to speed up later parsing. Note that these | ||
# data are needed for most operations, and populated by upslist_readFile() | ||
UPSCONF_DATA="" | ||
# Subset of normalized data above that only has sections, drivers and ports | ||
# Subset of normalized data above that only has sections, drivers and ports (SDP) | ||
UPSCONF_DATA_SDP="" | ||
|
||
# List of configured UPSes in the config-file | ||
|
@@ -479,8 +479,45 @@ upsconf_getDriverMedia() { | |
# particular system's physics, both serial and network media may need USB). | ||
CURR_DRV="`upsconf_getDriver "$1"`" || return $? | ||
case "$CURR_DRV" in | ||
*netxml*|*snmp*|*ipmi*|*powerman*|*-mib*|*avahi*|*apcupsd*) | ||
*netxml*|*snmp*|*ipmi*|*powerman*|*-mib*|*avahi*) | ||
printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; | ||
*apcupsd-ups*) | ||
# Relay from a nearby apcupsd network server into NUT ecosystem: | ||
CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" | ||
case "$CURR_PORT" in | ||
*localhost*|*127.0.0.1*|*::1*) | ||
printf '%s\n%s\n' "$CURR_DRV" "network-localhost" ; return ;; | ||
*) | ||
printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; | ||
esac | ||
;; | ||
*apc_modbus*) | ||
CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" | ||
CURR_PORTTYPE="`upsconf_getValue "$1" 'porttype'`" || CURR_PORTTYPE="" | ||
case "$CURR_PORTTYPE" in | ||
*usb*) | ||
printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; | ||
*serial*) | ||
printf '%s\n%s\n' "$CURR_DRV" "serial" ; return ;; | ||
*) # default depends on driver build (against libmodbus | ||
# version with or without support for usb) | ||
# TOTHINK: Check for presence of config values like | ||
# vendorid (USB) or baud (Serial)? They are optional | ||
# with reasonable defaults anyway... | ||
case "$CURR_PORT" in | ||
*auto*) | ||
printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; | ||
/*) | ||
printf '%s\n%s\n' "$CURR_DRV" "serial" ; return ;; | ||
*localhost*|*127.0.0.1*|*::1*) | ||
printf '%s\n%s\n' "$CURR_DRV" "network-localhost" ; return ;; | ||
*) | ||
printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; | ||
esac | ||
# returns are above, but just in case - have a fallback: | ||
printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; | ||
esac | ||
;; | ||
*usb*) | ||
printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; | ||
nutdrv_qx) # May be direct serial or USB | ||
|