mirror of
http://git.openwrt.org/packages.git
synced 2025-01-09 04:19:54 +08:00
nut: moved to github
git-svn-id: svn://svn.openwrt.org/openwrt/packages@42928 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
a520691565
commit
39376b76ab
@ -1,302 +0,0 @@
|
||||
#
|
||||
# Copyright © 2006-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=nut
|
||||
PKG_VERSION:=2.6.5
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.6/
|
||||
PKG_MD5SUM:=e6eac4fa04baff0d0a827d64efe81a7e
|
||||
|
||||
PKG_BUILD_DEPENDS:=libusb-compat libnetsnmp
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_INSTALL:=1
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
define Package/nut/Default
|
||||
URL:=http://www.networkupstools.org/
|
||||
TITLE:= Network UPS Tools
|
||||
DEPENDS:=@USB_SUPPORT +libnetsnmp +libpthread
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
endef
|
||||
|
||||
define Package/nut/description
|
||||
Network UPS Tools (NUT) is a client/server monitoring system that
|
||||
allows computers to share uninterruptible power supply (UPS) and
|
||||
power distribution unit (PDU) hardware. Clients access the hardware
|
||||
through the server, and are notified whenever the power status
|
||||
changes.
|
||||
endef
|
||||
|
||||
define Package/nut
|
||||
$(call Package/nut/Default)
|
||||
MENU:=1
|
||||
# TITLE+= (common)
|
||||
endef
|
||||
|
||||
define Package/nut-server
|
||||
$(call Package/nut/Default)
|
||||
TITLE+= (server)
|
||||
DEPENDS+= nut
|
||||
endef
|
||||
|
||||
define Package/nut-client
|
||||
$(call Package/nut/Default)
|
||||
TITLE+= (client)
|
||||
DEPENDS+= nut
|
||||
endef
|
||||
|
||||
define Package/nut-logger
|
||||
$(call Package/nut/Default)
|
||||
TITLE+= (logger)
|
||||
DEPENDS+= nut
|
||||
endef
|
||||
|
||||
define Package/nut-monitor
|
||||
$(call Package/nut/Default)
|
||||
TITLE+= (monitor)
|
||||
DEPENDS+= nut
|
||||
endef
|
||||
|
||||
define Package/nut/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/nut
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/nut.conf.sample $(1)/etc/nut/nut.conf
|
||||
ln -sf /var/run/ups.conf $(1)/etc/nut/ups.conf
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib* $(1)/usr/lib
|
||||
endef
|
||||
|
||||
define Package/nut/conffiles
|
||||
/etc/nut/nut.conf
|
||||
endef
|
||||
|
||||
define Package/nut-client/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin
|
||||
endef
|
||||
|
||||
define Package/nut-server/install
|
||||
$(INSTALL_DIR) $(1)/etc/nut
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/lib/nut
|
||||
$(INSTALL_DIR) $(1)/usr/share/nut
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/ups.init $(1)/etc/init.d/ups
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/lib/nut/upsdrvctl $(1)/lib/nut
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.conf.sample $(1)/etc/nut/upsd.conf
|
||||
ln -sf /var/run/upsd.users $(1)/etc/nut/upsd.users
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/cmdvartab
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/driver.list
|
||||
endef
|
||||
|
||||
define Package/nut-server/conffiles
|
||||
/etc/nut/upsd.conf
|
||||
endef
|
||||
|
||||
define Package/nut-logger/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin
|
||||
endef
|
||||
|
||||
define Package/nut-monitor/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/nut
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/upsmon.init $(1)/etc/init.d/upsmon
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin
|
||||
ln -sf /var/run/upsmon.conf $(1)/etc/nut/upsmon.conf
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf
|
||||
endef
|
||||
|
||||
define Package/nut-monitor/conffiles
|
||||
/etc/nut/upssched.conf
|
||||
endef
|
||||
|
||||
define DriverPackage
|
||||
define Package/nut-driver-$(1)
|
||||
$(call Package/nut/Default)
|
||||
TITLE += ($(1) driver)
|
||||
DEPENDS += nut nut-server
|
||||
ifeq ($(1),$(filter $(1),$(USB_LIBUSB_DRIVERLIST)))
|
||||
DEPENDS+=libusb-compat
|
||||
endif
|
||||
ifeq ($(1),$(filter $(1),$(SNMP_DRIVERLIST)))
|
||||
DEPENDS+=libnetsnmp
|
||||
endif
|
||||
endef
|
||||
# Deliberately empty (well, some spaces) in order to trigger a build
|
||||
# failure. It should be overridden by the list below, and when updating
|
||||
# to a new version of nut we will need to provide descriptions for any
|
||||
# new drivers.
|
||||
define Package/nut-driver-$(1)/description
|
||||
|
||||
endef
|
||||
define Package/nut-driver-$(1)/install
|
||||
$(INSTALL_DIR) $$(1)/lib/nut/
|
||||
$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/lib/nut/$(1) $$(1)/lib/nut/
|
||||
ifeq ($(1),clone)
|
||||
# Bundle clone and clone-outlet together
|
||||
$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/lib/nut/$(1)-outlet $$(1)/lib/nut/
|
||||
endif
|
||||
endef
|
||||
endef
|
||||
|
||||
# These lists are lifted *directly* from drivers/Makefile.am in the nut
|
||||
# source tree. This it to make it simpler to keep in sync when updating
|
||||
# to a newer version of nut. Do not edit this manually.
|
||||
#
|
||||
# DO NOT EDIT (except to update with a fresh cut/paste)!
|
||||
SERIAL_DRIVERLIST = bcmxcp belkin belkinunv bestfcom \
|
||||
bestfortress bestuferrups bestups dummy-ups etapro everups \
|
||||
gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \
|
||||
oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \
|
||||
safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
|
||||
blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old
|
||||
SNMP_DRIVERLIST = snmp-ups
|
||||
USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
|
||||
blazer_usb richcomm_usb
|
||||
# END: DO NOT EDIT!
|
||||
|
||||
NUT_DRIVERS := $(filter-out skel clone-outlet,$(SERIAL_DRIVERLIST)) \
|
||||
$(USB_LIBUSB_DRIVERLIST) $(SNMP_DRIVERLIST)
|
||||
|
||||
$(foreach d,$(NUT_DRIVERS),$(eval $(call DriverPackage,$(d))))
|
||||
|
||||
define DriverDescription
|
||||
define Package/nut-driver-$(1)/description
|
||||
$(2)
|
||||
endef
|
||||
endef
|
||||
|
||||
$(eval $(call DriverDescription,apcsmart,\
|
||||
Driver for American Power Conversion Smart Protocol UPS equipment))
|
||||
$(eval $(call DriverDescription,apcsmart-old,\
|
||||
Driver for American Power Conversion Smart Protocol UPS equipment))
|
||||
$(eval $(call DriverDescription,bcmxcp,\
|
||||
Driver for UPSes supporting the serial BCM/XCP protocol))
|
||||
$(eval $(call DriverDescription,bcmxcp_usb,\
|
||||
Experimental driver for UPSes supporting the BCM/XCP protocol over USB))
|
||||
$(eval $(call DriverDescription,belkin,\
|
||||
Driver for Belkin serial UPS equipment))
|
||||
$(eval $(call DriverDescription,belkinunv,\
|
||||
Driver for Belkin "Universal UPS" and compatible))
|
||||
$(eval $(call DriverDescription,bestfcom,\
|
||||
Driver for Best Power Fortress/Ferrups))
|
||||
$(eval $(call DriverDescription,bestfortress,\
|
||||
Driver for old Best Fortress UPS equipment))
|
||||
$(eval $(call DriverDescription,bestuferrups,\
|
||||
Driver for Best Power Micro-Ferrups))
|
||||
$(eval $(call DriverDescription,bestups,\
|
||||
Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment))
|
||||
$(eval $(call DriverDescription,blazer_ser,\
|
||||
Driver for Megatec/Q1 protocol serial))
|
||||
$(eval $(call DriverDescription,blazer_usb,\
|
||||
Driver for Megatec/Q1 protocol USB))
|
||||
$(eval $(call DriverDescription,clone,\
|
||||
UPS driver clone))
|
||||
$(eval $(call DriverDescription,dummy-ups,\
|
||||
Driver for multi-purpose UPS emulation))
|
||||
$(eval $(call DriverDescription,etapro,\
|
||||
Driver for ETA UPS equipment))
|
||||
$(eval $(call DriverDescription,everups,\
|
||||
Driver for Ever UPS models))
|
||||
$(eval $(call DriverDescription,gamatronic,\
|
||||
Driver for Gamatronic UPS equipment))
|
||||
$(eval $(call DriverDescription,genericups,\
|
||||
Driver for contact-closure UPS equipment))
|
||||
$(eval $(call DriverDescription,isbmex,\
|
||||
Driver for ISBMEX UPS equipment))
|
||||
$(eval $(call DriverDescription,ivtscd,\
|
||||
driver for the IVT Solar Controller Device))
|
||||
$(eval $(call DriverDescription,liebert,\
|
||||
Driver for Liebert contact-closure UPS equipment))
|
||||
$(eval $(call DriverDescription,liebert-esp2,\
|
||||
Driver for Liebert UPS using the ESP-II protocol))
|
||||
$(eval $(call DriverDescription,masterguard,\
|
||||
Driver for Masterguard UPS equipment))
|
||||
$(eval $(call DriverDescription,metasys,\
|
||||
Driver for Meta System UPS equipment))
|
||||
$(eval $(call DriverDescription,mge-shut,\
|
||||
Driver for SHUT Protocol UPS equipment))
|
||||
$(eval $(call DriverDescription,mge-utalk,\
|
||||
Driver for MGE UPS SYSTEMS UTalk protocol equipment))
|
||||
$(eval $(call DriverDescription,microdowell,\
|
||||
Driver for Microdowell Enterprise UPS series))
|
||||
$(eval $(call DriverDescription,oldmge-shut,\
|
||||
Driver for SHUT Protocol UPS equipment))
|
||||
$(eval $(call DriverDescription,oneac,\
|
||||
Driver for Oneac UPS equipment))
|
||||
$(eval $(call DriverDescription,optiups,\
|
||||
Driver for Opti-UPS (Viewsonice) UPS and Zinto D (ONLINE-USV) equipment))
|
||||
$(eval $(call DriverDescription,powercom,\
|
||||
UPS driver for Powercom/Trust/Advice UPS equipment))
|
||||
$(eval $(call DriverDescription,powerpanel,\
|
||||
Driver for PowerPanel Plus compatible UPS equipment))
|
||||
$(eval $(call DriverDescription,rhino,\
|
||||
Driver for Brazilian Microsol RHINO UPS equipment))
|
||||
$(eval $(call DriverDescription,richcomm_usb,\
|
||||
Driver UPS equipment using Richcomm dry-contact to USB solution))
|
||||
$(eval $(call DriverDescription,safenet,\
|
||||
Driver for SafeNet compatible UPS equipment))
|
||||
$(eval $(call DriverDescription,solis,\
|
||||
Driver for Brazilian Microsol SOLIS UPS equipment))
|
||||
$(eval $(call DriverDescription,tripplite,\
|
||||
Driver for Tripp-Lite SmartPro UPS equipment))
|
||||
$(eval $(call DriverDescription,tripplitesu,\
|
||||
Driver for Tripp-Lite SmartOnline (SU) UPS equipment))
|
||||
$(eval $(call DriverDescription,tripplite_usb,\
|
||||
Driver for older Tripp Lite USB UPSes (not PDC HID)))
|
||||
$(eval $(call DriverDescription,upscode2,\
|
||||
Driver for UPScode II compatible UPS equipment))
|
||||
$(eval $(call DriverDescription,usbhid-ups,\
|
||||
Driver for USB/HID UPS equipment))
|
||||
$(eval $(call DriverDescription,victronups,\
|
||||
Driver for IMV/Victron UPS unit Match, Match Lite, NetUps))
|
||||
$(eval $(call DriverDescription,snmp-ups,\
|
||||
Multi-MIB Driver for SNMP UPS equipment))
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--without-ssl \
|
||||
--with-pidpath=/var/run \
|
||||
--with-statepath=/var/run \
|
||||
--with-altpidpath=/var/run \
|
||||
--sysconfdir=/etc/nut \
|
||||
--with-drvpath=/lib/nut \
|
||||
--datadir=/usr/share/nut \
|
||||
--with-user=root \
|
||||
--with-group=root \
|
||||
--with-usb \
|
||||
--with-snmp \
|
||||
--without-libltdl \
|
||||
--with-dev
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,nut))
|
||||
$(eval $(call BuildPackage,nut-client))
|
||||
$(eval $(call BuildPackage,nut-server))
|
||||
$(eval $(call BuildPackage,nut-monitor))
|
||||
$(eval $(call BuildPackage,nut-logger))
|
||||
$(foreach d,$(NUT_DRIVERS),$(eval $(call BuildPackage,nut-driver-$(d))))
|
@ -1,87 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright © 2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
START=50
|
||||
|
||||
DEFAULT=/etc/default/nut
|
||||
RUN_D=/var/run
|
||||
PID_F=$RUN_D/upsd.pid
|
||||
UPS_C=$RUN_D/ups.conf
|
||||
USERS_C=$RUN_D/upsd.users
|
||||
|
||||
nut_user_add() {
|
||||
local cfg="$1"
|
||||
local a
|
||||
local val
|
||||
|
||||
config_get val "$cfg" username "$1"
|
||||
echo "[$val]" >> $USERS_C
|
||||
|
||||
config_get val "$cfg" password
|
||||
echo " password = $val" >> $USERS_C
|
||||
|
||||
config_get val "$cfg" actions
|
||||
for a in $val; do
|
||||
echo " actions = $a" >> $USERS_C
|
||||
done
|
||||
|
||||
config_get val "$cfg" instcmds
|
||||
for a in $val; do
|
||||
echo " instcmds = $a" >> $USERS_C
|
||||
done
|
||||
|
||||
config_get val "$cfg" upsmon
|
||||
if [ -n "$val" ]; then
|
||||
echo " upsmon $val" >> $USERS_C
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
local in_driver have_drivers
|
||||
config_cb() {
|
||||
if [ "$1" != "driver" ]; then
|
||||
in_driver=
|
||||
else
|
||||
echo "[$2]" >> $UPS_C
|
||||
in_driver=true
|
||||
have_drivers=true
|
||||
fi
|
||||
}
|
||||
option_cb() {
|
||||
if [ "$in_driver" = "true" ]; then
|
||||
echo " $1 = $2" >> $UPS_C
|
||||
fi
|
||||
}
|
||||
|
||||
[ -d $RUN_D ] || mkdir -p $RUN_D
|
||||
echo "# Config file automatically generated from UCI config" > $UPS_C
|
||||
echo "# Config file automatically generated from UCI config" > $USERS_C
|
||||
|
||||
config_load ups
|
||||
|
||||
config_foreach nut_user_add user
|
||||
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
if [ "$have_drivers" = "true" ]; then
|
||||
$DEBUG /usr/sbin/upsd $OPTIONS
|
||||
$DEBUG /lib/nut/upsdrvctl start
|
||||
fi
|
||||
}
|
||||
|
||||
nut_driver_stop() {
|
||||
local cfg="$1"
|
||||
local driver
|
||||
|
||||
config_get driver "$cfg" driver
|
||||
|
||||
[ -r /var/run/$driver-$cfg ] && /lib/nut/upsdrvctl stop $cfg
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -r $PID_F ] && /usr/sbin/upsd -c stop
|
||||
config_load ups
|
||||
config_foreach nut_driver_stop driver
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright © 2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
START=51
|
||||
|
||||
DEFAULT=/etc/default/nut
|
||||
RUN_D=/var/run
|
||||
PID_F=$RUN_D/upsmon.pid
|
||||
UPSMON_C=$RUN_D/upsmon.conf
|
||||
|
||||
nut_upsmon_conf() {
|
||||
local cfg="$1"
|
||||
|
||||
echo "# Config file automatically generated from UCI config" > $UPSMON_C
|
||||
|
||||
config_get val "$cfg" runas
|
||||
[ -n "$val" ] && echo "RUN_AS_USER $val" >> $PSMON_C
|
||||
|
||||
config_get val "$cfg" minsupplies 1
|
||||
echo "MINSUPPLIES $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" shutdowncmd "/sbin/halt"
|
||||
echo "SHUTDOWNCMD \"$val\"" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" notifycmd
|
||||
[ -n "$val" ] && echo "NOTIFYCMD \"$val\"" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" pollfreq 5
|
||||
echo "POLLFREQ $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" pollfreqalert 5
|
||||
echo "POLLFREQALERT $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" hostsync 15
|
||||
echo "HOSTSYNC $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" deadtime 15
|
||||
echo "DEADTIME $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" powerdownflag /var/run/killpower
|
||||
echo "POWERDOWNFLAG $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" onlinemsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG ONLINE \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" onbattmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG ONBATT \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" lowbattmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG LOWBATT \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" fsdmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG FSD \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" commokmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG COMMOK \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" commbadmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG COMMBAD \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" shutdownmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG SHUTDOWN \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" replbattmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG REPLBATT \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" nocommmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG NOCOMM \"$val\"" >> $UPSMON_C
|
||||
config_get val "$cfg" noparentmsg
|
||||
[ -n "$val" ] && echo "NOTIFYMSG NOPARENT \"$val\"" >> $UPSMON_C
|
||||
|
||||
local default
|
||||
config_get default "$cfg" defaultnotify SYSLOG
|
||||
config_get val "$cfg" onlinenotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG ONLINE $val" >> $UPSMON_C
|
||||
config_get val "$cfg" onbattnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG ONBATT $val" >> $UPSMON_C
|
||||
config_get val "$cfg" lowbattnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG LOWBATT $val" >> $UPSMON_C
|
||||
config_get val "$cfg" fsdnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG FSD $val" >> $UPSMON_C
|
||||
config_get val "$cfg" commoknotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG COMMOK $val" >> $UPSMON_C
|
||||
config_get val "$cfg" commbadnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG COMMBAD $val" >> $UPSMON_C
|
||||
config_get val "$cfg" shutdownnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG SHUTDOWN $val" >> $UPSMON_C
|
||||
config_get val "$cfg" replbattnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG REPLBATT $val" >> $UPSMON_C
|
||||
config_get val "$cfg" nocommnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG NOCOMM $val" >> $UPSMON_C
|
||||
config_get val "$cfg" noparentnotify "$default"
|
||||
[ -n "$val" ] && echo "NOTIFYFLAG NOPARENT $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" rbwarntime 43200
|
||||
echo "RBWARNTIME $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" nocommwarntime 300
|
||||
echo "NOCOMMWARNTIME $val" >> $UPSMON_C
|
||||
|
||||
config_get val "$cfg" finaldelay 5
|
||||
echo "FINALDELAY $val" >> $UPSMON_C
|
||||
}
|
||||
|
||||
nut_upsmon_add() {
|
||||
local cfg="$1"
|
||||
local type="$2"
|
||||
local upsname
|
||||
local hostname
|
||||
local port
|
||||
local powervalue
|
||||
local user
|
||||
local pass
|
||||
local system
|
||||
|
||||
# If no core config, use defaults
|
||||
[ -r $UPSMON_C ] || nut_upsmon_conf ""
|
||||
|
||||
config_get upsname "$cfg" upsname
|
||||
config_get hostname "$cfg" hostname localhost
|
||||
config_get port "$cfg" port
|
||||
config_get powervalue "$cfg" powervalue 1
|
||||
config_get user "$cfg" user
|
||||
config_get pass "$cfg" password
|
||||
system="$upsname@$hostname"
|
||||
if [ -n "$port" ]; then
|
||||
system="$system:$port";
|
||||
fi
|
||||
echo "MONITOR $system $powervalue $user $pass $type" >> $UPSMON_C
|
||||
}
|
||||
|
||||
start() {
|
||||
[ -d $RUN_D ] || mkdir -p $RUN_D
|
||||
rm -f $UPSMON_C
|
||||
|
||||
config_load upsmon
|
||||
|
||||
config_foreach nut_upsmon_conf upsmon
|
||||
config_foreach nut_upsmon_add master master
|
||||
config_foreach nut_upsmon_add slave slave
|
||||
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
$DEBUG /usr/sbin/upsmon $UPSMON_OPTIONS
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -r $PID_F ] && /usr/sbin/upsmon -c stop
|
||||
rm -f $UPSMON_C
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
--- nut-2.6.3.orig/drivers/Makefile.am 2011-12-05 16:36:46.000000000
|
||||
0100
|
||||
+++ nut-2.6.3/drivers/Makefile.am 2012-04-19 10:51:52.152059206 +0200
|
||||
@@ -165,7 +165,7 @@
|
||||
tripplite_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
|
||||
|
||||
bcmxcp_usb_SOURCES = bcmxcp_usb.c bcmxcp.c usb-common.c
|
||||
-bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
|
||||
+bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
|
||||
|
||||
blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c usb-common.c
|
@ -1,528 +0,0 @@
|
||||
From f8546df4c18c087eac829d3dfc097c919abb6d1c Mon Sep 17 00:00:00 2001
|
||||
From: aquette <aquette@72a954d1-e00c-0410-aa02-d9c7bb700a61>
|
||||
Date: Wed, 28 Nov 2012 21:44:21 +0000
|
||||
Subject: [PATCH] Official support for Minibox openUPS Intelligent UPS
|
||||
|
||||
Add a new usbhid-ups subdriver to handle Minibox openUPS Intelligent UPS
|
||||
(USB ID 0x04d8:0xd004) (patch from Nicu Pavel, Mini-Box.Com)
|
||||
|
||||
git-svn-id: svn://anonscm.debian.org/nut/trunk@3791 72a954d1-e00c-0410-aa02-d9c7bb700a61
|
||||
---
|
||||
data/driver.list.in | 2 +
|
||||
drivers/Makefile.am | 5 +-
|
||||
drivers/openups-hid.c | 360 +++++++++++++++++++++++++++++++++++++
|
||||
drivers/openups-hid.h | 38 ++++
|
||||
drivers/usbhid-ups.c | 5 +-
|
||||
scripts/upower/95-upower-hid.rules | 4 +
|
||||
6 files changed, 411 insertions(+), 3 deletions(-)
|
||||
create mode 100644 drivers/openups-hid.c
|
||||
create mode 100644 drivers/openups-hid.h
|
||||
|
||||
diff --git a/data/driver.list.in b/data/driver.list.in
|
||||
index 11014d6..70b5e0f 100644
|
||||
--- a/data/driver.list.in
|
||||
+++ b/data/driver.list.in
|
||||
@@ -645,6 +645,8 @@
|
||||
"Microsol" "ups" "5" "Rhino 10.0" "10000VA" "rhino"
|
||||
"Microsol" "ups" "5" "Rhino 20.0" "20000VA" "rhino"
|
||||
|
||||
+"Minibox" "ups" "5" "openUPS Intelligent UPS" "USB port" "usbhid-ups"
|
||||
+
|
||||
"Mustek" "ups" "2" "Powermust" "400VA Plus" "blazer_ser"
|
||||
"Mustek" "ups" "2" "Powermust" "600VA Plus" "blazer_ser"
|
||||
"Mustek" "ups" "2" "Powermust" "800VA Pro" "blazer_ser"
|
||||
diff --git a/drivers/Makefile.am b/drivers/Makefile.am
|
||||
index cd900cf..ad30874 100644
|
||||
--- a/drivers/Makefile.am
|
||||
+++ b/drivers/Makefile.am
|
||||
@@ -162,7 +162,8 @@ skel_LDADD = $(LDADD_DRIVERS)
|
||||
|
||||
# USB
|
||||
USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c explore-hid.c \
|
||||
- liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c
|
||||
+ liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \
|
||||
+ openups-hid.c
|
||||
usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \
|
||||
usb-common.c $(USBHID_UPS_SUBDRIVERS)
|
||||
usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
|
||||
@@ -245,7 +246,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \
|
||||
powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \
|
||||
safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \
|
||||
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h \
|
||||
- apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h
|
||||
+ apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h openups-hid.h
|
||||
|
||||
# Define a dummy library so that Automake builds rules for the
|
||||
# corresponding object files. This library is not actually built,
|
||||
diff --git a/drivers/openups-hid.c b/drivers/openups-hid.c
|
||||
new file mode 100644
|
||||
index 0000000..69a4a61
|
||||
--- /dev/null
|
||||
+++ b/drivers/openups-hid.c
|
||||
@@ -0,0 +1,360 @@
|
||||
+/* openups-hid.c - subdriver to monitor Minibox openUPS USB/HID devices with NUT
|
||||
+ *
|
||||
+ * Copyright (C)
|
||||
+ * 2003 - 2012 Arnaud Quette <ArnaudQuette@Eaton.com>
|
||||
+ * 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
+ * 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
+ * 2012 Nicu Pavel <npavel@mini-box.com>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
+ */
|
||||
+
|
||||
+#include "usbhid-ups.h"
|
||||
+#include "openups-hid.h"
|
||||
+#include "main.h" /* for getval() */
|
||||
+#include "usb-common.h"
|
||||
+
|
||||
+#define OPENUPS_HID_VERSION "openUPS HID 0.1"
|
||||
+
|
||||
+/* Minibox */
|
||||
+#define OPENUPS_VENDORID 0x04d8
|
||||
+
|
||||
+static char openups_scratch_buf[20];
|
||||
+
|
||||
+/* USB IDs device table */
|
||||
+static usb_device_id_t openups_usb_device_table[] = {
|
||||
+ /* openUPS Intelligent UPS (minimum required firmware 1.4) */
|
||||
+ {USB_DEVICE(OPENUPS_VENDORID, 0xd004), NULL},
|
||||
+
|
||||
+ /* Terminating entry */
|
||||
+ {-1, -1, NULL}
|
||||
+};
|
||||
+
|
||||
+/* Thermistor table used for temperature lookups
|
||||
+ * taken from the windows monitoring application
|
||||
+ */
|
||||
+static unsigned int therm_tbl[] =
|
||||
+{
|
||||
+ (unsigned int)0x31,
|
||||
+ (unsigned int)0x40,
|
||||
+ (unsigned int)0x53,
|
||||
+ (unsigned int)0x68,
|
||||
+ (unsigned int)0x82,
|
||||
+ (unsigned int)0xA0,
|
||||
+ (unsigned int)0xC3,
|
||||
+ (unsigned int)0xE9,
|
||||
+ (unsigned int)0x113,
|
||||
+ (unsigned int)0x13F,
|
||||
+ (unsigned int)0x16E,
|
||||
+ (unsigned int)0x19F,
|
||||
+ (unsigned int)0x1CF,
|
||||
+ (unsigned int)0x200,
|
||||
+ (unsigned int)0x22F,
|
||||
+ (unsigned int)0x25C,
|
||||
+ (unsigned int)0x286,
|
||||
+ (unsigned int)0x2AE,
|
||||
+ (unsigned int)0x2D3,
|
||||
+ (unsigned int)0x2F4,
|
||||
+ (unsigned int)0x312,
|
||||
+ (unsigned int)0x32D,
|
||||
+ (unsigned int)0x345,
|
||||
+ (unsigned int)0x35A,
|
||||
+ (unsigned int)0x36D,
|
||||
+ (unsigned int)0x37E,
|
||||
+ (unsigned int)0x38C,
|
||||
+ (unsigned int)0x399,
|
||||
+ (unsigned int)0x3A5,
|
||||
+ (unsigned int)0x3AF,
|
||||
+ (unsigned int)0x3B7,
|
||||
+ (unsigned int)0x3BF,
|
||||
+ (unsigned int)0x3C6,
|
||||
+ (unsigned int)0x3CC
|
||||
+};
|
||||
+
|
||||
+static unsigned int therm_tbl_size = sizeof(therm_tbl)/sizeof(therm_tbl[0]);
|
||||
+
|
||||
+static const char *openups_charging_fun(double value);
|
||||
+static const char *openups_discharging_fun(double value);
|
||||
+static const char *openups_online_fun(double value);
|
||||
+static const char *openups_nobattery_fun(double value);
|
||||
+static const char *openups_off_fun(double value);
|
||||
+
|
||||
+static const char *openups_scale_vin_fun(double value);
|
||||
+static const char *openups_scale_vout_fun(double value);
|
||||
+/* static const char *openups_scale_vbat_fun(double value); */
|
||||
+static const char *openups_scale_ccharge_fun(double value);
|
||||
+static const char *openups_scale_cdischarge_fun(double value);
|
||||
+static const char *openups_temperature_fun(double value);
|
||||
+
|
||||
+static info_lkp_t openups_charging_info[] = {
|
||||
+ {0, NULL, openups_charging_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_discharging_info[] = {
|
||||
+ {0, NULL, openups_discharging_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_online_info[] = {
|
||||
+ {0, NULL, openups_online_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_nobattery_info[] = {
|
||||
+ {0, NULL, openups_nobattery_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_off_info[] = {
|
||||
+ {0, NULL, openups_off_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_vin_info[] = {
|
||||
+ {0, NULL, openups_scale_vin_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_vout_info[] = {
|
||||
+ {0, NULL, openups_scale_vout_fun}
|
||||
+};
|
||||
+
|
||||
+/* static info_lkp_t openups_vbat_info[] = {
|
||||
+ {0, NULL, openups_scale_vbat_fun}
|
||||
+};*/
|
||||
+
|
||||
+static info_lkp_t openups_ccharge_info[] = {
|
||||
+ {0, NULL, openups_scale_ccharge_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_cdischarge_info[] = {
|
||||
+ {0, NULL, openups_scale_cdischarge_fun}
|
||||
+};
|
||||
+
|
||||
+static info_lkp_t openups_temperature_info[] = {
|
||||
+ {0, NULL, openups_temperature_fun}
|
||||
+};
|
||||
+
|
||||
+static const char *openups_charging_fun(double value)
|
||||
+{
|
||||
+ return value ? "chrg" : "!chrg";
|
||||
+}
|
||||
+
|
||||
+static const char *openups_discharging_fun(double value)
|
||||
+{
|
||||
+ return value ? "dischrg" : "!dischrg";
|
||||
+}
|
||||
+
|
||||
+static const char *openups_online_fun(double value)
|
||||
+{
|
||||
+ return value ? "online" : "!online";
|
||||
+}
|
||||
+
|
||||
+static const char *openups_nobattery_fun(double value)
|
||||
+{
|
||||
+ return value ? "nobattery" : "!nobattery";
|
||||
+}
|
||||
+
|
||||
+static const char *openups_off_fun(double value)
|
||||
+{
|
||||
+ return value ? "!off" : "off";
|
||||
+}
|
||||
+
|
||||
+static const char *openups_scale_vin_fun(double value)
|
||||
+{
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vin_scale);
|
||||
+ return openups_scratch_buf;
|
||||
+}
|
||||
+
|
||||
+static const char *openups_scale_vout_fun(double value)
|
||||
+{
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vout_scale);
|
||||
+ return openups_scratch_buf;
|
||||
+}
|
||||
+
|
||||
+/* static const char *openups_scale_vbat_fun(double value)
|
||||
+{
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vbat_scale);
|
||||
+ return openups_scratch_buf;
|
||||
+}*/
|
||||
+
|
||||
+static const char *openups_scale_ccharge_fun(double value)
|
||||
+{
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.3f", value * ccharge_scale);
|
||||
+ return openups_scratch_buf;
|
||||
+}
|
||||
+
|
||||
+static const char *openups_scale_cdischarge_fun(double value)
|
||||
+{
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.3f", value * cdischarge_scale);
|
||||
+ return openups_scratch_buf;
|
||||
+}
|
||||
+
|
||||
+static const char *openups_temperature_fun(double value)
|
||||
+{
|
||||
+ int i;
|
||||
+ int pos = -1;
|
||||
+ unsigned int thermistor = value * 100;
|
||||
+
|
||||
+ if (thermistor <= therm_tbl[0]) {
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", -40);
|
||||
+ } else {
|
||||
+ if (thermistor >= therm_tbl[therm_tbl_size - 1]) {
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", 125);
|
||||
+ } else {
|
||||
+ for (i = therm_tbl_size - 1; i >= 0; i--) {
|
||||
+ if (thermistor >= therm_tbl[i]) {
|
||||
+ pos = i;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (thermistor == therm_tbl[pos]) {
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", pos * 5 - 40);
|
||||
+ } else {
|
||||
+ int t1 = pos * 5 - 40;
|
||||
+ int t2 = (pos + 1) * 5 - 40;
|
||||
+
|
||||
+ unsigned int d1 = therm_tbl[pos];
|
||||
+ unsigned int d2 = therm_tbl[pos + 1];
|
||||
+
|
||||
+ float temp = (float) (thermistor - d1) * (t2 - t1) / (d2 - d1) + t1;
|
||||
+ snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", temp);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return openups_scratch_buf;
|
||||
+}
|
||||
+
|
||||
+/* --------------------------------------------------------------- */
|
||||
+/* Vendor-specific usage table */
|
||||
+/* --------------------------------------------------------------- */
|
||||
+
|
||||
+/* OPENUPS usage table */
|
||||
+static usage_lkp_t openups_usage_lkp[] = {
|
||||
+ {"Cell1", 0x00000001}, /* Battery cell 1 on J6 pin 1 */
|
||||
+ {"Cell2", 0x00000002}, /* Battery cell 2 on J6 pin 2 */
|
||||
+ {"Cell3", 0x00000003}, /* Battery cell 3 on J6 pin 3 */
|
||||
+ {"Cell4", 0x00000004}, /* Battery cell 4 on J6 pin 4 */
|
||||
+ {"Cell5", 0x00000005}, /* Battery cell 5 on J6 pin 5 */
|
||||
+ {"Cell6", 0x00000006}, /* Battery cell 6 on J4 pin 1 */
|
||||
+ /* Usage table for windows monitoring app only updates when
|
||||
+ * certain request codes are written to USB endpoint */
|
||||
+ /*{ "OpenUPSExtra", 0xff000001 }, */
|
||||
+ {NULL, 0}
|
||||
+};
|
||||
+
|
||||
+static usage_tables_t openups_utab[] = {
|
||||
+ openups_usage_lkp,
|
||||
+ hid_usage_lkp,
|
||||
+ NULL,
|
||||
+};
|
||||
+
|
||||
+/* --------------------------------------------------------------- */
|
||||
+/* HID2NUT lookup table */
|
||||
+/* --------------------------------------------------------------- */
|
||||
+
|
||||
+static hid_info_t openups_hid2nut[] = {
|
||||
+ {"ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", 0, stringid_conversion},
|
||||
+
|
||||
+ /* Battery */
|
||||
+ {"battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion},
|
||||
+ {"battery.mfr.date", 0, 0, "UPS.PowerSummary.iOEMInformation", NULL, "%s", 0, stringid_conversion},
|
||||
+ {"battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.2f", HU_FLAG_QUICK_POLL, NULL},
|
||||
+ /* { "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info }, */
|
||||
+ {"battery.current", 0, 0, "UPS.PowerSummary.Current", NULL, "%.3f", HU_FLAG_QUICK_POLL, NULL},
|
||||
+ {"battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL},
|
||||
+ {"battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
|
||||
+ {"battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
|
||||
+ {"battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL},
|
||||
+ {"battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
|
||||
+ {"battery.temperature", 0, 0, "UPS.PowerSummary.Temperature", NULL, NULL, HU_FLAG_QUICK_POLL, openups_temperature_info},
|
||||
+/* {"battery.cell1.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell1", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
+ {"battery.cell2.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell2", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
+ {"battery.cell3.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell3", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
+ {"battery.cell4.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell4", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
+ {"battery.cell5.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell5", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
+ {"battery.cell6.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell6", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
+*/
|
||||
+ /* Output */
|
||||
+ {"output.voltage", 0, 0, "UPS.PowerSummary.Output.Voltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vout_info},
|
||||
+ {"output.current", 0, 0, "UPS.PowerSummary.Output.Current", NULL, NULL, HU_FLAG_QUICK_POLL, openups_cdischarge_info},
|
||||
+
|
||||
+ /* Input */
|
||||
+ {"input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vin_info},
|
||||
+ {"input.current", 0, 0, "UPS.PowerSummary.Input.Current", NULL, NULL, HU_FLAG_QUICK_POLL, openups_ccharge_info},
|
||||
+
|
||||
+ /* Status */
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, HU_FLAG_QUICK_POLL, openups_off_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, HU_FLAG_QUICK_POLL, commfault_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, HU_FLAG_QUICK_POLL, overheat_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, HU_FLAG_QUICK_POLL, timelimitexpired_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, openups_charging_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, openups_discharging_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, openups_online_info},
|
||||
+ {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, HU_FLAG_QUICK_POLL, openups_nobattery_info},
|
||||
+
|
||||
+ /* end of structure. */
|
||||
+ {NULL, 0, 0, NULL, NULL, NULL, 0, NULL}
|
||||
+};
|
||||
+
|
||||
+static const char *openups_format_model(HIDDevice_t * hd)
|
||||
+{
|
||||
+ return hd->Product;
|
||||
+}
|
||||
+
|
||||
+static const char *openups_format_mfr(HIDDevice_t * hd)
|
||||
+{
|
||||
+ return hd->Vendor ? hd->Vendor : "openUPS";
|
||||
+}
|
||||
+
|
||||
+static const char *openups_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 openups_claim(HIDDevice_t * hd)
|
||||
+{
|
||||
+ int status = is_usb_device_supported(openups_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("openUPS", hd);
|
||||
+ return 0;
|
||||
+
|
||||
+ case SUPPORTED:
|
||||
+ return 1;
|
||||
+
|
||||
+ case NOT_SUPPORTED:
|
||||
+ default:
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+subdriver_t openups_subdriver = {
|
||||
+ OPENUPS_HID_VERSION,
|
||||
+ openups_claim,
|
||||
+ openups_utab,
|
||||
+ openups_hid2nut,
|
||||
+ openups_format_model,
|
||||
+ openups_format_mfr,
|
||||
+ openups_format_serial,
|
||||
+};
|
||||
diff --git a/drivers/openups-hid.h b/drivers/openups-hid.h
|
||||
new file mode 100644
|
||||
index 0000000..c87b3d1
|
||||
--- /dev/null
|
||||
+++ b/drivers/openups-hid.h
|
||||
@@ -0,0 +1,38 @@
|
||||
+/* openups-hid.h - subdriver to monitor Minibox openUPS USB/HID devices with NUT
|
||||
+ *
|
||||
+ * Copyright (C)
|
||||
+ * 2003 - 2009 Arnaud Quette <ArnaudQuette@Eaton.com>
|
||||
+ * 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
+ * 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
+ * 2012 Nicu Pavel <npavel@mini-box.com>
|
||||
+ *
|
||||
+ * 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 OPENUPS_HID_H
|
||||
+#define OPENUPS_HID_H
|
||||
+
|
||||
+#include "usbhid-ups.h"
|
||||
+
|
||||
+/* constants for converting HID read values to real values */
|
||||
+static const float vin_scale = 0.03545 * 100;
|
||||
+static const float vout_scale = 0.02571 * 100;
|
||||
+static const float vbat_scale = 0.00857 * 100;
|
||||
+static const float ccharge_scale = 0.8274 / 10;
|
||||
+static const float cdischarge_scale = 16.113 / 10;
|
||||
+
|
||||
+extern subdriver_t openups_subdriver;
|
||||
+
|
||||
+#endif /* OPENUPS_HID_H */
|
||||
diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c
|
||||
index 2d254c4..fcf628d 100644
|
||||
--- a/drivers/usbhid-ups.c
|
||||
+++ b/drivers/usbhid-ups.c
|
||||
@@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#define DRIVER_NAME "Generic HID driver"
|
||||
-#define DRIVER_VERSION "0.37"
|
||||
+#define DRIVER_VERSION "0.38"
|
||||
|
||||
#include "main.h"
|
||||
#include "libhid.h"
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
/* include all known subdrivers */
|
||||
#include "mge-hid.h"
|
||||
+
|
||||
#ifndef SHUT_MODE
|
||||
#include "explore-hid.h"
|
||||
#include "apc-hid.h"
|
||||
@@ -46,6 +47,7 @@
|
||||
#include "powercom-hid.h"
|
||||
#include "tripplite-hid.h"
|
||||
#include "idowell-hid.h"
|
||||
+ #include "openups-hid.h"
|
||||
#endif
|
||||
|
||||
/* master list of avaiable subdrivers */
|
||||
@@ -62,6 +64,7 @@ static subdriver_t *subdriver_list[] = {
|
||||
&powercom_subdriver,
|
||||
&tripplite_subdriver,
|
||||
&idowell_subdriver,
|
||||
+ &openups_subdriver,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules
|
||||
index a9e18fe..c57ef75 100644
|
||||
--- a/scripts/upower/95-upower-hid.rules
|
||||
+++ b/scripts/upower/95-upower-hid.rules
|
||||
@@ -15,6 +15,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}=="04d8", ENV{UPOWER_VENDOR}="Minibox"
|
||||
ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin"
|
||||
ATTRS{idVendor}=="051d", ENV{UPOWER_VENDOR}="APC"
|
||||
ATTRS{idVendor}=="0592", ENV{UPOWER_VENDOR}="Powerware"
|
||||
@@ -47,6 +48,9 @@ ATTRS{idVendor}=="0463", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups
|
||||
# Dell
|
||||
ATTRS{idVendor}=="047c", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups"
|
||||
|
||||
+# Minibox
|
||||
+ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="d004", ENV{UPOWER_BATTERY_TYPE}="ups"
|
||||
+
|
||||
# Belkin
|
||||
ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0375", ENV{UPOWER_BATTERY_TYPE}="ups"
|
||||
ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0551", ENV{UPOWER_BATTERY_TYPE}="ups"
|
||||
--
|
||||
1.8.0
|
||||
|
@ -1,35 +0,0 @@
|
||||
--- nut-2.6.5/drivers/openups-hid.c~ 2012-12-06 15:07:29.000000000 +0000
|
||||
+++ nut-2.6.5/drivers/openups-hid.c 2012-12-06 15:14:45.541936770 +0000
|
||||
@@ -329,24 +329,18 @@ static const char *openups_format_serial
|
||||
* the device is supported by this subdriver, else 0. */
|
||||
static int openups_claim(HIDDevice_t * hd)
|
||||
{
|
||||
- int status = is_usb_device_supported(openups_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("openUPS", hd);
|
||||
+ if (hd->VendorID != OPENUPS_VENDORID)
|
||||
return 0;
|
||||
|
||||
- case SUPPORTED:
|
||||
+ if (hd->ProductID == 0xd004)
|
||||
return 1;
|
||||
|
||||
- case NOT_SUPPORTED:
|
||||
- default:
|
||||
- return 0;
|
||||
- }
|
||||
+ /* by default, reject, unless the productid option is given */
|
||||
+ if (getval("productid"))
|
||||
+ return 1;
|
||||
+
|
||||
+ possibly_supported("openUPS", hd);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
subdriver_t openups_subdriver = {
|
Loading…
Reference in New Issue
Block a user