Imported Upstream version 2.6.0

This commit is contained in:
arnaud.quette@free.fr 2011-01-26 10:35:08 +01:00
parent 26fb71b504
commit 459aaf9392
510 changed files with 40508 additions and 18859 deletions

View file

@ -1,8 +1,9 @@
# Network UPS Tools: drivers
# by default, link programs in this directory with libcommon.a
# by default, link programs in this directory with libcommon.la
# (libtool version of the static lib, in order to access LTLIBOBJS)
#FIXME: SERLIBS is only useful for LDADD_DRIVERS_SERIAL not for LDADD_COMMON
LDADD_COMMON = ../common/libcommon.a ../common/libparseconf.la
LDADD_COMMON = ../common/libcommon.la ../common/libparseconf.la
LDADD_DRIVERS = $(LDADD_COMMON) main.o dstate.o
LDADD_HAL_DRIVERS = $(LDADD_COMMON) libnuthalmain.a
LDADD_DRIVERS_SERIAL = $(LDADD_DRIVERS) $(SERLIBS) serial.o
@ -31,16 +32,16 @@ endif
SERIAL_DRIVERLIST = apcsmart bcmxcp belkin belkinunv bestfcom \
bestfortress bestuferrups bestups dummy-ups etapro everups \
gamatronic genericups isbmex liebert liebertgxt2 masterguard megatec metasys \
gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \
mge-shut mge-utalk microdowell newmge-shut oneac optiups powercom rhino \
safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
blazer_ser clone clone-outlet ivtscd
SNMP_DRIVERLIST = snmp-ups
USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb megatec_usb \
USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
blazer_usb richcomm_usb
USB_DRIVERLIST = $(USB_LIBUSB_DRIVERLIST)
HAL_DRIVERLIST = hald-addon-usbhid-ups hald-addon-bcmxcp_usb \
hald-addon-tripplite_usb hald-addon-megatec_usb
hald-addon-tripplite_usb hald-addon-blazer_usb
NEONXML_DRIVERLIST = netxml-ups
# distribute all drivers, even ones that are not built by default
@ -87,6 +88,7 @@ upsdrvctl_LDADD = $(LDADD_COMMON)
# serial drivers: all of them use standard LDADD and CFLAGS
apcsmart_SOURCES = apcsmart.c
bcmxcp_SOURCES = bcmxcp.c bcmxcp_ser.c
bcmxcp_LDADD = $(LDADD) -lm
belkin_SOURCES = belkin.c
belkinunv_SOURCES = belkinunv.c
bestfcom_SOURCES = bestfcom.c
@ -102,9 +104,8 @@ isbmex_SOURCES = isbmex.c
isbmex_LDADD = $(LDADD) -lm
ivtscd_SOURCES = ivtscd.c
liebert_SOURCES = liebert.c
liebertgxt2_SOURCES = liebertgxt2.c
liebert_esp2_SOURCES = liebert-esp2.c
masterguard_SOURCES = masterguard.c
megatec_SOURCES = megatec.c
metasys_SOURCES = metasys.c
mge_shut_SOURCES = mge-shut.c hidparser.c
mge_utalk_SOURCES = mge-utalk.c
@ -134,7 +135,7 @@ dummy_ups_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/clients
dummy_ups_LDADD = $(LDADD_DRIVERS) ../clients/libupsclient.la
if WITH_SSL
dummy_ups_CFLAGS += $(LIBSSL_CFLAGS)
dummy_ups_LDADD += $(LIBSSL_LDFLAGS)
dummy_ups_LDADD += $(LIBSSL_LIBS)
endif
# Clone drivers
@ -148,26 +149,22 @@ 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
liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-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_LDFLAGS)
usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
tripplite_usb_SOURCES = tripplite_usb.c libusb.c usb-common.c
tripplite_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS) -lm
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_LDFLAGS)
megatec_usb_SOURCES = megatec.c megatec_usb.c libusb.c usb-common.c
megatec_usb_CFLAGS = $(AM_CFLAGS) -DMEGATEC_SUBDRV
megatec_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS)
bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c usb-common.c
blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS) -lm
blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
richcomm_usb_SOURCES = richcomm_usb.c usb-common.c
richcomm_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS)
richcomm_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
# HID-over-serial
newmge_shut_SOURCES = usbhid-ups.c libshut.c libhid.c hidparser.c mge-hid.c
@ -177,31 +174,31 @@ newmge_shut_LDADD = $(LDADD)
# SNMP
snmp_ups_SOURCES = snmp-ups.c apc-mib.c baytech-mib.c compaq-mib.c eaton-mib.c \
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LDFLAGS)
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c \
bestpower-mib.c
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
# HAL
hald_addon_usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \
$(USBHID_UPS_SUBDRIVERS)
hald_addon_usbhid_ups_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS)
hald_addon_usbhid_ups_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS)
hald_addon_tripplite_usb_SOURCES = tripplite_usb.c libusb.c
hald_addon_tripplite_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS) -lm
hald_addon_tripplite_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS) -lm
hald_addon_bcmxcp_usb_SOURCES = bcmxcp_usb.c bcmxcp.c
hald_addon_bcmxcp_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS)
hald_addon_bcmxcp_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS)
hald_addon_megatec_usb_SOURCES = megatec.c megatec_usb.c libusb.c
hald_addon_megatec_usb_CFLAGS = $(AM_CFLAGS) -DMEGATEC_SUBDRV
hald_addon_megatec_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS)
hald_addon_blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c
hald_addon_blazer_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS) -lm
# NEON XML/HTTP
netxml_ups_SOURCES = netxml-ups.c mge-xml.c
netxml_ups_LDADD = $(LDADD_DRIVERS) $(LIBNEON_LDFLAGS)
netxml_ups_LDADD = $(LDADD_DRIVERS) $(LIBNEON_LIBS)
# Powerman
powerman_pdu_SOURCES = powerman-pdu.c
powerman_pdu_LDADD = $(LDADD) $(LIBPOWERMAN_LDFLAGS)
powerman_pdu_LDADD = $(LDADD) $(LIBPOWERMAN_LIBS)
# ----------------------------------------------------------------------
# List of header files. The purpose of this list is not dependency
@ -209,14 +206,14 @@ powerman_pdu_LDADD = $(LDADD) $(LIBPOWERMAN_LDFLAGS)
# distributed by "make dist".
dist_noinst_HEADERS = apc-mib.h apc-hid.h apcsmart.h baytech-mib.h bcmxcp.h \
bcmxcp_io.h belkin.h belkin-hid.h blazer.h cps-hid.h dstate.h dstate-hal.h \
dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \
bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \
dstate-hal.h dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \
hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h libusb.h liebert-hid.h \
main.h main-hal.h megatec.h mge-hid.h mge-mib.h mge-shut.h mge-utalk.h \
main.h main-hal.h mge-hid.h mge-mib.h mge-shut.h mge-utalk.h \
mge-xml.h microdowell.h netvision-mib.h netxml-ups.h oneac.h \
powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \
safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h
# Define a dummy library so that Automake builds rules for the
# corresponding object files. This library is not actually built,

View file

@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.11 from Makefile.am.
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@ -62,17 +62,18 @@ EXTRA_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_4) \
@SOME_DRIVERS_FALSE@@WITH_NEONXML_TRUE@am__append_9 = $(NEONXML_DRIVERLIST)
@SOME_DRIVERS_FALSE@@WITH_LIBPOWERMAN_TRUE@am__append_10 = powerman-pdu
@WITH_SSL_TRUE@am__append_11 = $(LIBSSL_CFLAGS)
@WITH_SSL_TRUE@am__append_12 = $(LIBSSL_LDFLAGS)
@WITH_SSL_TRUE@am__append_12 = $(LIBSSL_LIBS)
subdir = drivers
DIST_COMMON = $(dist_noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_create_stdint_h.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_ipv6.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -82,6 +83,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_create_stdint_h.m4 \
$(top_srcdir)/m4/nut_check_libusb.m4 \
$(top_srcdir)/m4/nut_check_libwrap.m4 \
$(top_srcdir)/m4/nut_check_os.m4 \
$(top_srcdir)/m4/nut_config_libhal.m4 \
$(top_srcdir)/m4/nut_report_feature.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.in
@ -107,18 +109,18 @@ am__EXEEXT_1 = apcsmart$(EXEEXT) bcmxcp$(EXEEXT) belkin$(EXEEXT) \
bestuferrups$(EXEEXT) bestups$(EXEEXT) dummy-ups$(EXEEXT) \
etapro$(EXEEXT) everups$(EXEEXT) gamatronic$(EXEEXT) \
genericups$(EXEEXT) isbmex$(EXEEXT) liebert$(EXEEXT) \
liebertgxt2$(EXEEXT) masterguard$(EXEEXT) megatec$(EXEEXT) \
metasys$(EXEEXT) mge-shut$(EXEEXT) mge-utalk$(EXEEXT) \
microdowell$(EXEEXT) newmge-shut$(EXEEXT) oneac$(EXEEXT) \
optiups$(EXEEXT) powercom$(EXEEXT) rhino$(EXEEXT) \
safenet$(EXEEXT) skel$(EXEEXT) solis$(EXEEXT) \
tripplite$(EXEEXT) tripplitesu$(EXEEXT) upscode2$(EXEEXT) \
victronups$(EXEEXT) powerpanel$(EXEEXT) blazer_ser$(EXEEXT) \
clone$(EXEEXT) clone-outlet$(EXEEXT) ivtscd$(EXEEXT)
liebert-esp2$(EXEEXT) masterguard$(EXEEXT) metasys$(EXEEXT) \
mge-shut$(EXEEXT) mge-utalk$(EXEEXT) microdowell$(EXEEXT) \
newmge-shut$(EXEEXT) oneac$(EXEEXT) optiups$(EXEEXT) \
powercom$(EXEEXT) rhino$(EXEEXT) safenet$(EXEEXT) \
skel$(EXEEXT) solis$(EXEEXT) tripplite$(EXEEXT) \
tripplitesu$(EXEEXT) upscode2$(EXEEXT) victronups$(EXEEXT) \
powerpanel$(EXEEXT) blazer_ser$(EXEEXT) clone$(EXEEXT) \
clone-outlet$(EXEEXT) ivtscd$(EXEEXT)
am__EXEEXT_2 = snmp-ups$(EXEEXT)
am__EXEEXT_3 = usbhid-ups$(EXEEXT) bcmxcp_usb$(EXEEXT) \
tripplite_usb$(EXEEXT) megatec_usb$(EXEEXT) \
blazer_usb$(EXEEXT) richcomm_usb$(EXEEXT)
tripplite_usb$(EXEEXT) blazer_usb$(EXEEXT) \
richcomm_usb$(EXEEXT)
am__EXEEXT_4 = $(am__EXEEXT_3)
am__EXEEXT_5 = netxml-ups$(EXEEXT)
@SOME_DRIVERS_FALSE@@WITH_SERIAL_TRUE@am__EXEEXT_6 = $(am__EXEEXT_1)
@ -131,7 +133,7 @@ am__installdirs = "$(DESTDIR)$(driverexecdir)" \
am__EXEEXT_11 = hald-addon-usbhid-ups$(EXEEXT) \
hald-addon-bcmxcp_usb$(EXEEXT) \
hald-addon-tripplite_usb$(EXEEXT) \
hald-addon-megatec_usb$(EXEEXT)
hald-addon-blazer_usb$(EXEEXT)
PROGRAMS = $(driverexec_PROGRAMS) $(halexec_PROGRAMS)
am_apcsmart_OBJECTS = apcsmart.$(OBJEXT)
apcsmart_OBJECTS = $(am_apcsmart_OBJECTS)
@ -141,8 +143,8 @@ am__DEPENDENCIES_2 = $(LDADD_DRIVERS) $(am__DEPENDENCIES_1) serial.o
apcsmart_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_bcmxcp_OBJECTS = bcmxcp.$(OBJEXT) bcmxcp_ser.$(OBJEXT)
bcmxcp_OBJECTS = $(am_bcmxcp_OBJECTS)
bcmxcp_LDADD = $(LDADD)
bcmxcp_DEPENDENCIES = $(am__DEPENDENCIES_2)
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2)
bcmxcp_DEPENDENCIES = $(am__DEPENDENCIES_3)
am_bcmxcp_usb_OBJECTS = bcmxcp_usb.$(OBJEXT) bcmxcp.$(OBJEXT) \
usb-common.$(OBJEXT)
bcmxcp_usb_OBJECTS = $(am_bcmxcp_usb_OBJECTS)
@ -173,7 +175,6 @@ bestups_LDADD = $(LDADD)
bestups_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_blazer_ser_OBJECTS = blazer.$(OBJEXT) blazer_ser.$(OBJEXT)
blazer_ser_OBJECTS = $(am_blazer_ser_OBJECTS)
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2)
blazer_ser_DEPENDENCIES = $(am__DEPENDENCIES_3)
am_blazer_usb_OBJECTS = blazer.$(OBJEXT) blazer_usb.$(OBJEXT) \
libusb.$(OBJEXT) usb-common.$(OBJEXT)
@ -216,17 +217,11 @@ am_hald_addon_bcmxcp_usb_OBJECTS = bcmxcp_usb.$(OBJEXT) \
hald_addon_bcmxcp_usb_OBJECTS = $(am_hald_addon_bcmxcp_usb_OBJECTS)
hald_addon_bcmxcp_usb_DEPENDENCIES = $(LDADD_HAL_DRIVERS) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_hald_addon_megatec_usb_OBJECTS = \
hald_addon_megatec_usb-megatec.$(OBJEXT) \
hald_addon_megatec_usb-megatec_usb.$(OBJEXT) \
hald_addon_megatec_usb-libusb.$(OBJEXT)
hald_addon_megatec_usb_OBJECTS = $(am_hald_addon_megatec_usb_OBJECTS)
hald_addon_megatec_usb_DEPENDENCIES = $(LDADD_HAL_DRIVERS) \
am_hald_addon_blazer_usb_OBJECTS = blazer.$(OBJEXT) \
blazer_usb.$(OBJEXT) libusb.$(OBJEXT)
hald_addon_blazer_usb_OBJECTS = $(am_hald_addon_blazer_usb_OBJECTS)
hald_addon_blazer_usb_DEPENDENCIES = $(LDADD_HAL_DRIVERS) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
hald_addon_megatec_usb_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
am_hald_addon_tripplite_usb_OBJECTS = tripplite_usb.$(OBJEXT) \
libusb.$(OBJEXT)
hald_addon_tripplite_usb_OBJECTS = \
@ -236,7 +231,7 @@ hald_addon_tripplite_usb_DEPENDENCIES = $(LDADD_HAL_DRIVERS) \
am__objects_1 = apc-hid.$(OBJEXT) belkin-hid.$(OBJEXT) \
cps-hid.$(OBJEXT) explore-hid.$(OBJEXT) liebert-hid.$(OBJEXT) \
mge-hid.$(OBJEXT) powercom-hid.$(OBJEXT) \
tripplite-hid.$(OBJEXT)
tripplite-hid.$(OBJEXT) idowell-hid.$(OBJEXT)
am_hald_addon_usbhid_ups_OBJECTS = usbhid-ups.$(OBJEXT) \
libhid.$(OBJEXT) libusb.$(OBJEXT) hidparser.$(OBJEXT) \
$(am__objects_1)
@ -254,26 +249,14 @@ am_liebert_OBJECTS = liebert.$(OBJEXT)
liebert_OBJECTS = $(am_liebert_OBJECTS)
liebert_LDADD = $(LDADD)
liebert_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_liebertgxt2_OBJECTS = liebertgxt2.$(OBJEXT)
liebertgxt2_OBJECTS = $(am_liebertgxt2_OBJECTS)
liebertgxt2_LDADD = $(LDADD)
liebertgxt2_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_liebert_esp2_OBJECTS = liebert-esp2.$(OBJEXT)
liebert_esp2_OBJECTS = $(am_liebert_esp2_OBJECTS)
liebert_esp2_LDADD = $(LDADD)
liebert_esp2_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_masterguard_OBJECTS = masterguard.$(OBJEXT)
masterguard_OBJECTS = $(am_masterguard_OBJECTS)
masterguard_LDADD = $(LDADD)
masterguard_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_megatec_OBJECTS = megatec.$(OBJEXT)
megatec_OBJECTS = $(am_megatec_OBJECTS)
megatec_LDADD = $(LDADD)
megatec_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_megatec_usb_OBJECTS = megatec_usb-megatec.$(OBJEXT) \
megatec_usb-megatec_usb.$(OBJEXT) megatec_usb-libusb.$(OBJEXT) \
megatec_usb-usb-common.$(OBJEXT)
megatec_usb_OBJECTS = $(am_megatec_usb_OBJECTS)
megatec_usb_DEPENDENCIES = $(LDADD_DRIVERS) $(am__DEPENDENCIES_1)
megatec_usb_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(megatec_usb_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
am_metasys_OBJECTS = metasys.$(OBJEXT)
metasys_OBJECTS = $(am_metasys_OBJECTS)
metasys_LDADD = $(LDADD)
@ -336,7 +319,8 @@ skel_DEPENDENCIES = $(LDADD_DRIVERS)
am_snmp_ups_OBJECTS = snmp-ups.$(OBJEXT) apc-mib.$(OBJEXT) \
baytech-mib.$(OBJEXT) compaq-mib.$(OBJEXT) eaton-mib.$(OBJEXT) \
ietf-mib.$(OBJEXT) mge-mib.$(OBJEXT) netvision-mib.$(OBJEXT) \
powerware-mib.$(OBJEXT) raritan-pdu-mib.$(OBJEXT)
powerware-mib.$(OBJEXT) raritan-pdu-mib.$(OBJEXT) \
bestpower-mib.$(OBJEXT)
snmp_ups_OBJECTS = $(am_snmp_ups_OBJECTS)
snmp_ups_DEPENDENCIES = $(LDADD_DRIVERS) $(am__DEPENDENCIES_1)
am_solis_OBJECTS = solis.$(OBJEXT)
@ -390,12 +374,11 @@ SOURCES = $(libdummy_a_SOURCES) $(libnuthalmain_a_SOURCES) \
$(clone_outlet_SOURCES) $(dummy_ups_SOURCES) $(etapro_SOURCES) \
$(everups_SOURCES) $(gamatronic_SOURCES) $(genericups_SOURCES) \
$(hald_addon_bcmxcp_usb_SOURCES) \
$(hald_addon_megatec_usb_SOURCES) \
$(hald_addon_blazer_usb_SOURCES) \
$(hald_addon_tripplite_usb_SOURCES) \
$(hald_addon_usbhid_ups_SOURCES) $(isbmex_SOURCES) \
$(ivtscd_SOURCES) $(liebert_SOURCES) $(liebertgxt2_SOURCES) \
$(masterguard_SOURCES) $(megatec_SOURCES) \
$(megatec_usb_SOURCES) $(metasys_SOURCES) $(mge_shut_SOURCES) \
$(ivtscd_SOURCES) $(liebert_SOURCES) $(liebert_esp2_SOURCES) \
$(masterguard_SOURCES) $(metasys_SOURCES) $(mge_shut_SOURCES) \
$(mge_utalk_SOURCES) $(microdowell_SOURCES) \
$(netxml_ups_SOURCES) $(newmge_shut_SOURCES) $(oneac_SOURCES) \
$(optiups_SOURCES) $(powercom_SOURCES) $(powerman_pdu_SOURCES) \
@ -413,12 +396,11 @@ DIST_SOURCES = $(libdummy_a_SOURCES) $(libnuthalmain_a_SOURCES) \
$(clone_outlet_SOURCES) $(dummy_ups_SOURCES) $(etapro_SOURCES) \
$(everups_SOURCES) $(gamatronic_SOURCES) $(genericups_SOURCES) \
$(hald_addon_bcmxcp_usb_SOURCES) \
$(hald_addon_megatec_usb_SOURCES) \
$(hald_addon_blazer_usb_SOURCES) \
$(hald_addon_tripplite_usb_SOURCES) \
$(hald_addon_usbhid_ups_SOURCES) $(isbmex_SOURCES) \
$(ivtscd_SOURCES) $(liebert_SOURCES) $(liebertgxt2_SOURCES) \
$(masterguard_SOURCES) $(megatec_SOURCES) \
$(megatec_usb_SOURCES) $(metasys_SOURCES) $(mge_shut_SOURCES) \
$(ivtscd_SOURCES) $(liebert_SOURCES) $(liebert_esp2_SOURCES) \
$(masterguard_SOURCES) $(metasys_SOURCES) $(mge_shut_SOURCES) \
$(mge_utalk_SOURCES) $(microdowell_SOURCES) \
$(netxml_ups_SOURCES) $(newmge_shut_SOURCES) $(oneac_SOURCES) \
$(optiups_SOURCES) $(powercom_SOURCES) $(powerman_pdu_SOURCES) \
@ -432,9 +414,11 @@ HEADERS = $(dist_noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@ -447,8 +431,10 @@ CONFPATH = @CONFPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DBLATEX = @DBLATEX@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DOC_BUILD_LIST = @DOC_BUILD_LIST@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
@ -465,7 +451,6 @@ HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
HAL_FDI_PATH = @HAL_FDI_PATH@
HAL_USER = @HAL_USER@
HAVE_GLIB_2_14 = @HAVE_GLIB_2_14@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@ -476,22 +461,22 @@ LDFLAGS = @LDFLAGS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LDFLAGS = @LIBHAL_LDFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LDFLAGS = @LIBNEON_LDFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
LIBNETSNMP_LDFLAGS = @LIBNETSNMP_LDFLAGS@
LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@
LIBOBJS = @LIBOBJS@
LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@
LIBPOWERMAN_LDFLAGS = @LIBPOWERMAN_LDFLAGS@
LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LDFLAGS = @LIBSSL_LDFLAGS@
LIBSSL_LIBS = @LIBSSL_LIBS@
LIBTOOL = @LIBTOOL@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_LDFLAGS = @LIBUSB_LDFLAGS@
LIBUSB_LIBS = @LIBUSB_LIBS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LDFLAGS = @LIBWRAP_LDFLAGS@
LIBWRAP_LIBS = @LIBWRAP_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
@ -588,9 +573,10 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
# by default, link programs in this directory with libcommon.a
# by default, link programs in this directory with libcommon.la
# (libtool version of the static lib, in order to access LTLIBOBJS)
#FIXME: SERLIBS is only useful for LDADD_DRIVERS_SERIAL not for LDADD_COMMON
LDADD_COMMON = ../common/libcommon.a ../common/libparseconf.la
LDADD_COMMON = ../common/libcommon.la ../common/libparseconf.la
LDADD_DRIVERS = $(LDADD_COMMON) main.o dstate.o
LDADD_HAL_DRIVERS = $(LDADD_COMMON) libnuthalmain.a
LDADD_DRIVERS_SERIAL = $(LDADD_DRIVERS) $(SERLIBS) serial.o
@ -604,18 +590,18 @@ AM_CFLAGS = -I$(top_srcdir)/include $(am__append_1) $(am__append_2) \
$(am__append_3) $(am__append_4) $(am__append_5)
SERIAL_DRIVERLIST = apcsmart bcmxcp belkin belkinunv bestfcom \
bestfortress bestuferrups bestups dummy-ups etapro everups \
gamatronic genericups isbmex liebert liebertgxt2 masterguard megatec metasys \
gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \
mge-shut mge-utalk microdowell newmge-shut oneac optiups powercom rhino \
safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
blazer_ser clone clone-outlet ivtscd
SNMP_DRIVERLIST = snmp-ups
USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb megatec_usb \
USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
blazer_usb richcomm_usb
USB_DRIVERLIST = $(USB_LIBUSB_DRIVERLIST)
HAL_DRIVERLIST = hald-addon-usbhid-ups hald-addon-bcmxcp_usb \
hald-addon-tripplite_usb hald-addon-megatec_usb
hald-addon-tripplite_usb hald-addon-blazer_usb
NEONXML_DRIVERLIST = netxml-ups
@SOME_DRIVERS_FALSE@@WITH_HAL_TRUE@halexecdir = $(HAL_CALLOUTS_PATH)
@ -630,6 +616,7 @@ upsdrvctl_LDADD = $(LDADD_COMMON)
# serial drivers: all of them use standard LDADD and CFLAGS
apcsmart_SOURCES = apcsmart.c
bcmxcp_SOURCES = bcmxcp.c bcmxcp_ser.c
bcmxcp_LDADD = $(LDADD) -lm
belkin_SOURCES = belkin.c
belkinunv_SOURCES = belkinunv.c
bestfcom_SOURCES = bestfcom.c
@ -645,9 +632,8 @@ isbmex_SOURCES = isbmex.c
isbmex_LDADD = $(LDADD) -lm
ivtscd_SOURCES = ivtscd.c
liebert_SOURCES = liebert.c
liebertgxt2_SOURCES = liebertgxt2.c
liebert_esp2_SOURCES = liebert-esp2.c
masterguard_SOURCES = masterguard.c
megatec_SOURCES = megatec.c
metasys_SOURCES = metasys.c
mge_shut_SOURCES = mge-shut.c hidparser.c
mge_utalk_SOURCES = mge-utalk.c
@ -688,23 +674,20 @@ 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
liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-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_LDFLAGS)
usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
tripplite_usb_SOURCES = tripplite_usb.c libusb.c usb-common.c
tripplite_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS) -lm
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_LDFLAGS)
megatec_usb_SOURCES = megatec.c megatec_usb.c libusb.c usb-common.c
megatec_usb_CFLAGS = $(AM_CFLAGS) -DMEGATEC_SUBDRV
megatec_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS)
bcmxcp_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c usb-common.c
blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS) -lm
blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
richcomm_usb_SOURCES = richcomm_usb.c usb-common.c
richcomm_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LDFLAGS)
richcomm_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
# HID-over-serial
newmge_shut_SOURCES = usbhid-ups.c libshut.c libhid.c hidparser.c mge-hid.c
@ -714,44 +697,44 @@ newmge_shut_LDADD = $(LDADD)
# SNMP
snmp_ups_SOURCES = snmp-ups.c apc-mib.c baytech-mib.c compaq-mib.c eaton-mib.c \
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c \
bestpower-mib.c
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LDFLAGS)
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
# HAL
hald_addon_usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \
$(USBHID_UPS_SUBDRIVERS)
hald_addon_usbhid_ups_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS)
hald_addon_usbhid_ups_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS)
hald_addon_tripplite_usb_SOURCES = tripplite_usb.c libusb.c
hald_addon_tripplite_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS) -lm
hald_addon_tripplite_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS) -lm
hald_addon_bcmxcp_usb_SOURCES = bcmxcp_usb.c bcmxcp.c
hald_addon_bcmxcp_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS)
hald_addon_megatec_usb_SOURCES = megatec.c megatec_usb.c libusb.c
hald_addon_megatec_usb_CFLAGS = $(AM_CFLAGS) -DMEGATEC_SUBDRV
hald_addon_megatec_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LDFLAGS) $(LIBHAL_LDFLAGS)
hald_addon_bcmxcp_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS)
hald_addon_blazer_usb_SOURCES = blazer.c blazer_usb.c libusb.c
hald_addon_blazer_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS) -lm
# NEON XML/HTTP
netxml_ups_SOURCES = netxml-ups.c mge-xml.c
netxml_ups_LDADD = $(LDADD_DRIVERS) $(LIBNEON_LDFLAGS)
netxml_ups_LDADD = $(LDADD_DRIVERS) $(LIBNEON_LIBS)
# Powerman
powerman_pdu_SOURCES = powerman-pdu.c
powerman_pdu_LDADD = $(LDADD) $(LIBPOWERMAN_LDFLAGS)
powerman_pdu_LDADD = $(LDADD) $(LIBPOWERMAN_LIBS)
# ----------------------------------------------------------------------
# List of header files. The purpose of this list is not dependency
# tracking (which is automatic), but to ensure these files are
# distributed by "make dist".
dist_noinst_HEADERS = apc-mib.h apc-hid.h apcsmart.h baytech-mib.h bcmxcp.h \
bcmxcp_io.h belkin.h belkin-hid.h blazer.h cps-hid.h dstate.h dstate-hal.h \
dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \
bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \
dstate-hal.h dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \
hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h libusb.h liebert-hid.h \
main.h main-hal.h megatec.h mge-hid.h mge-mib.h mge-shut.h mge-utalk.h \
main.h main-hal.h mge-hid.h mge-mib.h mge-shut.h mge-utalk.h \
mge-xml.h microdowell.h netvision-mib.h netxml-ups.h oneac.h \
powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \
safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h
# Define a dummy library so that Automake builds rules for the
@ -951,9 +934,9 @@ genericups$(EXEEXT): $(genericups_OBJECTS) $(genericups_DEPENDENCIES)
hald-addon-bcmxcp_usb$(EXEEXT): $(hald_addon_bcmxcp_usb_OBJECTS) $(hald_addon_bcmxcp_usb_DEPENDENCIES)
@rm -f hald-addon-bcmxcp_usb$(EXEEXT)
$(LINK) $(hald_addon_bcmxcp_usb_OBJECTS) $(hald_addon_bcmxcp_usb_LDADD) $(LIBS)
hald-addon-megatec_usb$(EXEEXT): $(hald_addon_megatec_usb_OBJECTS) $(hald_addon_megatec_usb_DEPENDENCIES)
@rm -f hald-addon-megatec_usb$(EXEEXT)
$(hald_addon_megatec_usb_LINK) $(hald_addon_megatec_usb_OBJECTS) $(hald_addon_megatec_usb_LDADD) $(LIBS)
hald-addon-blazer_usb$(EXEEXT): $(hald_addon_blazer_usb_OBJECTS) $(hald_addon_blazer_usb_DEPENDENCIES)
@rm -f hald-addon-blazer_usb$(EXEEXT)
$(LINK) $(hald_addon_blazer_usb_OBJECTS) $(hald_addon_blazer_usb_LDADD) $(LIBS)
hald-addon-tripplite_usb$(EXEEXT): $(hald_addon_tripplite_usb_OBJECTS) $(hald_addon_tripplite_usb_DEPENDENCIES)
@rm -f hald-addon-tripplite_usb$(EXEEXT)
$(LINK) $(hald_addon_tripplite_usb_OBJECTS) $(hald_addon_tripplite_usb_LDADD) $(LIBS)
@ -969,18 +952,12 @@ ivtscd$(EXEEXT): $(ivtscd_OBJECTS) $(ivtscd_DEPENDENCIES)
liebert$(EXEEXT): $(liebert_OBJECTS) $(liebert_DEPENDENCIES)
@rm -f liebert$(EXEEXT)
$(LINK) $(liebert_OBJECTS) $(liebert_LDADD) $(LIBS)
liebertgxt2$(EXEEXT): $(liebertgxt2_OBJECTS) $(liebertgxt2_DEPENDENCIES)
@rm -f liebertgxt2$(EXEEXT)
$(LINK) $(liebertgxt2_OBJECTS) $(liebertgxt2_LDADD) $(LIBS)
liebert-esp2$(EXEEXT): $(liebert_esp2_OBJECTS) $(liebert_esp2_DEPENDENCIES)
@rm -f liebert-esp2$(EXEEXT)
$(LINK) $(liebert_esp2_OBJECTS) $(liebert_esp2_LDADD) $(LIBS)
masterguard$(EXEEXT): $(masterguard_OBJECTS) $(masterguard_DEPENDENCIES)
@rm -f masterguard$(EXEEXT)
$(LINK) $(masterguard_OBJECTS) $(masterguard_LDADD) $(LIBS)
megatec$(EXEEXT): $(megatec_OBJECTS) $(megatec_DEPENDENCIES)
@rm -f megatec$(EXEEXT)
$(LINK) $(megatec_OBJECTS) $(megatec_LDADD) $(LIBS)
megatec_usb$(EXEEXT): $(megatec_usb_OBJECTS) $(megatec_usb_DEPENDENCIES)
@rm -f megatec_usb$(EXEEXT)
$(megatec_usb_LINK) $(megatec_usb_OBJECTS) $(megatec_usb_LDADD) $(LIBS)
metasys$(EXEEXT): $(metasys_OBJECTS) $(metasys_DEPENDENCIES)
@rm -f metasys$(EXEEXT)
$(LINK) $(metasys_OBJECTS) $(metasys_LDADD) $(LIBS)
@ -1072,6 +1049,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/belkinunv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestfcom.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestfortress.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestpower-mib.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestuferrups.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestups.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blazer.Po@am__quote@
@ -1090,26 +1068,19 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/explore-hid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gamatronic.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genericups.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_addon_megatec_usb-libusb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_addon_megatec_usb-megatec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hidparser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idowell-hid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ietf-mib.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isbmex.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ivtscd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libusb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liebert-esp2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liebert-hid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liebert.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liebertgxt2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main-hal.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/masterguard.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/megatec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/megatec_usb-libusb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/megatec_usb-megatec.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/megatec_usb-megatec_usb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/megatec_usb-usb-common.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metasys.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mge-hid.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mge-mib.Po@am__quote@
@ -1186,104 +1157,6 @@ dummy_ups-dummy-ups.obj: dummy-ups.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dummy_ups_CFLAGS) $(CFLAGS) -c -o dummy_ups-dummy-ups.obj `if test -f 'dummy-ups.c'; then $(CYGPATH_W) 'dummy-ups.c'; else $(CYGPATH_W) '$(srcdir)/dummy-ups.c'; fi`
hald_addon_megatec_usb-megatec.o: megatec.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -MT hald_addon_megatec_usb-megatec.o -MD -MP -MF $(DEPDIR)/hald_addon_megatec_usb-megatec.Tpo -c -o hald_addon_megatec_usb-megatec.o `test -f 'megatec.c' || echo '$(srcdir)/'`megatec.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hald_addon_megatec_usb-megatec.Tpo $(DEPDIR)/hald_addon_megatec_usb-megatec.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec.c' object='hald_addon_megatec_usb-megatec.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -c -o hald_addon_megatec_usb-megatec.o `test -f 'megatec.c' || echo '$(srcdir)/'`megatec.c
hald_addon_megatec_usb-megatec.obj: megatec.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -MT hald_addon_megatec_usb-megatec.obj -MD -MP -MF $(DEPDIR)/hald_addon_megatec_usb-megatec.Tpo -c -o hald_addon_megatec_usb-megatec.obj `if test -f 'megatec.c'; then $(CYGPATH_W) 'megatec.c'; else $(CYGPATH_W) '$(srcdir)/megatec.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hald_addon_megatec_usb-megatec.Tpo $(DEPDIR)/hald_addon_megatec_usb-megatec.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec.c' object='hald_addon_megatec_usb-megatec.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -c -o hald_addon_megatec_usb-megatec.obj `if test -f 'megatec.c'; then $(CYGPATH_W) 'megatec.c'; else $(CYGPATH_W) '$(srcdir)/megatec.c'; fi`
hald_addon_megatec_usb-megatec_usb.o: megatec_usb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -MT hald_addon_megatec_usb-megatec_usb.o -MD -MP -MF $(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Tpo -c -o hald_addon_megatec_usb-megatec_usb.o `test -f 'megatec_usb.c' || echo '$(srcdir)/'`megatec_usb.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Tpo $(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec_usb.c' object='hald_addon_megatec_usb-megatec_usb.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -c -o hald_addon_megatec_usb-megatec_usb.o `test -f 'megatec_usb.c' || echo '$(srcdir)/'`megatec_usb.c
hald_addon_megatec_usb-megatec_usb.obj: megatec_usb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -MT hald_addon_megatec_usb-megatec_usb.obj -MD -MP -MF $(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Tpo -c -o hald_addon_megatec_usb-megatec_usb.obj `if test -f 'megatec_usb.c'; then $(CYGPATH_W) 'megatec_usb.c'; else $(CYGPATH_W) '$(srcdir)/megatec_usb.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Tpo $(DEPDIR)/hald_addon_megatec_usb-megatec_usb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec_usb.c' object='hald_addon_megatec_usb-megatec_usb.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -c -o hald_addon_megatec_usb-megatec_usb.obj `if test -f 'megatec_usb.c'; then $(CYGPATH_W) 'megatec_usb.c'; else $(CYGPATH_W) '$(srcdir)/megatec_usb.c'; fi`
hald_addon_megatec_usb-libusb.o: libusb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -MT hald_addon_megatec_usb-libusb.o -MD -MP -MF $(DEPDIR)/hald_addon_megatec_usb-libusb.Tpo -c -o hald_addon_megatec_usb-libusb.o `test -f 'libusb.c' || echo '$(srcdir)/'`libusb.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hald_addon_megatec_usb-libusb.Tpo $(DEPDIR)/hald_addon_megatec_usb-libusb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libusb.c' object='hald_addon_megatec_usb-libusb.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -c -o hald_addon_megatec_usb-libusb.o `test -f 'libusb.c' || echo '$(srcdir)/'`libusb.c
hald_addon_megatec_usb-libusb.obj: libusb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -MT hald_addon_megatec_usb-libusb.obj -MD -MP -MF $(DEPDIR)/hald_addon_megatec_usb-libusb.Tpo -c -o hald_addon_megatec_usb-libusb.obj `if test -f 'libusb.c'; then $(CYGPATH_W) 'libusb.c'; else $(CYGPATH_W) '$(srcdir)/libusb.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hald_addon_megatec_usb-libusb.Tpo $(DEPDIR)/hald_addon_megatec_usb-libusb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libusb.c' object='hald_addon_megatec_usb-libusb.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_megatec_usb_CFLAGS) $(CFLAGS) -c -o hald_addon_megatec_usb-libusb.obj `if test -f 'libusb.c'; then $(CYGPATH_W) 'libusb.c'; else $(CYGPATH_W) '$(srcdir)/libusb.c'; fi`
megatec_usb-megatec.o: megatec.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-megatec.o -MD -MP -MF $(DEPDIR)/megatec_usb-megatec.Tpo -c -o megatec_usb-megatec.o `test -f 'megatec.c' || echo '$(srcdir)/'`megatec.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-megatec.Tpo $(DEPDIR)/megatec_usb-megatec.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec.c' object='megatec_usb-megatec.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-megatec.o `test -f 'megatec.c' || echo '$(srcdir)/'`megatec.c
megatec_usb-megatec.obj: megatec.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-megatec.obj -MD -MP -MF $(DEPDIR)/megatec_usb-megatec.Tpo -c -o megatec_usb-megatec.obj `if test -f 'megatec.c'; then $(CYGPATH_W) 'megatec.c'; else $(CYGPATH_W) '$(srcdir)/megatec.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-megatec.Tpo $(DEPDIR)/megatec_usb-megatec.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec.c' object='megatec_usb-megatec.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-megatec.obj `if test -f 'megatec.c'; then $(CYGPATH_W) 'megatec.c'; else $(CYGPATH_W) '$(srcdir)/megatec.c'; fi`
megatec_usb-megatec_usb.o: megatec_usb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-megatec_usb.o -MD -MP -MF $(DEPDIR)/megatec_usb-megatec_usb.Tpo -c -o megatec_usb-megatec_usb.o `test -f 'megatec_usb.c' || echo '$(srcdir)/'`megatec_usb.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-megatec_usb.Tpo $(DEPDIR)/megatec_usb-megatec_usb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec_usb.c' object='megatec_usb-megatec_usb.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-megatec_usb.o `test -f 'megatec_usb.c' || echo '$(srcdir)/'`megatec_usb.c
megatec_usb-megatec_usb.obj: megatec_usb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-megatec_usb.obj -MD -MP -MF $(DEPDIR)/megatec_usb-megatec_usb.Tpo -c -o megatec_usb-megatec_usb.obj `if test -f 'megatec_usb.c'; then $(CYGPATH_W) 'megatec_usb.c'; else $(CYGPATH_W) '$(srcdir)/megatec_usb.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-megatec_usb.Tpo $(DEPDIR)/megatec_usb-megatec_usb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='megatec_usb.c' object='megatec_usb-megatec_usb.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-megatec_usb.obj `if test -f 'megatec_usb.c'; then $(CYGPATH_W) 'megatec_usb.c'; else $(CYGPATH_W) '$(srcdir)/megatec_usb.c'; fi`
megatec_usb-libusb.o: libusb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-libusb.o -MD -MP -MF $(DEPDIR)/megatec_usb-libusb.Tpo -c -o megatec_usb-libusb.o `test -f 'libusb.c' || echo '$(srcdir)/'`libusb.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-libusb.Tpo $(DEPDIR)/megatec_usb-libusb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libusb.c' object='megatec_usb-libusb.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-libusb.o `test -f 'libusb.c' || echo '$(srcdir)/'`libusb.c
megatec_usb-libusb.obj: libusb.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-libusb.obj -MD -MP -MF $(DEPDIR)/megatec_usb-libusb.Tpo -c -o megatec_usb-libusb.obj `if test -f 'libusb.c'; then $(CYGPATH_W) 'libusb.c'; else $(CYGPATH_W) '$(srcdir)/libusb.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-libusb.Tpo $(DEPDIR)/megatec_usb-libusb.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libusb.c' object='megatec_usb-libusb.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-libusb.obj `if test -f 'libusb.c'; then $(CYGPATH_W) 'libusb.c'; else $(CYGPATH_W) '$(srcdir)/libusb.c'; fi`
megatec_usb-usb-common.o: usb-common.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-usb-common.o -MD -MP -MF $(DEPDIR)/megatec_usb-usb-common.Tpo -c -o megatec_usb-usb-common.o `test -f 'usb-common.c' || echo '$(srcdir)/'`usb-common.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-usb-common.Tpo $(DEPDIR)/megatec_usb-usb-common.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='usb-common.c' object='megatec_usb-usb-common.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-usb-common.o `test -f 'usb-common.c' || echo '$(srcdir)/'`usb-common.c
megatec_usb-usb-common.obj: usb-common.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -MT megatec_usb-usb-common.obj -MD -MP -MF $(DEPDIR)/megatec_usb-usb-common.Tpo -c -o megatec_usb-usb-common.obj `if test -f 'usb-common.c'; then $(CYGPATH_W) 'usb-common.c'; else $(CYGPATH_W) '$(srcdir)/usb-common.c'; fi`
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/megatec_usb-usb-common.Tpo $(DEPDIR)/megatec_usb-usb-common.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='usb-common.c' object='megatec_usb-usb-common.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(megatec_usb_CFLAGS) $(CFLAGS) -c -o megatec_usb-usb-common.obj `if test -f 'usb-common.c'; then $(CYGPATH_W) 'usb-common.c'; else $(CYGPATH_W) '$(srcdir)/usb-common.c'; fi`
newmge_shut-usbhid-ups.o: usbhid-ups.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(newmge_shut_CFLAGS) $(CFLAGS) -MT newmge_shut-usbhid-ups.o -MD -MP -MF $(DEPDIR)/newmge_shut-usbhid-ups.Tpo -c -o newmge_shut-usbhid-ups.o `test -f 'usbhid-ups.c' || echo '$(srcdir)/'`usbhid-ups.c
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/newmge_shut-usbhid-ups.Tpo $(DEPDIR)/newmge_shut-usbhid-ups.Po

View file

@ -4,7 +4,7 @@
* 2003 - 2009 Arnaud Quette <arnaud.quette@free.fr>
* 2005 John Stamp <kinsayder@hotmail.com>
* 2005 Peter Selinger <selinger@users.sourceforge.net>
* 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
* 2009 - 2010 Arjen de Korte <adkorte-guest@alioth.debian.org>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
* and Eaton <http://www.eaton.com>
@ -36,10 +36,22 @@
/* APC */
#define APC_VENDORID 0x051d
/* Don't use interrupt pipe on 5G models (used by proprietary protocol) */
static void *disable_interrupt_pipe(void)
{
if (use_interrupt_pipe == TRUE) {
upslogx(LOG_INFO, "interrupt pipe disabled (add 'pollonly' flag to 'ups.conf' to get rid of this message)");
use_interrupt_pipe= FALSE;
}
return NULL;
}
/* USB IDs device table */
static usb_device_id_t apc_usb_device_table[] = {
/* various models */
{ USB_DEVICE(APC_VENDORID, 0x0002), NULL },
/* various 5G models */
{ USB_DEVICE(APC_VENDORID, 0x0003), disable_interrupt_pipe },
/* Terminating entry */
{ -1, -1, NULL }
@ -47,7 +59,7 @@ static usb_device_id_t apc_usb_device_table[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *apc_date_conversion_fun(double value)
static const char *apc_date_conversion_fun(double value)
{
static char buf[20];
int year, month, day;
@ -222,8 +234,11 @@ static hid_info_t apc_hid2nut[] = {
{ "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL },
{ "battery.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL },
{ "battery.runtime", 0, 0, "UPS.Battery.RunTimeToEmpty", NULL, "%.0f", 0, NULL },
{ "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL },
{ "battery.runtime.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Battery.RemainingTimeLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "battery.runtime.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "battery.voltage", 0, 0, "UPS.Battery.Voltage", NULL, "%.1f", 0, NULL },
{ "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.1f", 0, NULL },
{ "battery.voltage.nominal", 0, 0, "UPS.Battery.ConfigVoltage", NULL, "%.1f", 0, NULL },
{ "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, "%.1f", 0, NULL }, /* Back-UPS 500 */
@ -236,21 +251,30 @@ static hid_info_t apc_hid2nut[] = {
/* UPS page */
{ "ups.load", 0, 0, "UPS.Output.PercentLoad", NULL, "%.1f", 0, NULL },
{ "ups.load", 0, 0, "UPS.PowerConverter.PercentLoad", NULL, "%.0f", 0, NULL },
/* USB HID PDC defaults */
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.APCGeneralCollection.APCDelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL}, /* APC */
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.APCGeneralCollection.APCDelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL}, /* APC */
{ "ups.timer.start", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.start", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL}, /* APC */
{ "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.shutdown", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL}, /* APC */
{ "ups.timer.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.reboot", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL}, /* APC */
/* used by APC SmartUPS RM */
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Output.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Output.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.timer.start", 0, 0, "UPS.Output.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.shutdown", 0, 0, "UPS.Output.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.reboot", 0, 0, "UPS.Output.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
/* used by APC BackUPS ES */
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.APCGeneralCollection.APCDelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.APCGeneralCollection.APCDelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.timer.start", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.shutdown", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.reboot", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.test.result", 0, 0, "UPS.Battery.Test", NULL, "%s", 0, test_read_info },
{ "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", 0, beeper_info },
{ "ups.mfr.date", 0, 0, "UPS.ManufacturerDate", NULL, "%s", 0, date_conversion },
{ "ups.mfr.date", 0, 0, "UPS.PowerSummary.ManufacturerDate", NULL, "%s", 0, date_conversion }, /* Back-UPS 500 */
{ "ups.realpower.nominal", 0, 0, "UPS.PowerConverter.ConfigActivePower", NULL, "%.0f", 0, NULL },
/* the below one need to be discussed as we might need to complete
* the ups.test sub collection
@ -313,11 +337,17 @@ static hid_info_t apc_hid2nut[] = {
{ "test.panel.start", 0, 0, "UPS.PowerSummary.APCPanelTest", NULL, "1", HU_TYPE_CMD, NULL }, /* Back-UPS 500 */
{ "test.panel.stop", 0, 0, "UPS.PowerSummary.APCPanelTest", NULL, "0", HU_TYPE_CMD, NULL }, /* Back-UPS 500 */
/* USB HID PDC defaults */
{ "load.off.delay", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL },
{ "load.on.delay", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL },
{ "shutdown.stop", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL },
{ "shutdown.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL },
/* APC Backups ES */
/* used by APC SmartUPS RM */
{ "load.off.delay", 0, 0, "UPS.Output.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL },
{ "load.on.delay", 0, 0, "UPS.Output.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL },
{ "shutdown.stop", 0, 0, "UPS.Output.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL },
{ "shutdown.reboot", 0, 0, "UPS.Output.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL },
/* used by APC BackUPS ES */
{ "load.off.delay", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL },
{ "load.on.delay", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL },
{ "shutdown.stop", 0, 0, "UPS.APCGeneralCollection.APCDelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL },
@ -333,7 +363,7 @@ static hid_info_t apc_hid2nut[] = {
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *apc_format_model(HIDDevice_t *hd) {
static const char *apc_format_model(HIDDevice_t *hd) {
static char model[64];
char *ptr1, *ptr2;
@ -356,11 +386,11 @@ static char *apc_format_model(HIDDevice_t *hd) {
return model;
}
static char *apc_format_mfr(HIDDevice_t *hd) {
static const char *apc_format_mfr(HIDDevice_t *hd) {
return hd->Vendor ? hd->Vendor : "APC";
}
static char *apc_format_serial(HIDDevice_t *hd) {
static const char *apc_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}

View file

@ -48,7 +48,7 @@ upsdrv_info_t upsdrv_info = {
static int ups_status = 0, quirk_capability_overflow = 0;
static struct apc_vartab_t *vartab_lookup_char(char cmdchar)
static apc_vartab_t *vartab_lookup_char(char cmdchar)
{
int i;
@ -59,7 +59,7 @@ static struct apc_vartab_t *vartab_lookup_char(char cmdchar)
return NULL;
}
static struct apc_vartab_t *vartab_lookup_name(const char *var)
static apc_vartab_t *vartab_lookup_name(const char *var)
{
int i;
@ -73,7 +73,7 @@ static struct apc_vartab_t *vartab_lookup_name(const char *var)
/* FUTURE: change to use function pointers */
/* convert APC formatting to NUT formatting */
static char *convert_data(struct apc_vartab_t *cmd_entry, char *upsval)
static const char *convert_data(apc_vartab_t *cmd_entry, char *upsval)
{
static char tmp[128];
int tval;
@ -202,7 +202,7 @@ static int read_buf(char *buf, size_t buflen)
return ret;
}
static int poll_data(struct apc_vartab_t *vt)
static int poll_data(apc_vartab_t *vt)
{
int ret;
char tmp[SMALLBUF];
@ -241,8 +241,9 @@ static int poll_data(struct apc_vartab_t *vt)
static int query_ups(const char *var, int first)
{
int ret;
char temp[256], *ptr;
struct apc_vartab_t *vt;
char temp[256];
const char *ptr;
apc_vartab_t *vt;
vt = vartab_lookup_name(var);
@ -293,7 +294,7 @@ static void do_capabilities(void)
const char *ptr, *entptr;
char upsloc, temp[512], cmd, loc, etmp[16], *endtemp;
int nument, entlen, i, matrix, ret;
struct apc_vartab_t *vt;
apc_vartab_t *vt;
upsdebugx(1, "APC - About to get capabilities string");
/* If we can do caps, then we need the Firmware revision which has
@ -914,10 +915,11 @@ static void update_info_all(void)
upsdebugx(3, "update_info_all: done");
}
static int setvar_enum(struct apc_vartab_t *vt, const char *val)
static int setvar_enum(apc_vartab_t *vt, const char *val)
{
int i, ret;
char orig[256], temp[256], *ptr;
char orig[256], temp[256];
const char *ptr;
ret = ser_send_char(upsfd, vt->cmd);
@ -1006,7 +1008,7 @@ static int setvar_enum(struct apc_vartab_t *vt, const char *val)
return STAT_SET_HANDLED;
}
static int setvar_string(struct apc_vartab_t *vt, const char *val)
static int setvar_string(apc_vartab_t *vt, const char *val)
{
unsigned int i;
int ret;
@ -1088,7 +1090,7 @@ static int setvar_string(struct apc_vartab_t *vt, const char *val)
static int setvar(const char *varname, const char *val)
{
struct apc_vartab_t *vt;
apc_vartab_t *vt;
vt = vartab_lookup_name(varname);
@ -1111,7 +1113,7 @@ static int setvar(const char *varname, const char *val)
}
/* actually send the instcmd's char to the ups */
static int do_cmd(struct apc_cmdtab_t *ct)
static int do_cmd(apc_cmdtab_t *ct)
{
int ret;
char buf[SMALLBUF];
@ -1152,7 +1154,7 @@ static int do_cmd(struct apc_cmdtab_t *ct)
}
/* some commands must be repeated in a window to execute */
static int instcmd_chktime(struct apc_cmdtab_t *ct)
static int instcmd_chktime(apc_cmdtab_t *ct)
{
double elapsed;
time_t now;
@ -1176,7 +1178,7 @@ static int instcmd_chktime(struct apc_cmdtab_t *ct)
static int instcmd(const char *cmdname, const char *extra)
{
int i;
struct apc_cmdtab_t *ct;
apc_cmdtab_t *ct;
ct = NULL;

View file

@ -101,12 +101,13 @@
#define APC_F_REASON 0x130000 /* Reason of transfer */
#define APC_F_LEAVE 0 /* Just pass this through */
struct apc_vartab_t {
typedef struct {
const char *name; /* the variable name */
unsigned int flags; /* various flags */
char cmd; /* command character */
} apc_vartab_t;
} apc_vartab[] = {
apc_vartab_t apc_vartab[] = {
{ "ups.firmware", 0, 'b' },
{ "ups.firmware.aux", 0, 'v' },
@ -213,11 +214,13 @@ struct apc_vartab_t {
#define APC_CMD_ON 0x0E /* ^N */
#define APC_CMD_BYPTOGGLE '^'
struct apc_cmdtab_t {
typedef struct {
const char *name;
int flags;
char cmd;
} apc_cmdtab[] =
} apc_cmdtab_t;
apc_cmdtab_t apc_cmdtab[] =
{
{ "load.off", APC_NASTY|APC_REPEAT, APC_CMD_OFF },
{ "load.on", APC_REPEAT, APC_CMD_ON },
@ -250,8 +253,7 @@ struct {
const char *firmware;
const char *cmdchars;
int flags;
} compat_tab[] =
{
} compat_tab[] = {
/* APC Matrix */
{ "0ZI", "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz/<>", 0 },
{ "5UI", "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz/<>", 0 },

View file

@ -150,13 +150,13 @@ static int init_outlet(unsigned char len);
static int instcmd(const char *cmdname, const char *extra);
char *FreqTol[3] = {"+/-2%", "+/-5%", "+/-7"};
char *ABMStatus[4] = {"Charging", "Discharging", "Floating", "Resting"};
const char *FreqTol[3] = {"+/-2%", "+/-5%", "+/-7"};
const char *ABMStatus[4] = {"Charging", "Discharging", "Floating", "Resting"};
/* Standard Authorization Block */
unsigned char AUTHOR[4] = {0xCF, 0x69, 0xE8, 0xD5};
int nphases = 0;
int outlet_block_len = 0;
char *cpu_name[5] = {"Cont:", "Inve:", "Rect:", "Netw:", "Disp:"};
const char *cpu_name[5] = {"Cont:", "Inve:", "Rect:", "Netw:", "Disp:"};
/* get_word function from nut driver metasys.c */
int get_word(const unsigned char *buffer) /* return an integer reading a word in the supplied buffer */
@ -958,7 +958,7 @@ void init_limit(void)
{
unsigned char answer[PW_ANSWER_MAX_SIZE];
int value, res;
char *horn_stat[3] = {"disabled", "enabled", "muted"};
const char *horn_stat[3] = {"disabled", "enabled", "muted"};
res = command_read_sequence(PW_LIMIT_BLOCK_REQ, answer);
if (res <= 0) {

View file

@ -330,7 +330,7 @@
#define BCMXCP_ALARM_MAP_MAX 240 /* Max no of entries in BCM/XCP alarm map (adjusted upwards to nearest multi of 8 */
typedef struct { /* Entry in BCM/XCP - UPS - NUT mapping table */
char *nut_entity; /* The NUT variable name */
const char *nut_entity; /* The NUT variable name */
unsigned char format; /* The format of the data - float, long etc */
unsigned int meter_block_index; /* The position of this meter in the UPS meter block */
} BCMXCP_METER_MAP_ENTRY_t;
@ -340,7 +340,7 @@ BCMXCP_METER_MAP_ENTRY_t
typedef struct { /* Entry in BCM/XCP - UPS mapping table */
int alarm_block_index; /* Index of this alarm in alarm block. -1 = not existing */
char *alarm_desc; /* Description of this alarm */
const char *alarm_desc; /* Description of this alarm */
} BCMXCP_ALARM_MAP_ENTRY_t;
BCMXCP_ALARM_MAP_ENTRY_t

View file

@ -304,7 +304,7 @@ int command_write_sequence(unsigned char *command, int command_length, unsigned
}
void upsdrv_comm_good()
void upsdrv_comm_good(void)
{
nutusb_comm_good();
}
@ -344,7 +344,7 @@ static void nutusb_open_error(const char *port)
}
/* FIXME: this part of the opening can go into common... */
static usb_dev_handle *open_powerware_usb()
static usb_dev_handle *open_powerware_usb(void)
{
struct usb_bus *busses = usb_get_busses();
struct usb_bus *bus;

View file

@ -68,7 +68,7 @@ static usb_device_id_t belkin_usb_device_table[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *belkin_firmware_conversion_fun(double value)
static const char *belkin_firmware_conversion_fun(double value)
{
static char buf[20];
@ -81,7 +81,7 @@ static info_lkp_t belkin_firmware_conversion[] = {
{ 0, NULL, belkin_firmware_conversion_fun }
};
static char *belkin_upstype_conversion_fun(double value)
static const char *belkin_upstype_conversion_fun(double value)
{
switch ((long)value & 0x0f)
{
@ -104,7 +104,7 @@ static info_lkp_t belkin_upstype_conversion[] = {
{ 0, NULL, belkin_upstype_conversion_fun }
};
static char *belkin_sensitivity_conversion_fun(double value)
static const char *belkin_sensitivity_conversion_fun(double value)
{
switch ((long)value)
{
@ -131,7 +131,7 @@ static info_lkp_t belkin_test_info[] = {
{ 0, NULL, NULL }
};
static char *belkin_overload_conversion_fun(double value)
static const char *belkin_overload_conversion_fun(double value)
{
if ((long)value & 0x0010) {
return "overload";
@ -144,7 +144,7 @@ static info_lkp_t belkin_overload_conversion[] = {
{ 0, NULL, belkin_overload_conversion_fun }
};
static char *belkin_overheat_conversion_fun(double value)
static const char *belkin_overheat_conversion_fun(double value)
{
if ((long)value & 0x0040) {
return "overheat";
@ -157,7 +157,7 @@ static info_lkp_t belkin_overheat_conversion[] = {
{ 0, NULL, belkin_overheat_conversion_fun }
};
static char *belkin_commfault_conversion_fun(double value)
static const char *belkin_commfault_conversion_fun(double value)
{
if ((long)value & 0x0080) {
return "commfault";
@ -170,7 +170,7 @@ static info_lkp_t belkin_commfault_conversion[] = {
{ 0, NULL, belkin_commfault_conversion_fun }
};
static char *belkin_awaitingpower_conversion_fun(double value)
static const char *belkin_awaitingpower_conversion_fun(double value)
{
if ((long)value & 0x2000) {
return "awaitingpower";
@ -183,7 +183,7 @@ static info_lkp_t belkin_awaitingpower_conversion[] = {
{ 0, NULL, belkin_awaitingpower_conversion_fun }
};
static char *belkin_online_conversion_fun(double value)
static const char *belkin_online_conversion_fun(double value)
{
if ((long)value & 0x0001) {
return "!online";
@ -196,7 +196,7 @@ static info_lkp_t belkin_online_conversion[] = {
{ 0, NULL, belkin_online_conversion_fun }
};
static char *belkin_lowbatt_conversion_fun(double value)
static const char *belkin_lowbatt_conversion_fun(double value)
{
if ((long)value & 0x0004) {
return "lowbatt";
@ -209,7 +209,7 @@ static info_lkp_t belkin_lowbatt_conversion[] = {
{ 0, NULL, belkin_lowbatt_conversion_fun }
};
static char *belkin_depleted_conversion_fun(double value)
static const char *belkin_depleted_conversion_fun(double value)
{
if ((long)value & 0x0040) {
return "depleted";
@ -222,7 +222,7 @@ static info_lkp_t belkin_depleted_conversion[] = {
{ 0, NULL, belkin_depleted_conversion_fun }
};
static char *belkin_replacebatt_conversion_fun(double value)
static const char *belkin_replacebatt_conversion_fun(double value)
{
if ((long)value & 0x0080) {
return "replacebatt";
@ -385,7 +385,7 @@ static hid_info_t belkin_hid2nut[] = {
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *belkin_format_model(HIDDevice_t *hd) {
static const char *belkin_format_model(HIDDevice_t *hd) {
if ((hd->Product) && (strlen(hd->Product) > 0)) {
return hd->Product;
}
@ -393,8 +393,8 @@ static char *belkin_format_model(HIDDevice_t *hd) {
return "unknown";
}
static char *belkin_format_mfr(HIDDevice_t *hd) {
char *mfr;
static const char *belkin_format_mfr(HIDDevice_t *hd) {
const char *mfr;
mfr = hd->Vendor ? hd->Vendor : "Belkin";
/* trim leading whitespace */
while (*mfr == ' ') {
@ -406,7 +406,7 @@ static char *belkin_format_mfr(HIDDevice_t *hd) {
return mfr;
}
static char *belkin_format_serial(HIDDevice_t *hd) {
static const char *belkin_format_serial(HIDDevice_t *hd) {
char serial[64];
if (hd->Serial) {

View file

@ -28,7 +28,10 @@
#include "belkin.h"
#define DRIVER_NAME "Belkin Smart protocol driver"
#define DRIVER_VERSION "0.22"
#define DRIVER_VERSION "0.24"
static int init_communication(void);
static int get_belkin_reply(char *buf);
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -41,29 +44,33 @@ upsdrv_info_t upsdrv_info = {
static void send_belkin_command(char cmd, const char *subcmd, const char *data)
{
ser_flush_io(upsfd);
ser_send(upsfd, "~00%c%03d%s%s", cmd, (int)strlen(data) + 3, subcmd, data);
upsdebugx(3, "Send Command: %s, %s", subcmd, data);
}
static int init_communication(void)
{
int i;
int res;
int i, res;
char temp[SMALLBUF];
res = -1;
for (i = 1; i <= 10 && res == -1; i++) {
send_belkin_command(STATUS,MANUFACTURER,"");
for (i = 0; i < 10; i++) {
send_belkin_command(STATUS, MANUFACTURER, "");
res = get_belkin_reply(temp);
if (res > 0) {
/* return the number of retries needed before a valid reply is read (discard contents) */
return i;
}
}
if (res == -1 || strcmp(temp,"BELKIN"))
return res;
return 0;
/* no valid reply read */
return -1;
}
static char *get_belkin_field(const char *in, char *out, size_t outlen,
size_t num)
static char *get_belkin_field(const char *in, char *out, size_t outlen, size_t num)
{
size_t i, c = 1;
char *ptr;
@ -73,22 +80,26 @@ static char *get_belkin_field(const char *in, char *out, size_t outlen,
snprintf(out, outlen, "%s", in);
ptr = strchr(out, ';');
if (ptr)
if (ptr) {
*ptr = '\0';
}
return out;
}
}
for (i = 0; i < strlen(in); i++) {
if (in[i] == ';')
if (in[i] == ';') {
c++;
}
if (c == num) {
snprintf(out, outlen, "%s", &in[i + 1]);
ptr = strchr(out, ';');
if (ptr)
if (ptr) {
*ptr = '\0';
}
return out;
}
}
@ -96,204 +107,16 @@ static char *get_belkin_field(const char *in, char *out, size_t outlen,
return NULL;
}
static int do_status(void)
{
char temp[SMALLBUF], st[SMALLBUF];
int res;
send_belkin_command(STATUS,STAT_STATUS,"");
res = get_belkin_reply(temp);
if (res == -1) {
dstate_datastale();
return 0;
}
status_init();
get_belkin_field(temp, st, sizeof(st), 6);
if (*st == '1') {
status_set("OFF");
} else { /* (OFF) and (OB | OL) are mutually exclusive */
get_belkin_field(temp, st, sizeof(st), 2);
if (*st == '1') {
status_set("OB");
send_belkin_command(STATUS,STAT_BATTERY,"");
res = get_belkin_reply(temp);
if (res == -1) {
dstate_datastale();
return 0;
}
get_belkin_field(temp, st, sizeof(st), 10);
res = atoi(st);
get_belkin_field(temp, st, sizeof(st), 2);
if (*st == '1' || res < LOW_BAT)
status_set("LB"); /* low battery */
}
else
status_set("OL"); /* on line */
}
status_commit();
dstate_dataok();
return 1;
}
static int do_broken_rat(char *buf)
{
int ret, cnt;
char tmp[8];
usleep(25000);
ret = ser_get_buf_len(upsfd, (unsigned char *)tmp, 7, 3, 0);
if (ret != 7)
return -1;
tmp[7] = '\0';
cnt = atoi(tmp + 4);
if ((cnt < 1) || (cnt > 255))
return -1;
usleep(5000 * cnt);
/* firmware 001 only sends 50 bytes instead of the proper 53 */
if (cnt == 53)
cnt = 50;
ret = ser_get_buf_len(upsfd, (unsigned char *)buf, 50, cnt, 0);
buf[cnt] = 0;
return ret;
}
static int init_ups_data(void)
{
int res;
double low, high;
char temp[SMALLBUF], st[SMALLBUF];
send_belkin_command(STATUS, MODEL, "");
res = get_belkin_reply(temp);
if (res == -1)
return res;
dstate_setinfo("ups.model", "%s", temp);
send_belkin_command(STATUS, VERSION_CMD, "");
res = get_belkin_reply(temp);
if (res == -1)
return res;
dstate_setinfo("ups.firmware", "%s", temp);
/* deal with stupid firmware that breaks RAT */
send_belkin_command(STATUS, RATING, "");
if (!strcmp(temp, "001"))
res = do_broken_rat(temp);
else
res = get_belkin_reply(temp);
if (res > 0) {
get_belkin_field(temp, st, sizeof(st), 8);
low = atof(st) / 0.88;
get_belkin_field(temp, st, sizeof(st), 9);
high = atof(st) * 0.88;
dstate_setinfo("input.transfer.low", "%03.1f", low);
dstate_setinfo("input.transfer.high", "%03.1f", high);
}
ser_flush_io(upsfd);
dstate_addcmd("load.off");
dstate_addcmd("load.on");
upsdrv_updateinfo();
return 0;
}
/* normal idle loop - keep up with the current state of the UPS */
void upsdrv_updateinfo(void)
{
int res;
double val;
char temp[SMALLBUF], st[SMALLBUF];
if (!do_status())
return;
send_belkin_command(STATUS, STAT_INPUT, "");
res = get_belkin_reply(temp);
if (res == -1)
return;
get_belkin_field(temp, st, sizeof(st), 3);
val = atof(st) / 10;
dstate_setinfo("input.voltage", "%05.1f", val);
get_belkin_field(temp, st, sizeof(st), 2);
val = atof(st) / 10;
dstate_setinfo("input.frequency", "%.1f", val);
send_belkin_command(STATUS,STAT_BATTERY, "");
res = get_belkin_reply(temp);
if (res == -1)
return;
get_belkin_field(temp, st, sizeof(st), 10);
val = atof(st);
dstate_setinfo("battery.charge", "%03.0f", val);
get_belkin_field(temp, st, sizeof(st), 9);
val = atof(st);
dstate_setinfo("battery.temperature", "%03.0f", val);
get_belkin_field(temp, st, sizeof(st), 7);
val = atof(st) / 10;
dstate_setinfo("battery.voltage", "%4.1f", val);
get_belkin_field(temp, st, sizeof(st), 9);
val = atof(st);
dstate_setinfo("ups.temperature", "%03.0f", val);
send_belkin_command(STATUS, STAT_OUTPUT, "");
res = get_belkin_reply(temp);
if (res == -1)
return;
get_belkin_field(temp, st, sizeof(st), 2);
val = atof(st) / 10;
dstate_setinfo("output.frequency", "%.1f", val);
get_belkin_field(temp, st, sizeof(st), 4);
val = atof(st) / 10;
dstate_setinfo("output.voltage", "%05.1f", val);
get_belkin_field(temp, st, sizeof(st), 7);
val = atof(st);
dstate_setinfo("ups.load", "%03.0f", val);
}
static int get_belkin_reply(char *buf)
{
int ret, cnt;
int ret;
long cnt;
char tmp[8];
usleep(25000);
/* pull first 7 bytes to get data length - like ~00S004 */
ret = ser_get_buf_len(upsfd, (unsigned char *)tmp, 7, 3, 0);
/* pull first 7 bytes to get data length - like ~00D004 */
ret = ser_get_buf_len(upsfd, (unsigned char *)tmp, 7, 2, 0);
if (ret != 7) {
ser_comm_fail("Initial read returned %d bytes", ret);
@ -301,21 +124,28 @@ static int get_belkin_reply(char *buf)
}
tmp[7] = 0;
cnt = atoi(tmp + 4);
cnt = strtol(tmp + 4, NULL, 10);
upsdebugx(3, "Received: %s", tmp);
if ((cnt < 1) || (cnt > 255))
if (cnt == 0) { /* possible to have ~00R000, return empty response */
buf[0] = 0;
return 0;
}
if ((cnt < 0) || (cnt > 255)) {
return -1;
}
/* give it time to respond to us */
usleep(5000 * cnt);
ret = ser_get_buf_len(upsfd, (unsigned char *)buf, cnt, 3, 0);
ret = ser_get_buf_len(upsfd, (unsigned char *)buf, cnt, 2, 0);
buf[cnt] = 0;
upsdebugx(3, "Received: %s", buf);
if (ret != cnt) {
ser_comm_fail("Second read returned %d bytes, expected %d",
ret, cnt);
ser_comm_fail("Second read returned %d bytes, expected %ld", ret, cnt);
return -1;
}
@ -324,14 +154,206 @@ static int get_belkin_reply(char *buf)
return ret;
}
static int do_broken_rat(char *buf)
{
int ret;
long cnt;
char tmp[8];
usleep(25000);
/* pull first 7 bytes to get data length - like ~00D004 */
ret = ser_get_buf_len(upsfd, (unsigned char *)tmp, 7, 2, 0);
if (ret != 7) {
ser_comm_fail("Initial read returned %d bytes", ret);
return -1;
}
tmp[7] = 0;
cnt = strtol(tmp + 4, NULL, 10);
upsdebugx(3, "Received: %s", tmp);
if (cnt == 0) { /* possible to have ~00R000, return empty response */
buf[0] = 0;
return 0;
}
if ((cnt < 0) || (cnt > 255)) {
return -1;
}
/* give it time to respond to us */
usleep(5000 * cnt);
/* firmware 001 only sends 50 bytes instead of the proper 53 */
if (cnt == 53) {
cnt = 50;
}
ret = ser_get_buf_len(upsfd, (unsigned char *)buf, cnt, 2, 0);
buf[cnt] = 0;
upsdebugx(3, "Received: %s", buf);
if (ret != cnt) {
ser_comm_fail("Second read returned %d bytes, expected %ld", ret, cnt);
return -1;
}
ser_comm_good();
return ret;
}
/* normal idle loop - keep up with the current state of the UPS */
void upsdrv_updateinfo(void)
{
static int retry = 0;
int res;
char temp[SMALLBUF], st[SMALLBUF];
send_belkin_command(STATUS, STAT_STATUS, "");
res = get_belkin_reply(temp);
if (res < 0) {
if (retry < MAXTRIES) {
upsdebugx(1, "Communications with UPS lost: status read failed!");
retry++;
} else { /* too many retries */
upslogx(LOG_WARNING, "Communications with UPS lost: status read failed!");
dstate_datastale();
}
return;
}
if (retry) { /* previous attempt had failed */
upslogx(LOG_WARNING, "Communications with UPS re-established");
retry = 0;
}
if (res == 0) {
upsdebugx(1, "Ignoring empty return value after status query");
return;
}
status_init();
get_belkin_field(temp, st, sizeof(st), 6);
if (*st == '1') {
status_set("OFF");
}
get_belkin_field(temp, st, sizeof(st), 2);
if (*st == '1') {
status_set("OB"); /* on battery */
} else {
status_set("OL"); /* on line */
}
get_belkin_field(temp, st, sizeof(st), 16);
dstate_setinfo("ups.beeper.status", "%s", (*st == '0' ? "disabled" : "enabled"));
send_belkin_command(STATUS, STAT_BATTERY, "");
res = get_belkin_reply(temp);
if (res > 0) {
/* report the compiled in battery charge where the driver assumes the battery is low */
dstate_setinfo("battery.charge.low", "%d", LOW_BAT);
get_belkin_field(temp, st, sizeof(st), 10);
res = atoi(st);
get_belkin_field(temp, st, sizeof(st), 2);
if (*st == '1' || res < LOW_BAT) {
status_set("LB"); /* low battery */
}
get_belkin_field(temp, st, sizeof(st), 10);
dstate_setinfo("battery.charge", "%.0f", strtod(st, NULL));
get_belkin_field(temp, st, sizeof(st), 9);
dstate_setinfo("battery.temperature", "%.0f", strtod(st, NULL));
get_belkin_field(temp, st, sizeof(st), 7);
dstate_setinfo("battery.voltage", "%.1f", strtod(st, NULL) / 10);
get_belkin_field(temp, st, sizeof(st), 9);
dstate_setinfo("ups.temperature", "%.0f", strtod(st, NULL));
}
send_belkin_command(STATUS, STAT_INPUT, "");
res = get_belkin_reply(temp);
if (res > 0) {
get_belkin_field(temp, st, sizeof(st), 3);
dstate_setinfo("input.voltage", "%.1f", strtod(st, NULL) / 10);
get_belkin_field(temp, st, sizeof(st), 2);
dstate_setinfo("input.frequency", "%.1f", strtod(st, NULL) / 10);
}
send_belkin_command(STATUS, STAT_OUTPUT, "");
res = get_belkin_reply(temp);
if (res > 0) {
get_belkin_field(temp, st, sizeof(st), 2);
dstate_setinfo("output.frequency", "%.1f", strtod(st, NULL) / 10);
get_belkin_field(temp, st, sizeof(st), 4);
dstate_setinfo("output.voltage", "%.1f", strtod(st, NULL) / 10);
get_belkin_field(temp, st, sizeof(st), 7);
dstate_setinfo("ups.load", "%.0f", strtod(st, NULL));
}
send_belkin_command(STATUS, TEST_RESULT, "");
res = get_belkin_reply(temp);
if (res > 0) {
get_belkin_field(temp, st, sizeof(st), 1);
switch (*st)
{
case '0':
dstate_setinfo("ups.test.result", "%s", "No test performed");
break;
case '1':
dstate_setinfo("ups.test.result", "%s", "Passed");
break;
case '2':
dstate_setinfo("ups.test.result", "%s", "In progress");
break;
case '3':
case '4':
dstate_setinfo("ups.test.result", "%s", "10s test failed");
break;
case '5':
dstate_setinfo("ups.test.result", "%s", "deep test failed");
break;
case '6':
dstate_setinfo("ups.test.result", "%s", "Aborted");
break;
default:
upsdebugx(3, "Unhandled test status '%c'", *st);
break;
}
}
status_commit();
dstate_dataok();
}
/* power down the attached load immediately */
void upsdrv_shutdown(void)
{
int res;
res = init_communication();
if (res == -1)
if (res < 0) {
printf("Detection failed. Trying a shutdown command anyway.\n");
}
/* tested on a F6C525-SER: this works when OL and OB */
@ -347,6 +369,27 @@ void upsdrv_shutdown(void)
send_belkin_command(CONTROL, "SDA", "5");
}
/* handle "beeper.disable" */
static void do_beeper_off(void) {
int res;
char temp[SMALLBUF];
const char *arg;
/* Compare the model name, as the BUZZER_OFF argument depends on it */
send_belkin_command(STATUS, MODEL, "");
res = get_belkin_reply(temp);
if (res == -1)
return;
if (!strcmp(temp, "F6C1400-EUR")) {
arg = BUZZER_OFF2;
} else {
arg = BUZZER_OFF0;
}
send_belkin_command(CONTROL,BUZZER,arg);
}
/* handle the "load.off" with some paranoia */
static void do_off(void)
{
@ -375,6 +418,16 @@ static void do_off(void)
static int instcmd(const char *cmdname, const char *extra)
{
if (!strcasecmp(cmdname, "beeper.disable")) {
do_beeper_off();
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "beeper.enable")) {
send_belkin_command(CONTROL,BUZZER,BUZZER_ON);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "load.off")) {
do_off();
return STAT_INSTCMD_HANDLED;
@ -385,17 +438,25 @@ static int instcmd(const char *cmdname, const char *extra)
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "test.battery.start.quick")) {
send_belkin_command(CONTROL,TEST,TEST_10SEC);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "test.battery.start.deep")) {
send_belkin_command(CONTROL,TEST,TEST_DEEP);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "test.battery.stop")) {
send_belkin_command(CONTROL,TEST,TEST_CANCEL);
return STAT_INSTCMD_HANDLED;
}
upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
return STAT_INSTCMD_UNKNOWN;
}
static void set_serialDTR0RTS1(void)
{
/* set DTR to low and RTS to high */
ser_set_dtr(upsfd, 0);
ser_set_rts(upsfd, 1);
}
void upsdrv_help(void)
{
}
@ -409,8 +470,10 @@ void upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B2400);
set_serialDTR0RTS1();
/* set DTR to low and RTS to high */
ser_set_dtr(upsfd, 0);
ser_set_rts(upsfd, 1);
sleep(1);
@ -420,9 +483,10 @@ void upsdrv_initups(void)
void upsdrv_initinfo(void)
{
int res;
char temp[SMALLBUF], st[SMALLBUF];
res = init_communication();
if (res == -1) {
if (res < 0) {
fatalx(EXIT_FAILURE,
"Unable to detect an Belkin Smart protocol UPS on port %s\n"
"Check the cabling, port name or model name and try again", device_path
@ -431,11 +495,42 @@ void upsdrv_initinfo(void)
dstate_setinfo("ups.mfr", "BELKIN");
/* see what's out there */
init_ups_data();
send_belkin_command(STATUS, MODEL, "");
res = get_belkin_reply(temp);
if (res > 0) {
dstate_setinfo("ups.model", "%s", temp);
}
printf("Detected %s on %s\n", dstate_getinfo("ups.model"),
device_path);
send_belkin_command(STATUS, VERSION_CMD, "");
res = get_belkin_reply(temp);
if (res > 0) {
dstate_setinfo("ups.firmware", "%s", temp);
}
/* deal with stupid firmware that breaks RAT */
send_belkin_command(STATUS, RATING, "");
if (!strcmp(temp, "001")) {
res = do_broken_rat(temp);
} else {
res = get_belkin_reply(temp);
}
if (res > 0) {
get_belkin_field(temp, st, sizeof(st), 8);
dstate_setinfo("input.transfer.low", "%.0f", strtod(st, NULL) / 0.88);
get_belkin_field(temp, st, sizeof(st), 9);
dstate_setinfo("input.transfer.high", "%.0f", strtod(st, NULL) * 0.88);
}
dstate_addcmd("beeper.disable");
dstate_addcmd("beeper.enable");
dstate_addcmd("load.off");
dstate_addcmd("load.on");
dstate_addcmd("test.battery.start.quick");
dstate_addcmd("test.battery.start.deep");
dstate_addcmd("test.battery.stop");
upsh.instcmd = instcmd;
}

View file

@ -32,22 +32,29 @@
#define STAT_OUTPUT "STO"
#define STAT_BATTERY "STB"
#define STAT_STATUS "STA"
#define TEST_RESULT "TSR"
#define POWER_ON "RON"
#define POWER_OFF "ROF"
#define POWER_SDTYPE "SDT" /* shutdown type? */
#define POWER_CYCLE "SDA" /* shutdown, then restore */
#define BUZZER "BUZ"
#define BUZZER_ON "1"
#define BUZZER_OFF0 "0" /* Switching the buzzer off can be either 0 or 2 */
#define BUZZER_OFF2 "2" /* Seems to be used for F6c1400 */
#define TEST "TST"
#define TEST_10SEC "3"
#define TEST_DEEP "4"
#define TEST_CANCEL "0"
/* The UPS Status "low battery" comes up 10s before the UPS actually stops.
Therefore a shutdown is done at this battery % */
#define LOW_BAT 20
/* the maximum allowed number of missed replies */
#define MAXTRIES 3
/* dangerous instant commands must be reconfirmed within a 12 second window */
#define CONFIRM_DANGEROUS_COMMANDS 1
#define MINCMDTIME 3
#define MAXCMDTIME 15
static int init_communication (void);
static int init_ups_data (void);
static int get_belkin_reply (char*);
static void set_serialDTR0RTS1(void);

View file

@ -528,7 +528,7 @@ Version: 8.07
Released: 08/01/1995
*/
void upsdrv_init_nofc()
void upsdrv_init_nofc(void)
{
char tmp[256], rstring[1024];
@ -734,7 +734,7 @@ void upsdrv_init_fc(const char *fcstring)
fc.valid = 1;
}
void upsdrv_initups ()
void upsdrv_initups(void)
{
char rstring[256];

View file

@ -148,7 +148,7 @@ static inline void setinfo_int_minutes (const char *key, const char * s, size_t
}
/* set info to float value */
static inline void setinfo_float (const char *key, char * fmt, const char * s, size_t len, double factor)
static inline void setinfo_float (const char *key, const char * fmt, const char * s, size_t len, double factor)
{
char buf[10];
if (len > sizeof(buf)) len = sizeof(buf)-1;
@ -402,7 +402,7 @@ void upsdrv_makevartable(void)
}
struct {
char * val;
const char * val;
speed_t speed;
} speed_table[] = {
{"1200", B1200},

80
drivers/bestpower-mib.c Normal file
View file

@ -0,0 +1,80 @@
/* bestpower-mib.c - data to monitor Eaton Best Power Ferrups
* using earlier version of the ConnectUPS
*
* Copyright (C) 2010 - Arnaud Quette <arnaud.quette@free.fr>
*
* 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 "bestpower-mib.h"
#define BESTPOWER_MIB_VERSION "0.1"
#define BESTPOWER_OID_MODEL_NAME ".1.3.6.1.4.1.2947.1.1.2.0"
/*
* http://powerquality.eaton.com/Support/Software-Drivers/Downloads/connectivity-firmware/bestpwr2.mib
*/
static info_lkp_t bestpower_power_status[] = {
{ 1, "OL" },
{ 2, "OB" },
{ 0, "NULL" }
} ;
/* Snmp2NUT lookup table for Best Power MIB */
static snmp_info_t bestpower_mib[] = {
/* Device page */
{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "ups",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
/*.1.3.6.1.4.1.2947.1.1.1.0 = STRING: "Ferrups"
.1.3.6.1.4.1.2947.1.1.2.0 = STRING: "FE850VA"*/
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, BESTPOWER_OID_MODEL_NAME,
"Best Ferrups", SU_FLAG_STATIC, NULL, NULL },
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.5.0",
"", SU_FLAG_STATIC, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.7.0",
"", SU_FLAG_STATIC, NULL },
{ "ups.power", 0, 1, ".1.3.6.1.4.1.2947.1.1.3.0", "",
0, NULL },
{ "ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.8.0", "",
0, NULL },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.2.1.0", "",
0 /*SU_STATUS_PWR*/, &bestpower_power_status[0] },
/* Battery runtime is expressed in minutes */
{ "battery.runtime", 0, 60.0, ".1.3.6.1.4.1.2947.1.2.3.0", "",
0, NULL },
/* The elapsed time in seconds since the
* UPS has switched to battery power */
{ "battery.runtime.elapsed", 0, 1.0, ".1.3.6.1.4.1.2947.1.2.2.0", "",
0, NULL },
{ "battery.voltage", 0, 0.1, ".1.3.6.1.4.1.2947.1.2.4.0", "",
0, NULL },
{ "battery.current", 0, 0.1, ".1.3.6.1.4.1.2947.1.2.5.0", "",
0, NULL },
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL, NULL }
} ;
mib2nut_info_t bestpower = { "bestpower", BESTPOWER_MIB_VERSION, "",
BESTPOWER_OID_MODEL_NAME, bestpower_mib };

9
drivers/bestpower-mib.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef BESTPOWER_MIB_H
#define BESTPOWER_MIB_H
#include "main.h"
#include "snmp-ups.h"
extern mib2nut_info_t bestpower;
#endif /* BESTPOWER_MIB_H */

View file

@ -211,6 +211,11 @@ static int blazer_status(const char *cmd)
dstate_setinfo(status[i].var, status[i].fmt, status[i].conv(val, NULL));
}
if (!val) {
upsdebugx(2, "%s: parsing failed", __func__);
return -1;
}
if (strspn(val, "01") != 8) {
upsdebugx(2, "Invalid status [%s]", val);
return -1;
@ -517,11 +522,11 @@ static void blazer_initbattery(void)
val = getval("runtimecal");
if (val) {
int rh, lh, rl, ll;
double rh, lh, rl, ll;
time(&lastpoll);
if (sscanf(val, "%d,%d,%d,%d", &rh, &lh, &rl, &ll) < 4) {
if (sscanf(val, "%lf,%lf,%lf,%lf", &rh, &lh, &rl, &ll) < 4) {
fatalx(EXIT_FAILURE, "Insufficient parameters for runtimecal");
}
@ -533,10 +538,10 @@ static void blazer_initbattery(void)
fatalx(EXIT_FAILURE, "Parameter out of range (load)");
}
batt.runt.exp = log((double)rl / rh) / log((double)lh / ll);
batt.runt.exp = log(rl / rh) / log(lh / ll);
upsdebugx(2, "battery runtime exponent : %.3f", batt.runt.exp);
batt.runt.nom = rh * pow(lh/100, batt.runt.exp);
batt.runt.nom = rh * pow(lh / 100, batt.runt.exp);
upsdebugx(2, "battery runtime nominal : %.1f", batt.runt.nom);
} else {

View file

@ -61,7 +61,7 @@ static usb_device_id_t cps_usb_device_table[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *cps_battvolt_fun(double value)
static const char *cps_battvolt_fun(double value)
{
static char buf[8];
@ -161,15 +161,15 @@ static hid_info_t cps_hid2nut[] = {
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *cps_format_model(HIDDevice_t *hd) {
static const char *cps_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static char *cps_format_mfr(HIDDevice_t *hd) {
static const char *cps_format_mfr(HIDDevice_t *hd) {
return hd->Vendor ? hd->Vendor : "CPS";
}
static char *cps_format_serial(HIDDevice_t *hd) {
static const char *cps_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}

View file

@ -95,8 +95,8 @@ static void* battery_type_handler(LibHalChangeSet *cs, char* battery_type);
/* Structure to lookup between NUT and HAL data */
typedef struct {
char *nut_name; /* NUT variable name */
char *hal_name; /* HAL variable name */
const char *nut_name; /* NUT variable name */
const char *hal_name; /* HAL variable name */
int hal_type; /* HAL variable type */
void *(*fun)(LibHalChangeSet *cs,
char *value); /* conversion function. */

View file

@ -20,6 +20,7 @@
#ifndef DSTATE_HAL_H_SEEN
#define DSTATE_HAL_H_SEEN 1
#include "state.h"
#include "attribute.h"
/*#include "parseconf.h"*/
@ -45,11 +46,11 @@ gboolean dbus_init_local (void);
#define HAL_WARNING
/* track client connections */
/* struct conn_t {
/* typedef struct conn_s {
* int fd;
* PCONF_CTX_t ctx;
* void *next;
*};
* struct conn_s *next;
*} conn_t;
*/
extern struct ups_handler upsh;
@ -67,8 +68,8 @@ int dstate_delinfo(const char *var);
int dstate_delenum(const char *var, const char *val);
int dstate_delcmd(const char *cmd);
void dstate_free(void);
const struct st_tree_t *dstate_getroot(void);
const struct cmdlist_t *dstate_getcmdlist(void);
const st_tree_t *dstate_getroot(void);
const cmdlist_t *dstate_getcmdlist(void);
void dstate_dataok(void);
void dstate_datastale(void);

View file

@ -35,9 +35,9 @@
static int sockfd = -1, stale = 1, alarm_active = 0;
static char *sockfn = NULL;
static char status_buf[ST_MAX_VALUE_LEN], alarm_buf[ST_MAX_VALUE_LEN];
static struct st_tree_t *dtree_root = NULL;
static struct conn_t *connhead = NULL;
static struct cmdlist_t *cmdhead = NULL;
static st_tree_t *dtree_root = NULL;
static conn_t *connhead = NULL;
static cmdlist_t *cmdhead = NULL;
struct ups_handler upsh;
@ -139,7 +139,7 @@ static int sock_open(const char *fn)
return fd;
}
static void sock_disconnect(struct conn_t *conn)
static void sock_disconnect(conn_t *conn)
{
close(conn->fd);
@ -165,7 +165,7 @@ static void send_to_all(const char *fmt, ...)
int ret;
char buf[ST_SOCK_BUF_LEN];
va_list ap;
struct conn_t *conn, *cnext;
conn_t *conn, *cnext;
va_start(ap, fmt);
ret = vsnprintf(buf, sizeof(buf), fmt, ap);
@ -190,7 +190,7 @@ static void send_to_all(const char *fmt, ...)
}
}
static int send_to_one(struct conn_t *conn, const char *fmt, ...)
static int send_to_one(conn_t *conn, const char *fmt, ...)
{
int ret;
va_list ap;
@ -221,7 +221,7 @@ static int send_to_one(struct conn_t *conn, const char *fmt, ...)
static void sock_connect(int sock)
{
int fd, ret;
struct conn_t *conn;
conn_t *conn;
struct sockaddr_un sa;
socklen_t salen;
@ -266,10 +266,10 @@ static void sock_connect(int sock)
upsdebugx(3, "new connection on fd %d", fd);
}
static int st_tree_dump_conn(struct st_tree_t *node, struct conn_t *conn)
static int st_tree_dump_conn(st_tree_t *node, conn_t *conn)
{
int ret;
struct enum_t *etmp;
enum_t *etmp;
if (!node) {
return 1; /* not an error */
@ -325,9 +325,9 @@ static int st_tree_dump_conn(struct st_tree_t *node, struct conn_t *conn)
return 1; /* everything's OK here ... */
}
static int cmd_dump_conn(struct conn_t *conn)
static int cmd_dump_conn(conn_t *conn)
{
struct cmdlist_t *cmd;
cmdlist_t *cmd;
for (cmd = cmdhead; cmd; cmd = cmd->next) {
if (!send_to_one(conn, "ADDCMD %s\n", cmd->name)) {
@ -338,7 +338,7 @@ static int cmd_dump_conn(struct conn_t *conn)
return 1;
}
static int sock_arg(struct conn_t *conn, int numarg, char **arg)
static int sock_arg(conn_t *conn, int numarg, char **arg)
{
if (numarg < 1) {
return 0;
@ -415,7 +415,7 @@ static int sock_arg(struct conn_t *conn, int numarg, char **arg)
return 0;
}
static void sock_read(struct conn_t *conn)
static void sock_read(conn_t *conn)
{
int i, ret;
char buf[SMALLBUF];
@ -463,7 +463,7 @@ static void sock_read(struct conn_t *conn)
static void sock_close(void)
{
struct conn_t *conn, *cnext;
conn_t *conn, *cnext;
if (sockfd != -1) {
close(sockfd);
@ -487,15 +487,15 @@ static void sock_close(void)
/* interface */
void dstate_init(const char *prog, const char *port)
void dstate_init(const char *prog, const char *devname)
{
char sockname[SMALLBUF];
/* do this here for now */
signal(SIGPIPE, SIG_IGN);
if (port) {
snprintf(sockname, sizeof(sockname), "%s/%s-%s", dflt_statepath(), prog, port);
if (devname) {
snprintf(sockname, sizeof(sockname), "%s/%s-%s", dflt_statepath(), prog, devname);
} else {
snprintf(sockname, sizeof(sockname), "%s/%s", dflt_statepath(), prog);
}
@ -511,7 +511,7 @@ int dstate_poll_fds(struct timeval timeout, int extrafd)
int ret, maxfd, overrun = 0;
fd_set rfds;
struct timeval now;
struct conn_t *conn, *cnext;
conn_t *conn, *cnext;
FD_ZERO(&rfds);
FD_SET(sockfd, &rfds);
@ -632,7 +632,7 @@ int dstate_addenum(const char *var, const char *fmt, ...)
void dstate_setflags(const char *var, int flags)
{
struct st_tree_t *sttmp;
st_tree_t *sttmp;
char flist[SMALLBUF];
/* find the dtree node for var */
@ -666,7 +666,7 @@ void dstate_setflags(const char *var, int flags)
void dstate_setaux(const char *var, int aux)
{
struct st_tree_t *sttmp;
st_tree_t *sttmp;
/* find the dtree node for var */
sttmp = state_tree_find(dtree_root, var);
@ -756,12 +756,12 @@ void dstate_free(void)
sock_close();
}
const struct st_tree_t *dstate_getroot(void)
const st_tree_t *dstate_getroot(void)
{
return dtree_root;
}
const struct cmdlist_t *dstate_getcmdlist(void)
const cmdlist_t *dstate_getcmdlist(void)
{
return cmdhead;
}

View file

@ -20,6 +20,7 @@
#ifndef DSTATE_H_SEEN
#define DSTATE_H_SEEN 1
#include "state.h"
#include "attribute.h"
#include "parseconf.h"
@ -29,16 +30,16 @@
#define DS_MAX_READ 256 /* don't read forever from upsd */
/* track client connections */
struct conn_t {
typedef struct conn_s {
int fd;
PCONF_CTX_t ctx;
struct conn_t *prev;
struct conn_t *next;
};
struct conn_s *prev;
struct conn_s *next;
} conn_t;
extern struct ups_handler upsh;
void dstate_init(const char *prog, const char *port);
void dstate_init(const char *prog, const char *devname);
int dstate_poll_fds(struct timeval timeout, int extrafd);
int dstate_setinfo(const char *var, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
@ -52,8 +53,8 @@ int dstate_delinfo(const char *var);
int dstate_delenum(const char *var, const char *val);
int dstate_delcmd(const char *cmd);
void dstate_free(void);
const struct st_tree_t *dstate_getroot(void);
const struct cmdlist_t *dstate_getcmdlist(void);
const st_tree_t *dstate_getroot(void);
const cmdlist_t *dstate_getcmdlist(void);
void dstate_dataok(void);
void dstate_datastale(void);

View file

@ -1,7 +1,7 @@
/* dummy-ups.c - NUT testing driver and repeater
/* dummy-ups.c - NUT simulation and device repeater driver
Copyright (C)
2005 - 2009 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
2005 - 2010 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
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
@ -39,11 +39,12 @@
#include "upsclient.h"
#include "dummy-ups.h"
#define DRIVER_NAME "Dummy UPS driver"
#define DRIVER_VERSION "0.10"
#define DRIVER_NAME "Device simulation and repeater driver"
#define DRIVER_VERSION "0.12"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
upsdrv_info_t upsdrv_info =
{
DRIVER_NAME,
DRIVER_VERSION,
"Arnaud Quette <arnaud.quette@gmail.com>",
@ -51,12 +52,12 @@ upsdrv_info_t upsdrv_info = {
{ NULL }
};
#define MODE_UNKNOWN 0
#define MODE_NONE 0
#define MODE_DUMMY 1 /* use the embedded defintion or a definition file */
#define MODE_REPEATER 2 /* use libupsclient to repeat an UPS */
#define MODE_META 3 /* consolidate data from several UPSs (TBS) */
int mode=MODE_UNKNOWN;
int mode=MODE_NONE;
/* parseconf context, for dummy mode using a file */
PCONF_CTX_t *ctx=NULL;
@ -76,7 +77,7 @@ static int upsclient_update_vars(void);
/* connection information */
static char *client_upsname = NULL, *hostname = NULL;
static UPSCONN_t *ups = NULL;
int port;
static int port;
/* Driver functions */
@ -84,11 +85,14 @@ void upsdrv_initinfo(void)
{
dummy_info_t *item;
switch (mode) {
switch (mode)
{
case MODE_DUMMY:
/* Initialise basic essential variables */
for ( item = nut_data ; item->info_type != NULL ; item++ ) {
if (item->drv_flags & DU_FLAG_INIT) {
for ( item = nut_data ; item->info_type != NULL ; item++ )
{
if (item->drv_flags & DU_FLAG_INIT)
{
dstate_setinfo(item->info_type, "%s", item->default_value);
dstate_setflags(item->info_type, item->info_flags);
@ -110,28 +114,33 @@ void upsdrv_initinfo(void)
case MODE_META:
case MODE_REPEATER:
/* Obtain the target name */
if (upscli_splitname(device_path, &client_upsname, &hostname, &port) != 0) {
if (upscli_splitname(device_path, &client_upsname, &hostname, &port) != 0)
{
fatalx(EXIT_FAILURE, "Error: invalid UPS definition.\nRequired format: upsname[@hostname[:port]]");
}
/* Connect to the target */
ups = xmalloc(sizeof(*ups));
if (upscli_connect(ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0) {
if (upscli_connect(ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0)
{
fatalx(EXIT_FAILURE, "Error: %s", upscli_strerror(ups));
}
else {
else
{
upsdebugx(1, "Connected to %s@%s", client_upsname, hostname);
}
if (upsclient_update_vars() < 0) {
if (upsclient_update_vars() < 0)
{
/* check for an old upsd */
if (upscli_upserror(ups) == UPSCLI_ERR_UNKCOMMAND) {
if (upscli_upserror(ups) == UPSCLI_ERR_UNKCOMMAND)
{
fatalx(EXIT_FAILURE, "Error: upsd is too old to support this query");
}
fatalx(EXIT_FAILURE, "Error: %s", upscli_strerror(ups));
}
/* FIXME: commands and settables! */
/* FIXME: commands and settable variable! */
break;
default:
case MODE_UNKNOWN:
case MODE_NONE:
fatalx(EXIT_FAILURE, "no suitable definition found!");
break;
}
@ -146,7 +155,8 @@ void upsdrv_updateinfo(void)
sleep(1);
switch (mode) {
switch (mode)
{
case MODE_DUMMY:
/* Now get user's defined variables */
if (parse_data_file(upsfd) >= 0)
@ -155,18 +165,26 @@ void upsdrv_updateinfo(void)
case MODE_META:
case MODE_REPEATER:
if (upsclient_update_vars() > 0)
{
dstate_dataok();
else {
}
else
{
/* try to reconnect */
upscli_disconnect(ups);
if (upscli_connect(ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0) {
if (upscli_connect(ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0)
{
upsdebugx(1, "Error reconnecting: %s", upscli_strerror(ups));
}
else {
else
{
upsdebugx(1, "Reconnected");
}
}
break;
case MODE_NONE:
default:
break;
}
}
@ -198,14 +216,16 @@ void upsdrv_makevartable(void)
void upsdrv_initups(void)
{
/* check the running mode... */
if (strchr(device_path, '@')) {
if (strchr(device_path, '@'))
{
upsdebugx(1, "Repeater mode");
mode = MODE_REPEATER;
dstate_setinfo("driver.parameter.mode", "repeater");
/* if there is at least one more => MODE_META... */
/* FIXME: if there is at least one more => MODE_META... */
}
else {
upsdebugx(1, "Dummy mode");
else
{
upsdebugx(1, "Dummy (simulation) mode");
mode = MODE_DUMMY;
dstate_setinfo("driver.parameter.mode", "dummy");
}
@ -213,12 +233,15 @@ void upsdrv_initups(void)
void upsdrv_cleanup(void)
{
if ( (mode == MODE_META) || (mode == MODE_REPEATER) ) {
if (ups) {
if ( (mode == MODE_META) || (mode == MODE_REPEATER) )
{
if (ups)
{
upscli_disconnect(ups);
}
if (ctx) {
if (ctx)
{
pconf_finish(ctx);
free(ctx);
}
@ -235,7 +258,8 @@ static int setvar(const char *varname, const char *val)
upsdebugx(2, "entering setvar(%s, %s)", varname, val);
if (!strncmp(varname, "ups.status", 10)) {
if (!strncmp(varname, "ups.status", 10))
{
status_init();
/* FIXME: split and check values (support multiple values), à la usbhid-ups */
status_set(val);
@ -245,29 +269,38 @@ static int setvar(const char *varname, const char *val)
}
/* Check variable validity */
if (!is_valid_data(varname)) {
if (!is_valid_data(varname))
{
upsdebugx(2, "setvar: invalid variable name (%s)", varname);
return STAT_SET_UNKNOWN;
}
/* Check value validity */
if (!is_valid_value(varname, val)) {
if (!is_valid_value(varname, val))
{
upsdebugx(2, "setvar: invalid value (%s) for variable (%s)", val, varname);
return STAT_SET_UNKNOWN;
}
dstate_setinfo(varname, "%s", val);
if ( (item = find_info(varname)) != NULL) {
dstate_setflags(item->info_type, item->info_flags);
/* Set max length for strings, if needed */
if (item->info_flags & ST_FLAG_STRING)
dstate_setaux(item->info_type, item->info_len);
/* If value is empty, remove the variable (FIXME: do we need
* a magic word?) */
if (strlen(val) == 0)
{
dstate_delinfo(varname);
}
else
{
dstate_setinfo(varname, "%s", val);
if ( (item = find_info(varname)) != NULL)
{
dstate_setflags(item->info_type, item->info_flags);
/* Set max length for strings, if needed */
if (item->info_flags & ST_FLAG_STRING)
dstate_setaux(item->info_type, item->info_len);
}
}
return STAT_SET_HANDLED;
}
@ -288,15 +321,17 @@ static int upsclient_update_vars(void)
ret = upscli_list_start(ups, numq, query);
if (ret < 0) {
if (ret < 0)
{
upsdebugx(1, "Error: %s (%i)", upscli_strerror(ups), upscli_upserror(ups));
return ret;
}
while (upscli_list_next(ups, numq, query, &numa, &answer) == 1) {
while (upscli_list_next(ups, numq, query, &numa, &answer) == 1)
{
/* VAR <upsname> <varname> <val> */
if (numa < 4) {
if (numa < 4)
{
upsdebugx(1, "Error: insufficient data (got %d args, need at least 4)", numa);
}
@ -315,7 +350,8 @@ static dummy_info_t *find_info(const char *varname)
{
dummy_info_t *item;
for ( item = nut_data ; item->info_type != NULL ; item++ ) {
for ( item = nut_data ; item->info_type != NULL ; item++ )
{
if (!strcasecmp(item->info_type, varname))
return item;
}
@ -330,13 +366,15 @@ static int is_valid_data(const char* varname)
{
dummy_info_t *item;
if ( (item = find_info(varname)) != NULL) {
return 1;
if ( (item = find_info(varname)) != NULL)
{
return 1;
}
/* FIXME: we need to have the full data set before
* enforcing controls! */
* enforcing controls! We also need a way to automate
* the update / sync process (with cmdvartab?!) */
upsdebugx(1, "Unknown data. Commiting anyway...");
return 1;
/* return 0;*/
@ -347,14 +385,16 @@ static int is_valid_value(const char* varname, const char *value)
{
dummy_info_t *item;
if ( (item = find_info(varname)) != NULL) {
if ( (item = find_info(varname)) != NULL)
{
/* FIXME: test enum or bound against value */
return 1;
}
/* FIXME: we need to have the full data set before
* enforcing controls! */
* enforcing controls! We also need a way to automate
* the update / sync process (with cmdvartab?) */
upsdebugx(1, "Unknown data. Commiting value anyway...");
return 1;
/* return 0;*/
@ -372,7 +412,7 @@ static void upsconf_err(const char *errmsg)
static int parse_data_file(int upsfd)
{
char fn[SMALLBUF];
char *ptr, *var_value;
char *ptr, *var_value = (char*) xmalloc(MAX_STRING_SIZE);
int value_args = 0, counter;
time_t now;
@ -380,14 +420,15 @@ static int parse_data_file(int upsfd)
upsdebugx(1, "entering parse_data_file()");
if (now < next_update) {
if (now < next_update)
{
upsdebugx(1, "leaving (paused)...");
return 1;
}
/* initialise everything, to loop back at the beginning of the file */
if (ctx == NULL) {
/* initialise everything, to loop back at the beginning of the file */
if (ctx == NULL)
{
ctx = (PCONF_CTX_t *)xmalloc(sizeof(PCONF_CTX_t));
if (device_path[0] == '/')
@ -402,14 +443,15 @@ static int parse_data_file(int upsfd)
fn, ctx->errmsg);
}
/* reset the next call time, so that we can loop back on the file
/* Reset the next call time, so that we can loop back on the file
* if there is no blocking action (ie TIMER) until the end of the file */
next_update = -1;
/* now start or continue parsing... */
while (pconf_file_next(ctx)) {
if (pconf_parse_error(ctx)) {
/* Now start or continue parsing... */
while (pconf_file_next(ctx))
{
if (pconf_parse_error(ctx))
{
upsdebugx(2, "Parse error: %s:%d: %s",
fn, ctx->linenum, ctx->errmsg);
continue;
@ -419,8 +461,9 @@ static int parse_data_file(int upsfd)
if (ctx->numargs < 1)
continue;
/* process actions (only "TIMER" ATM) */
if (!strncmp(ctx->arglist[0], "TIMER", 5)) {
/* Process actions (only "TIMER" ATM) */
if (!strncmp(ctx->arglist[0], "TIMER", 5))
{
/* TIMER <seconds> will wait "seconds" before
* continuing the parsing */
int delay = atoi (ctx->arglist[1]);
@ -430,55 +473,63 @@ static int parse_data_file(int upsfd)
break;
}
/* Remove the ":" after the variable name */
/* Remove ":" suffix, after the variable name */
if ((ptr = strchr(ctx->arglist[0], ':')) != NULL)
*ptr = '\0';
upsdebugx(3, "parse_data_file: variable \"%s\" with %d args", ctx->arglist[0], (int)ctx->numargs);
upsdebugx(3, "parse_data_file: variable \"%s\" with %d args",
ctx->arglist[0], (int)ctx->numargs);
/* skip the driver.* collection data */
if (!strncmp(ctx->arglist[0], "driver.", 7)) {
/* Skip the driver.* collection data */
if (!strncmp(ctx->arglist[0], "driver.", 7))
{
upsdebugx(2, "parse_data_file: skipping %s", ctx->arglist[0]);
continue;
}
/* From there, we get varname in arg[0], and values in other arg[1...x] */
/* FIXME: iteration on arg[2, 3, ...]
if ST_FLAG_STRING => all args are the value
if ups.status, each arg is a value to be set (ie OB LB) + check against enum
else int/float values need to be check against bound/enum
*/
var_value = (char*) xmalloc(MAX_STRING_SIZE);
for (counter = 1, value_args = ctx->numargs ; counter < value_args ; counter++) {
if (counter != 1) /* don't append the first space separator */
strncat(var_value, " ", MAX_STRING_SIZE);
strncat(var_value, ctx->arglist[counter], MAX_STRING_SIZE);
}
/* special handler for status */
if (!strncmp( ctx->arglist[0], "ups.status", 10)) {
if (!strncmp( ctx->arglist[0], "ups.status", 10))
{
status_init();
setvar(ctx->arglist[0], var_value);
for (counter = 1, value_args = ctx->numargs ;
counter < value_args ; counter++)
{
status_set(ctx->arglist[counter]);
}
status_commit();
}
else {
if (setvar(ctx->arglist[0], var_value) == STAT_SET_UNKNOWN) {
else
{
memset(var_value, 0, MAX_STRING_SIZE);
for (counter = 1, value_args = ctx->numargs ;
counter < value_args ; counter++)
{
if (counter != 1) /* don't append the first space separator */
strncat(var_value, " ", 1);
strncat(var_value, ctx->arglist[counter], MAX_STRING_SIZE);
}
if (setvar(ctx->arglist[0], var_value) == STAT_SET_UNKNOWN)
{
upsdebugx(2, "parse_data_file: can't add \"%s\" with value \"%s\"\nError: %s",
ctx->arglist[0], var_value, ctx->errmsg);
}
else {
else
{
upsdebugx(3, "parse_data_file: added \"%s\" with value \"%s\"",
ctx->arglist[0], var_value);
}
}
}
/* cleanup parseconf if there is no pending action */
if (next_update == -1) {
/* Cleanup parseconf if there is no pending action */
if (next_update == -1)
{
pconf_finish(ctx);
free(ctx);
ctx=NULL;
free(var_value);
}
return 1;
}

View file

@ -1,7 +1,7 @@
/* dummy-ups.h - NUT testing driver and repeater
Copyright (C)
2005 - 2009 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
2005 - 2010 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
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
@ -23,6 +23,7 @@
* as the "port" parameter (only the file name, not the path).
* The format of this file is the same as an upsc dump:
* <varname>: <value>
* FIXME: use cmdvartab for conformance checking
* ...
* Once the driver is loaded:
* - change the value by using upsrw
@ -36,7 +37,7 @@
/* --------------------------------------------------------------- */
typedef struct {
char *status_str; /* ups.status string */
const char *status_str; /* ups.status string */
int status_value; /* ups.status value */
} status_lkp_t;
@ -81,11 +82,11 @@ typedef struct {
/* --------------------------------------------------------------- */
typedef struct {
char *info_type; /* NUT variable name */
const char *info_type; /* NUT variable name */
int info_flags; /* NUT flags (to set in addinfo) */
float info_len; /* if ST_FLAG_STRING: length of the string */
/* if HU_TYPE_CMD: command value ; multiplier (or max len) otherwise */
char *default_value; /* if HU_FLAG_ABSENT: default value ; format otherwise */
const char *default_value; /* if HU_FLAG_ABSENT: default value ; format otherwise */
int drv_flags; /* */
char **var_values; /* all possible values for this variable (allows to check data...) */
/* FIXME: "void *" so we can have bound or enum */

View file

@ -42,15 +42,15 @@ static hid_info_t explore_hid2nut[] =
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *explore_format_model(HIDDevice_t *hd) {
static const char *explore_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static char *explore_format_mfr(HIDDevice_t *hd) {
static const char *explore_format_mfr(HIDDevice_t *hd) {
return hd->Vendor;
}
static char *explore_format_serial(HIDDevice_t *hd) {
static const char *explore_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}

View file

@ -117,7 +117,7 @@ int sec_cmd(const char mode, const char *command, char *msgbuf, int *buflen)
return ret;
}
void addquery(char *cmd, int field, int varnum, int pollflag)
void addquery(const char *cmd, int field, int varnum, int pollflag)
{
int q;
@ -297,17 +297,20 @@ void upsdrv_updateinfo(void)
void upsdrv_shutdown(void)
{
int msg_len;
char msgbuf[SMALLBUF];
int msg_len;
msg_len = snprintf(msgbuf, sizeof(msgbuf), "-1");
sec_cmd(SEC_SETCMD, SEC_SHUTDOWN, msgbuf, &msg_len);
msg_len = 2;
sec_cmd (SEC_SETCMD,SEC_SHUTDOWN,"-1",&msg_len);
msg_len = 1 ;
sec_cmd (SEC_SETCMD,SEC_AUTORESTART,"1",&msg_len);
msg_len = 1;
sec_cmd (SEC_SETCMD, SEC_SHUTTYPE,"2",&msg_len);
msg_len = 1;
sec_cmd (SEC_SETCMD,SEC_SHUTDOWN,"5",&msg_len);
msg_len = snprintf(msgbuf, sizeof(msgbuf), "1");
sec_cmd(SEC_SETCMD, SEC_AUTORESTART, msgbuf, &msg_len);
msg_len = snprintf(msgbuf, sizeof(msgbuf), "2");
sec_cmd(SEC_SETCMD, SEC_SHUTTYPE,msgbuf, &msg_len);
msg_len = snprintf(msgbuf, sizeof(msgbuf), "5");
sec_cmd(SEC_SETCMD, SEC_SHUTDOWN, msgbuf, &msg_len);
}
/*

View file

@ -64,7 +64,7 @@
#define FLAG_POLL 0 /* For commands that polled normaly */
#define FLAG_POLLONCE 1 /* For commands that only polled once */
/* Some baud rates for setup_serial() */
struct baud_rate_t {
struct {
int rate;
int name;
} baud_rates[] = {
@ -80,11 +80,11 @@ struct baud_rate_t {
/* macro for checking whether a variable is supported */
struct sec_varlist_t {
char *setcmd; /* INFO_x define from shared.h */
char *name; /* Human readable text (also in shared-tables.h) */
struct {
const char *setcmd; /* INFO_x define from shared.h */
const char *name; /* Human readable text (also in shared-tables.h) */
int unit; /* Variable should be divided by this */
char *cmd; /* Command to send to pool/set variable */
const char *cmd; /* Command to send to pool/set variable */
int field; /* Which returned field variable corresponsd to */
int size; /* string length/integer max/enum count */
int poll; /* poll flag */
@ -191,8 +191,8 @@ struct sec_varlist_t {
#define SEC_POLL 1
#define SEC_POLLONCE 0
struct sec_querylist_t {
char *command; /* sec command */
struct {
const char *command; /* sec command */
int varnum[SEC_MAXFIELDS]; /* sec variable number for each field */
int pollflag;
} sec_querylist[SEC_QUERYLIST_LEN];

View file

@ -27,7 +27,9 @@
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif /* __cplusplus */
#include "hidtypes.h"
@ -63,7 +65,9 @@ void SetValue(const HIDData_t *pData, unsigned char *Buf, long Value);
#ifdef __cplusplus
/* *INDENT-OFF* */
} /* extern "C" */
/* *INDENT-ON* */
#endif /* __cplusplus */
#endif

View file

@ -26,7 +26,9 @@
#define HIDTYPES_H
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif /* __cplusplus */
#include <sys/types.h>
@ -143,7 +145,9 @@ typedef struct {
} HIDDesc_t;
#ifdef __cplusplus
/* *INDENT-OFF* */
} /* extern "C" */
/* *INDENT-ON* */
#endif /* __cplusplus */
#endif /* HIDTYPES_H */

169
drivers/idowell-hid.c Normal file
View file

@ -0,0 +1,169 @@
/* idowell-hid.c - subdriver to monitor iDowell 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>
*
* Note: this subdriver was initially generated as a "stub" by the
* path-to-subdriver script. It must be customized.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "usbhid-ups.h"
#include "idowell-hid.h"
#include "main.h" /* for getval() */
#include "usb-common.h"
#define IDOWELL_HID_VERSION "iDowell HID 0.1"
/* FIXME: experimental flag to be put in upsdrv_info */
/* iDowell */
#define IDOWELL_VENDORID 0x075d
/* USB IDs device table */
static usb_device_id_t idowell_usb_device_table[] = {
/* iDowell */
{ USB_DEVICE(IDOWELL_VENDORID, 0x0300), NULL },
/* Terminating entry */
{ -1, -1, NULL }
};
/* --------------------------------------------------------------- */
/* Vendor-specific usage table */
/* --------------------------------------------------------------- */
/* IDOWELL usage table */
static usage_lkp_t idowell_usage_lkp[] = {
{ NULL, 0 }
};
static usage_tables_t idowell_utab[] = {
idowell_usage_lkp,
hid_usage_lkp,
NULL,
};
/* --------------------------------------------------------------- */
/* HID2NUT lookup table */
/* --------------------------------------------------------------- */
static hid_info_t idowell_hid2nut[] = {
#ifdef DEBUG
{ "unmapped.ups.flow.[4].flowid", 0, 0, "UPS.Flow.[4].FlowID", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powerconverter.output.outputid", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.capacitygranularity1", 0, 0, "UPS.PowerSummary.CapacityGranularity1", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.capacitymode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.flowid", 0, 0, "UPS.PowerSummary.FlowID", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.fullchargecapacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.imanufacturer", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.iproduct", 0, 0, "UPS.PowerSummary.iProduct", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.iserialnumber", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.powersummaryid", 0, 0, "UPS.PowerSummary.PowerSummaryID", NULL, "%.0f", 0, NULL },
{ "unmapped.ups.powersummary.presentstatus.undefined", 0, 0, "UPS.PowerSummary.PresentStatus.Undefined", NULL, "%.0f", 0, NULL },
#endif /* DEBUG */
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.CommunicationLost", NULL, NULL, 0, commfault_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, 0, off_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, 0, commfault_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, 0, overload_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info },
/* battery page */
{ "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL },
{ "battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_STATIC , NULL }, /* Read only */
{ "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL },
{ "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion },
/* UPS page */
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.timer.start", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL },
{ "ups.power.nominal", 0, 0, "UPS.Flow.[4].ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL },
/* input page */
{ "input.transfer.high", 0, 0, "UPS.PowerConverter.Output.HighVoltageTransfer", NULL, "%.0f", HU_FLAG_STATIC, NULL },
{ "input.transfer.low", 0, 0, "UPS.PowerConverter.Output.LowVoltageTransfer", NULL, "%.0f", HU_FLAG_STATIC, NULL },
/* output page */
{ "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.1f", 0, NULL },
{ "output.voltage.nominal", 0, 0, "UPS.Flow.[4].ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL },
{ "output.frequency.nominal", 0, 0, "UPS.Flow.[4].ConfigFrequency", NULL, "%.0f", HU_FLAG_STATIC, NULL },
/* instant commands */
{ "load.off.delay", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL },
{ "load.on.delay", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL },
{ "shutdown.stop", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL },
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static const char *idowell_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static const char *idowell_format_mfr(HIDDevice_t *hd) {
return hd->Vendor ? hd->Vendor : "iDowell";
}
static const char *idowell_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 idowell_claim(HIDDevice_t *hd)
{
int status = is_usb_device_supported(idowell_usb_device_table, hd->VendorID, hd->ProductID);
switch (status)
{
case POSSIBLY_SUPPORTED:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
return 1;
}
possibly_supported("iDowell", hd);
return 0;
case SUPPORTED:
return 1;
case NOT_SUPPORTED:
default:
return 0;
}
}
subdriver_t idowell_subdriver = {
IDOWELL_HID_VERSION,
idowell_claim,
idowell_utab,
idowell_hid2nut,
idowell_format_model,
idowell_format_mfr,
idowell_format_serial,
};

30
drivers/idowell-hid.h Normal file
View file

@ -0,0 +1,30 @@
/* idowell-hid.h - subdriver to monitor iDowell 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>
*
* 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 IDOWELL_HID_H
#define IDOWELL_HID_H
#include "usbhid-ups.h"
extern subdriver_t idowell_subdriver;
#endif /* IDOWELL_HID_H */

View file

@ -3,6 +3,7 @@
* Copyright (C) 2002-2006
* Arnaud Quette <arnaud.quette@free.fr>
* Niels Baggesen <niels@baggesen.net>
* Arjen de Korte <adkorte-guest@alioth.debian.org>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
*
@ -28,231 +29,248 @@
#define IETF_MIB_VERSION "1.3"
/* SNMP OIDs set */
#define IETF_OID_UPS_MIB "1.3.6.1.2.1.33"
#define IETF_OID_MFR_NAME "1.3.6.1.2.1.33.1.1.1.0" /* UPS-MIB::upsIdentManufacturer.0 */
#define IETF_OID_MODEL_NAME "1.3.6.1.2.1.33.1.1.2.0" /* UPS-MIB::upsIdentModel.0 */
#define IETF_OID_FIRMREV "1.3.6.1.2.1.33.1.1.3.0" /* UPS-MIB::upsIdentUPSSoftwareVersion.0 */
#define IETF_OID_AGENTREV "1.3.6.1.2.1.33.1.1.4.0" /* UPS-MIB::upsIdentAgentSoftwareVersion.0 */
#define IETF_OID_IDENT "1.3.6.1.2.1.33.1.1.5.0" /* UPS-MIB::upsIdentName.0 */
#define IETF_OID_UPS_MIB "1.3.6.1.2.1.33.1."
#define IETF_OID_BATT_STATUS "1.3.6.1.2.1.33.1.2.1.0" /* UPS-MIB::upsBatteryStatus.0 */
#define IETF_OID_BATT_RUNTIME "1.3.6.1.2.1.33.1.2.3.0" /* UPS-MIB::upsEstimatedMinutesRemaining.0 */
#define IETF_OID_BATT_CHARGE "1.3.6.1.2.1.33.1.2.4.0" /* UPS-MIB::upsEstimatedChargeRemaining.0 */
#define IETF_OID_BATT_VOLTAGE "1.3.6.1.2.1.33.1.2.5.0" /* UPS-MIB::upsBatteryVoltage.0 */
#define IETF_OID_BATT_CURRENT "1.3.6.1.2.1.33.1.2.6.0" /* UPS-MIB::upsBatteryCurrent.0 */
#define IETF_OID_BATT_TEMP "1.3.6.1.2.1.33.1.2.7.0" /* UPS-MIB::upsBatteryTemperature.0 */
/* #define DEBUG */
#define IETF_OID_IN_LINEBADS "1.3.6.1.2.1.33.1.3.1.0" /* UPS-MIB::upsInputLineBads.0 */
#define IETF_OID_IN_LINES "1.3.6.1.2.1.33.1.3.2.0" /* UPS-MIB::upsInputNumLines.0 */
#define IETF_OID_IN_FREQ "1.3.6.1.2.1.33.1.3.3.1.2" /* UPS-MIB::upsInputFrequency */
#define IETF_OID_IN_VOLTAGE "1.3.6.1.2.1.33.1.3.3.1.3" /* UPS-MIB::upsInputVoltage */
#define IETF_OID_IN_CURRENT "1.3.6.1.2.1.33.1.3.3.1.4" /* UPS-MIB::upsInputCurrent */
#define IETF_OID_IN_POWER "1.3.6.1.2.1.33.1.3.3.1.5" /* UPS-MIB::upsInputTruePower */
#define IETF_OID_POWER_STATUS "1.3.6.1.2.1.33.1.4.1.0" /* UPS-MIB::upsOutputSource.0 */
#define IETF_OID_OUT_FREQUENCY "1.3.6.1.2.1.33.1.4.2.0" /* UPS-MIB::upsOutputFrequency.0 */
#define IETF_OID_OUT_LINES "1.3.6.1.2.1.33.1.4.3.0" /* UPS-MIB::upsOutputNumLines.0 */
#define IETF_OID_OUT_VOLTAGE "1.3.6.1.2.1.33.1.4.4.1.2" /* UPS-MIB::upsOutputVoltage */
#define IETF_OID_OUT_CURRENT "1.3.6.1.2.1.33.1.4.4.1.3" /* UPS-MIB::upsOutputCurrent */
#define IETF_OID_OUT_POWER "1.3.6.1.2.1.33.1.4.4.1.4" /* UPS-MIB::upsOutputPower */
#define IETF_OID_LOAD_LEVEL "1.3.6.1.2.1.33.1.4.4.1.5" /* UPS-MIB::upsOutputPercentLoad */
#define IETF_OID_UPS_TEST_ID "1.3.6.1.2.1.33.1.7.1" /* UPS-MIB::upsTestID */
#define IETF_OID_UPS_TEST_RES "1.3.6.1.2.1.33.1.7.3" /* UPS-MIB::upsTestResultsSummary */
#define IETF_OID_UPS_TEST_RESDET "1.3.6.1.2.1.33.1.7.4" /* UPS-MIB::upsTestResultsDetail */
#define IETF_OID_UPS_TEST_NOTEST "1.3.6.1.2.1.33.1.7.7.1" /* UPS-MIB::upsTestNoTestInitiated */
#define IETF_OID_UPS_TEST_ABORT "1.3.6.1.2.1.33.1.7.7.2" /* UPS-MIB::upsTestAbortTestInProgress */
#define IETF_OID_UPS_TEST_GSTEST "1.3.6.1.2.1.33.1.7.7.3" /* UPS-MIB::upsTestGeneralSystemsTest */
#define IETF_OID_UPS_TEST_QBATT "1.3.6.1.2.1.33.1.7.7.4" /* UPS-MIB::upsTestQuickBatteryTest */
#define IETF_OID_UPS_TEST_DBATT "1.3.6.1.2.1.33.1.7.7.5" /* UPS-MIB::upsTestDeepBatteryCalibration */
#define IETF_OID_CONF_VOLTAGE "1.3.6.1.2.1.33.1.9.3.0" /* UPS-MIB::upsConfigOutputVoltage.0 */
#define IETF_OID_CONF_OUT_VA "1.3.6.1.2.1.33.1.9.5.0" /* UPS-MIB::upsConfigOutputVA.0 */
#define IETF_OID_CONF_RUNTIME_LOW "1.3.6.1.2.1.33.1.9.7.0" /* UPS-MIB::upsConfigLowBattTime.0 */
/* Defines for IETF_OID_POWER_STATUS (1) */
static info_lkp_t ietf_pwr_info[] = {
{ 1, "" /* other */ },
{ 2, "OFF" /* none */ },
{ 3, "OL" /* normal */ },
{ 4, "OL BYPASS" /* bypass */ },
{ 5, "OB" /* battery */ },
{ 6, "OL BOOST" /* booster */ },
{ 7, "OL TRIM" /* reducer */ },
{ 0, "NULL" }
} ;
/* Defines for IETF_OID_BATT_STATUS (2) */
static info_lkp_t ietf_batt_info[] = {
static info_lkp_t ietf_battery_info[] = {
{ 1, "" /* unknown */ },
{ 2, "" /* batteryNormal */},
{ 3, "LB" /* batteryLow */ },
{ 4, "LB" /* batteryDepleted */ },
{ 5, "" /* unknown */ },
{ 6, "RB" /* batteryError */},
{ 0, "NULL" }
} ;
};
/* Defines for IETF_OID_TEST_RES */
static info_lkp_t ietf_test_res_info[] = {
{ 1, "Done and passed" },
{ 2, "Done and warning" },
{ 3, "Done and error" },
{ 4, "Aborted" },
{ 5, "In progress" },
{ 6, "No test initiated" },
static info_lkp_t ietf_power_source_info[] = {
{ 1, "" /* other */ },
{ 2, "OFF" /* none */ },
{ 3, "OL" /* normal */ },
{ 4, "OL BYPASS" /* bypass */ },
{ 5, "OB" /* battery */ },
{ 6, "OL BOOST" /* booster */ },
{ 7, "OL TRIM" /* reducer */ },
{ 0, "NULL" }
} ;
};
#define IETF_OID_SD_AFTER_DELAY "1.3.6.1.2.1.33.1.8.2" /* UPS-MIB::upsShutdownAfterDelay */
#define IETF_OFF_DO 0
#define IETF_OID_ALARM_OB "1.3.6.1.2.1.33.1.6.3.2" /* UPS-MIB::upsAlarmOnBattery */
#define IETF_OID_ALARM_LB "1.3.6.1.2.1.33.1.6.3.3" /* UPS-MIB::upsAlarmLowBattery */
static info_lkp_t ietf_alarm_ob[] = {
{ 1, "OB" },
static info_lkp_t ietf_overload_info[] = {
{ 1, "OVER" }, /* output overload */
{ 0, "NULL" }
} ;
};
static info_lkp_t ietf_alarm_lb[] = {
{ 1, "LB" },
static info_lkp_t ietf_test_active_info[] = {
{ 1, "" }, /* upsTestNoTestsInitiated */
{ 2, "" }, /* upsTestAbortTestInProgress */
{ 3, "TEST" }, /* upsTestGeneralSystemsTest */
{ 4, "TEST" }, /* upsTestQuickBatteryTest */
{ 5, "CAL" }, /* upsTestDeepBatteryCalibration */
{ 0, "NULL" }
} ;
};
/* Missing data
CAL - UPS is performing calibration
OVER - UPS is overloaded
FSD - UPS is in forced shutdown state (slaves take note)
*/
static info_lkp_t ietf_test_result_info[] = {
{ 1, "done and passed" },
{ 2, "done and warning" },
{ 3, "done and error" },
{ 4, "aborted" },
{ 5, "in progress" },
{ 6, "no test initiated" },
{ 0, "NULL" }
};
/* Snmp2NUT lookup table */
#ifdef DEBUG
static info_lkp_t ietf_shutdown_type_info[] = {
{ 1, "output" },
{ 2, "system" },
{ 0, "NULL" }
};
#endif
static info_lkp_t ietf_yes_no_info[] = {
{ 1, "yes" },
{ 2, "no" },
{ 0, "NULL" }
};
static info_lkp_t ietf_beeper_status_info[] = {
{ 1, "disabled" },
{ 2, "enabled" },
{ 3, "muted" },
{ 0, "NULL" }
};
/* Snmp2NUT lookup table info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar */
static snmp_info_t ietf_mib[] = {
/* UPS page */
/* info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_MFR_NAME, "Generic",
SU_FLAG_STATIC, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_MODEL_NAME, "Generic SNMP UPS",
SU_FLAG_STATIC, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_FIRMREV, "",
SU_FLAG_STATIC, NULL },
{ "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_AGENTREV, "",
SU_FLAG_STATIC, NULL },
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_IDENT, "",
SU_FLAG_STATIC, NULL },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_POWER_STATUS, "OFF",
SU_STATUS_PWR, &ietf_pwr_info[0] },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_BATT_STATUS, "",
SU_STATUS_BATT, &ietf_alarm_ob[0] },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_BATT_STATUS, "",
SU_STATUS_BATT, &ietf_alarm_lb[0] },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_BATT_STATUS, "",
SU_STATUS_BATT, &ietf_batt_info[0] },
{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_TEST_RESDET, "",
0, NULL },
{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_TEST_RES, "",
0, ietf_test_res_info },
/* The Device Identification group */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "1.1.0", "Generic", SU_FLAG_STATIC, NULL }, /* upsIdentManufacturer */
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "1.2.0", "Generic SNMP UPS", SU_FLAG_STATIC, NULL }, /* upsIdentModel */
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "1.3.0", "", SU_FLAG_STATIC, NULL }, /* upsIdentUPSSoftwareVersion */
{ "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "1.4.0", "", SU_FLAG_STATIC, NULL }, /* upsIdentAgentSoftwareVersion */
#ifdef DEBUG
{ "debug.upsIdentName", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "1.5.0", "", 0, NULL }, /* upsIdentName */
{ "debug.upsIdentAttachedDevices", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "1.6.0", "", 0, NULL }, /* upsIdentAttachedDevices */
#endif
/* Battery Group */
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "2.1.0", "", SU_STATUS_BATT, ietf_battery_info }, /* upsBatteryStatus */
#ifdef DEBUG
{ "debug.upsSecondsOnBattery", 0, 1.0, IETF_OID_UPS_MIB "2.2.0", "", 0, NULL }, /* upsSecondsOnBattery */
#endif
{ "battery.runtime", 0, 60.0, IETF_OID_UPS_MIB "2.3.0", "", 0, NULL }, /* upsEstimatedMinutesRemaining */
{ "battery.charge", 0, 1, IETF_OID_UPS_MIB "2.4.0", "", 0, NULL }, /* upsEstimatedChargeRemaining */
{ "battery.voltage", 0, 0.1, IETF_OID_UPS_MIB "2.5.0", "", 0, NULL }, /* upsBatteryVoltage */
{ "battery.current", 0, 0.1, IETF_OID_UPS_MIB "2.6.0", "", 0, NULL }, /* upsBatteryCurrent */
{ "battery.temperature", 0, 1.0, IETF_OID_UPS_MIB "2.7.0", "", 0, NULL }, /* upsBatteryTemperature */
/* Battery page */
{ "battery.charge", 0, 1.0, IETF_OID_BATT_CHARGE, "",
0, NULL },
{ "battery.runtime", 0, 60.0, IETF_OID_BATT_RUNTIME, "",
0, NULL },
{ "battery.runtime.low", ST_FLAG_RW, 1, IETF_OID_CONF_RUNTIME_LOW, "",
0, NULL },
{ "battery.voltage", 0, 0.1, IETF_OID_BATT_VOLTAGE, "",
0, NULL },
{ "battery.current", 0, 0.1, IETF_OID_BATT_CURRENT, "",
0, NULL },
{ "battery.temperature", 0, 1.0, IETF_OID_BATT_TEMP, "",
0, NULL },
/* Input Group */
#ifdef DEBUG
{ "debug.upsInputLineBads", 0, 1.0, IETF_OID_UPS_MIB "3.1.0", "", 0, NULL }, /* upsInputLineBads */
#endif
{ "input.phases", 0, 1.0, IETF_OID_UPS_MIB "3.2.0", "", SU_FLAG_SETINT, NULL, &input_phases }, /* upsInputNumLines */
#ifdef DEBUG
{ "debug.upsInputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.1.1", "", SU_INPUT_1, NULL }, /* upsInputLineIndex */
{ "debug.[1].upsInputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.1.1", "", SU_INPUT_3, NULL },
{ "debug.[2].upsInputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.1.2", "", SU_INPUT_3, NULL },
{ "debug.[3].upsInputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.1.3", "", SU_INPUT_3, NULL },
#endif
{ "input.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.1", "", SU_INPUT_1, NULL }, /* upsInputFrequency */
{ "input.L1.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.1", "", SU_INPUT_3, NULL },
{ "input.L2.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.2", "", SU_INPUT_3, NULL },
{ "input.L3.frequency", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.2.3", "", SU_INPUT_3, NULL },
{ "input.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.1", "", SU_INPUT_1, NULL }, /* upsInputVoltage */
{ "input.L1-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.3.3", "", SU_INPUT_3, NULL },
{ "input.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.1", "", SU_INPUT_1, NULL }, /* upsInputCurrent */
{ "input.L1.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.1", "", SU_INPUT_3, NULL },
{ "input.L2.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.2", "", SU_INPUT_3, NULL },
{ "input.L3.current", 0, 0.1, IETF_OID_UPS_MIB "3.3.1.4.3", "", SU_INPUT_3, NULL },
{ "input.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.1", "", SU_INPUT_1, NULL }, /* upsInputTruePower */
{ "input.L1.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.1", "", SU_INPUT_3, NULL },
{ "input.L2.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.2", "", SU_INPUT_3, NULL },
{ "input.L3.realpower", 0, 1.0, IETF_OID_UPS_MIB "3.3.1.5.3", "", SU_INPUT_3, NULL },
/* Output page */
{ "output.phases", 0, 1.0, IETF_OID_OUT_LINES, "",
SU_FLAG_SETINT, NULL, &output_phases },
{ "output.frequency", 0, 0.1, IETF_OID_OUT_FREQUENCY, "",
0, NULL },
{ "output.voltage", 0, 1.0, IETF_OID_OUT_VOLTAGE ".1", "",
SU_OUTPUT_1, NULL },
{ "output.L1-N.voltage", 0, 1.0, IETF_OID_OUT_VOLTAGE ".1", "",
SU_OUTPUT_3, NULL },
{ "output.L2-N.voltage", 0, 1.0, IETF_OID_OUT_VOLTAGE ".2", "",
SU_OUTPUT_3, NULL },
{ "output.L3-N.voltage", 0, 1.0, IETF_OID_OUT_VOLTAGE ".3", "",
SU_OUTPUT_3, NULL },
{ "output.current", 0, 0.1, IETF_OID_OUT_CURRENT ".1", "",
SU_OUTPUT_1, NULL },
{ "output.L1.current", 0, 0.1, IETF_OID_OUT_CURRENT ".1", "",
SU_OUTPUT_3, NULL },
{ "output.L2.current", 0, 0.1, IETF_OID_OUT_CURRENT ".2", "",
SU_OUTPUT_3, NULL },
{ "output.L3.current", 0, 0.1, IETF_OID_OUT_CURRENT ".3", "",
SU_OUTPUT_3, NULL },
{ "output.power", 0, 1.0, IETF_OID_OUT_POWER ".1", "",
SU_OUTPUT_1, NULL },
{ "output.L1.power", 0, 1.0, IETF_OID_OUT_POWER ".1", "",
SU_OUTPUT_3, NULL },
{ "output.L2.power", 0, 1.0, IETF_OID_OUT_POWER ".2", "",
SU_OUTPUT_3, NULL },
{ "output.L3.power", 0, 1.0, IETF_OID_OUT_POWER ".3", "",
SU_OUTPUT_3, NULL },
{ "ups.load", 0, 1.0, IETF_OID_LOAD_LEVEL ".1", "",
SU_OUTPUT_1, NULL },
{ "output.L1.power.percent", 0, 1.0, IETF_OID_LOAD_LEVEL ".1", "",
SU_OUTPUT_3, NULL },
{ "output.L2.power.percent", 0, 1.0, IETF_OID_LOAD_LEVEL ".2", "",
SU_OUTPUT_3, NULL },
{ "output.L3.power.percent", 0, 1.0, IETF_OID_LOAD_LEVEL ".3", "",
SU_OUTPUT_3, NULL },
/* Output Group */
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "4.1.0", "", SU_STATUS_PWR, ietf_power_source_info }, /* upsOutputSource */
{ "output.frequency", 0, 0.1, IETF_OID_UPS_MIB "4.2.0", "", 0, NULL }, /* upsOutputFrequency */
{ "output.phases", 0, 1.0, IETF_OID_UPS_MIB "4.3.0", "", SU_FLAG_SETINT, NULL, &output_phases }, /* upsOutputNumLines */
#ifdef DEBUG
{ "debug.upsOutputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.1.1", "", SU_OUTPUT_1, NULL }, /* upsOutputLineIndex */
{ "debug.[1].upsOutputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.1.1", "", SU_OUTPUT_3, NULL },
{ "debug.[2].upsOutputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.1.2", "", SU_OUTPUT_3, NULL },
{ "debug.[3].upsOutputLineIndex", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.1.3", "", SU_OUTPUT_3, NULL },
#endif
{ "output.voltage", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.2.1", "", SU_OUTPUT_1, NULL }, /* upsOutputVoltage */
{ "output.L1-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.2.1", "", SU_OUTPUT_3, NULL },
{ "output.L2-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.2.2", "", SU_OUTPUT_3, NULL },
{ "output.L3-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.2.3", "", SU_OUTPUT_3, NULL },
{ "output.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.1", "", SU_OUTPUT_1, NULL }, /* upsOutputCurrent */
{ "output.L1.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.current", 0, 0.1, IETF_OID_UPS_MIB "4.4.1.3.3", "", SU_OUTPUT_3, NULL },
{ "output.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.1", "", SU_OUTPUT_1, NULL }, /* upsOutputPower */
{ "output.L1.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.realpower", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.4.3", "", SU_OUTPUT_3, NULL },
{ "ups.load", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.5.1", "", SU_OUTPUT_1, NULL }, /* upsOutputPercentLoad */
{ "output.L1.power.percent", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.5.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.power.percent", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.5.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.power.percent", 0, 1.0, IETF_OID_UPS_MIB "4.4.1.5.3", "", SU_OUTPUT_3, NULL },
/* Input page */
{ "input.phases", 0, 1.0, IETF_OID_IN_LINES, "",
SU_FLAG_SETINT, NULL, &input_phases },
{ "input.frequency", 0, 0.1, IETF_OID_IN_FREQ ".1", "",
SU_INPUT_1, NULL },
{ "input.voltage", 0, 1.0, IETF_OID_IN_VOLTAGE ".1", "",
SU_INPUT_1, NULL },
{ "input.L1-N.voltage", 0, 1.0, IETF_OID_IN_VOLTAGE ".1", "",
SU_INPUT_3, NULL },
{ "input.L2-N.voltage", 0, 1.0, IETF_OID_IN_VOLTAGE ".2", "",
SU_INPUT_3, NULL },
{ "input.L3-N.voltage", 0, 1.0, IETF_OID_IN_VOLTAGE ".3", "",
SU_INPUT_3, NULL },
{ "input.current", 0, 0.1, IETF_OID_IN_CURRENT ".1", "",
SU_INPUT_1, NULL },
{ "input.L1.current", 0, 0.1, IETF_OID_IN_CURRENT ".1", "",
SU_INPUT_3, NULL },
{ "input.L2.current", 0, 0.1, IETF_OID_IN_CURRENT ".2", "",
SU_INPUT_3, NULL },
{ "input.L3.current", 0, 0.1, IETF_OID_IN_CURRENT ".3", "",
SU_INPUT_3, NULL },
{ "input.realpower", 0, 0.1, IETF_OID_IN_POWER ".1", "",
SU_INPUT_1, NULL },
{ "input.L1.realpower", 0, 0.1, IETF_OID_IN_POWER ".1", "",
SU_INPUT_3, NULL },
{ "input.L2.realpower", 0, 0.1, IETF_OID_IN_POWER ".2", "",
SU_INPUT_3, NULL },
{ "input.L3.realpower", 0, 0.1, IETF_OID_IN_POWER ".3", "",
SU_INPUT_3, NULL },
{ "input.quality", 0, 1.0, IETF_OID_IN_LINEBADS, "",
0, NULL },
/* Bypass Group */
{ "input.bypass.phases", 0, 1.0, IETF_OID_UPS_MIB "5.2.0", "", SU_FLAG_SETINT, NULL, &bypass_phases }, /* upsBypassNumLines */
{ "input.bypass.frequency", 0, 0.1, IETF_OID_UPS_MIB "5.1.0", "", SU_BYPASS_1 | SU_BYPASS_3, NULL }, /* upsBypassFrequency */
#ifdef DEBUG
{ "debug.upsBypassLineIndex", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.1.1", "", SU_BYPASS_1, NULL }, /* upsBypassLineIndex */
{ "debug.[1].upsBypassLineIndex", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.1.1", "", SU_BYPASS_3, NULL },
{ "debug.[2].upsBypassLineIndex", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.1.2", "", SU_BYPASS_3, NULL },
{ "debug.[3].upsBypassLineIndex", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.1.3", "", SU_BYPASS_3, NULL },
#endif
{ "input.bypass.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.3.1", "", SU_BYPASS_1, NULL }, /* upsBypassVoltage */
{ "input.bypass.L1-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.3.1", "", SU_BYPASS_3, NULL },
{ "input.bypass.L2-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.3.2", "", SU_BYPASS_3, NULL },
{ "input.bypass.L3-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.3.3", "", SU_BYPASS_3, NULL },
{ "input.bypass.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.4.1", "", SU_BYPASS_1, NULL }, /* upsBypassCurrent */
{ "input.bypass.L1.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.4.1", "", SU_BYPASS_3, NULL },
{ "input.bypass.L2.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.4.2", "", SU_BYPASS_3, NULL },
{ "input.bypass.L3.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.4.3", "", SU_BYPASS_3, NULL },
{ "input.bypass.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.5.1", "", SU_BYPASS_1, NULL }, /* upsBypassPower */
{ "input.bypass.L1.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.5.1", "", SU_BYPASS_3, NULL },
{ "input.bypass.L2.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.5.2", "", SU_BYPASS_3, NULL },
{ "input.bypass.L3.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.5.3", "", SU_BYPASS_3, NULL },
/* instant commands. */
{ "load.off", 0, IETF_OFF_DO, IETF_OID_SD_AFTER_DELAY, "",
SU_TYPE_CMD, NULL },
/* write the OID of the battery test into the test initiator OID */
{ "test.battery.start.quick", 0, SU_INFOSIZE, IETF_OID_UPS_TEST_ID, IETF_OID_UPS_TEST_QBATT,
SU_TYPE_CMD, NULL },
/* write the OID of the battery test into the test initiator OID */
{ "test.battery.start.deep", 0, SU_INFOSIZE, IETF_OID_UPS_TEST_ID, IETF_OID_UPS_TEST_DBATT,
SU_TYPE_CMD, NULL },
/* { CMD_SHUTDOWN, 0, IETF_OFF_GRACEFUL, IETF_OID_OFF, "", 0, NULL }, */
/* Alarm Group */
#ifdef DEBUG
{ "debug.upsAlarmsPresent", 0, 1.0, IETF_OID_UPS_MIB "6.1.0", "", 0, NULL }, /* upsAlarmsPresent */
{ "debug.upsAlarmBatteryBad", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.1", "", 0, NULL }, /* upsAlarmBatteryBad */
{ "debug.upsAlarmOnBattery", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.2", "", 0, NULL }, /* upsAlarmOnBattery */
{ "debug.upsAlarmLowBattery", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.3", "", 0, NULL }, /* upsAlarmLowBattery */
{ "debug.upsAlarmDepletedBattery", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.4", "", 0, NULL }, /* upsAlarmDepletedBattery */
{ "debug.upsAlarmTempBad", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.5", "", 0, NULL }, /* upsAlarmTempBad */
{ "debug.upsAlarmInputBad", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.6", "", 0, NULL }, /* upsAlarmInputBad */
{ "debug.upsAlarmOutputBad", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.7", "", 0, NULL }, /* upsAlarmOutputBad */
#endif
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.8", "", 0, ietf_overload_info }, /* upsAlarmOutputOverload */
#ifdef DEBUG
{ "debug.upsAlarmOnBypass", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.9", "", 0, NULL }, /* upsAlarmOnBypass */
{ "debug.upsAlarmBypassBad", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.10", "", 0, NULL }, /* upsAlarmBypassBad */
{ "debug.upsAlarmOutputOffAsRequested", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.11", "", 0, NULL }, /* upsAlarmOutputOffAsRequested */
{ "debug.upsAlarmUpsOffAsRequested", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.12", "", 0, NULL }, /* upsAlarmUpsOffAsRequested */
{ "debug.upsAlarmChargerFailed", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.13", "", 0, NULL }, /* upsAlarmChargerFailed */
{ "debug.upsAlarmUpsOutputOff", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.14", "", 0, NULL }, /* upsAlarmUpsOutputOff */
{ "debug.upsAlarmUpsSystemOff", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.15", "", 0, NULL }, /* upsAlarmUpsSystemOff */
{ "debug.upsAlarmFanFailure", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.16", "", 0, NULL }, /* upsAlarmFanFailure */
{ "debug.upsAlarmFuseFailure", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.17", "", 0, NULL }, /* upsAlarmFuseFailure */
{ "debug.upsAlarmGeneralFault", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.18", "", 0, NULL }, /* upsAlarmGeneralFault */
{ "debug.upsAlarmDiagnosticTestFailed", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.19", "", 0, NULL }, /* upsAlarmDiagnosticTestFailed */
{ "debug.upsAlarmCommunicationsLost", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.20", "", 0, NULL }, /* upsAlarmCommunicationsLost */
{ "debug.upsAlarmAwaitingPower", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.21", "", 0, NULL }, /* upsAlarmAwaitingPower */
{ "debug.upsAlarmShutdownPending", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.22", "", 0, NULL }, /* upsAlarmShutdownPending */
{ "debug.upsAlarmShutdownImminent", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.23", "", 0, NULL }, /* upsAlarmShutdownImminent */
{ "debug.upsAlarmTestInProgress", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "6.3.24", "", 0, NULL }, /* upsAlarmTestInProgress */
#endif
/* Test Group */
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "7.1.0", "", 0, ietf_test_active_info }, /* upsTestId */
{ "test.battery.stop", 0, 0, IETF_OID_UPS_MIB "7.1.0", IETF_OID_UPS_MIB "7.7.2", SU_TYPE_CMD, NULL }, /* upsTestAbortTestInProgress */
{ "test.battery.start", 0, 0, IETF_OID_UPS_MIB "7.1.0", IETF_OID_UPS_MIB "7.7.3", SU_TYPE_CMD, NULL }, /* upsTestGeneralSystemsTest */
{ "test.battery.start.quick", 0, 0, IETF_OID_UPS_MIB "7.1.0", IETF_OID_UPS_MIB "7.7.4", SU_TYPE_CMD, NULL }, /* upsTestQuickBatteryTest */
{ "test.battery.start.deep", 0, 0, IETF_OID_UPS_MIB "7.1.0", IETF_OID_UPS_MIB "7.7.5", SU_TYPE_CMD, NULL }, /* upsTestDeepBatteryCalibration */
#ifdef DEBUG
{ "debug.upsTestSpinLock", 0, 1.0, IETF_OID_UPS_MIB "7.2.0", "", 0, NULL }, /* upsTestSpinLock */
#endif
{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "7.3.0", "", 0, ietf_test_result_info }, /* upsTestResultsSummary */
#ifdef DEBUG
{ "debug.upsTestResultsDetail", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "7.4.0", "", 0, NULL }, /* upsTestResultsDetail */
{ "debug.upsTestStartTime", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "7.5.0", "", 0, NULL }, /* upsTestStartTime */
{ "debug.upsTestElapsedTime", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "7.6.0", "", 0, NULL }, /* upsTestElapsedTime */
#endif
/* Control Group */
#ifdef DEBUG
{ "debug.upsShutdownType", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "8.1.0", "", 0, ietf_shutdown_type_info }, /* upsShutdownType */
#endif
{ "ups.timer.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 8, IETF_OID_UPS_MIB "8.2.0", "", 0, NULL }, /* upsShutdownAfterDelay*/
{ "load.off", 0, 0, IETF_OID_UPS_MIB "8.2.0", "", SU_TYPE_CMD, NULL },
{ "ups.timer.start", ST_FLAG_STRING | ST_FLAG_RW, 8, IETF_OID_UPS_MIB "8.3.0", "", 0, NULL }, /* upsStartupAfterDelay */
{ "load.on", 0, 0, IETF_OID_UPS_MIB "8.3.0", "", SU_TYPE_CMD, NULL },
{ "ups.timer.reboot", ST_FLAG_STRING | ST_FLAG_RW, 8, IETF_OID_UPS_MIB "8.4.0", "", 0, NULL }, /* upsRebootWithDuration */
{ "ups.start.auto", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "8.5.0", "", 0, ietf_yes_no_info }, /* upsAutoRestart */
/* Configuration Group */
{ "input.voltage.nominal", 0, 1.0, IETF_OID_UPS_MIB "9.1.0", "", 0, NULL }, /* upsConfigInputVoltage */
{ "input.frequency.nominal", 0, 0.1, IETF_OID_UPS_MIB "9.2.0", "", 0, NULL }, /* upsConfigInputFreq */
{ "output.voltage.nominal", 0, 1.0, IETF_OID_UPS_MIB "9.3.0", "", 0, NULL }, /* upsConfigOutputVoltage */
{ "output.frequency.nominal", 0, 0.1, IETF_OID_UPS_MIB "9.4.0", "", 0, NULL }, /* upsConfigOutputFreq */
{ "output.power.nominal", 0, 1.0, IETF_OID_UPS_MIB "9.5.0", "", 0, NULL }, /* upsConfigOutputVA */
{ "output.realpower.nominal", 0, 1.0, IETF_OID_UPS_MIB "9.6.0", "", 0, NULL }, /* upsConfigOutputPower */
{ "battery.runtime.low", 0, 60.0, IETF_OID_UPS_MIB "9.7.0", "", 0, NULL }, /* upsConfigLowBattTime */
{ "beeper.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "9.8.0", "", 0, ietf_beeper_status_info }, /* upsConfigAudibleStatus */
{ "beeper.disable", 0, 1, IETF_OID_UPS_MIB "9.8.0", "", SU_TYPE_CMD, NULL },
{ "beeper.enable", 0, 2, IETF_OID_UPS_MIB "9.8.0", "", SU_TYPE_CMD, NULL },
{ "beeper.mute", 0, 3, IETF_OID_UPS_MIB "9.8.0", "", SU_TYPE_CMD, NULL },
{ "input.transfer.low", 0, 1.0, IETF_OID_UPS_MIB "9.9.0", "", 0, NULL }, /* upsConfigLowVoltageTransferPoint */
{ "input.transfer.high", 0, 1.0, IETF_OID_UPS_MIB "9.10.0", "", 0, NULL }, /* upsConfigHighVoltageTransferPoint */
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }
};
mib2nut_info_t ietf = { "ietf", IETF_MIB_VERSION, IETF_OID_POWER_STATUS, IETF_OID_MFR_NAME, ietf_mib };
mib2nut_info_t ietf = { "ietf", IETF_MIB_VERSION, IETF_OID_UPS_MIB "4.1.0", IETF_OID_UPS_MIB "1.1.0", ietf_mib };

View file

@ -49,7 +49,7 @@ static struct {
float temperature;
} battery;
static int ivt_status()
static int ivt_status(void)
{
char reply[SMALLBUF];
int ret, i, j = 0;

View file

@ -155,7 +155,7 @@ static int refresh_report_buffer(reportbuf_t *rbuf, hid_dev_handle_t udev, HIDDa
}
/* broken report descriptors are common, so store whatever we can */
memcpy(rbuf->data[id], buf, rbuf->len[id]);
memcpy(rbuf->data[id], buf, (r < rbuf->len[id]) ? r : rbuf->len[id]);
if (rbuf->len[id] != r) {
upsdebugx(2, "%s: expected %d bytes, but got %d instead", __func__, rbuf->len[id], r);
@ -221,7 +221,7 @@ static int file_report_buffer(reportbuf_t *rbuf, unsigned char *buf, int buflen)
int id = buf[0];
/* broken report descriptors are common, so store whatever we can */
memcpy(rbuf->data[id], buf, rbuf->len[id]);
memcpy(rbuf->data[id], buf, (buflen < rbuf->len[id]) ? buflen : rbuf->len[id]);
if (rbuf->len[id] != buflen) {
upsdebugx(2, "%s: expected %d bytes, but got %d instead", __func__, rbuf->len[id], buflen);
@ -299,7 +299,7 @@ void HIDDumpTree(hid_dev_handle_t udev, usage_tables_t *utab)
/* Get data value */
if (HIDGetDataValue(udev, pData, &value, MAX_TS) == 1) {
upsdebugx(1, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %f",
upsdebugx(1, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %g",
HIDGetDataItem(pData, utab), HIDDataType(pData), pData->ReportID, pData->Offset, pData->Size, value);
continue;
}

View file

@ -192,7 +192,7 @@ int libshut_get_interrupt(int upsfd, unsigned char *buf,
void libshut_close(int upsfd);
/* FIXME */
char * shut_strerror() { return ""; }
const char * shut_strerror(void) { return ""; }
/*!
* From SHUT specifications

View file

@ -54,8 +54,8 @@ typedef struct SHUTDevice_s {
* shut_communication_subdriver_s: structure to describe the communication routines
*/
typedef struct shut_communication_subdriver_s {
char *name; /* name of this subdriver */
char *version; /* version of this subdriver */
const char *name; /* name of this subdriver */
const char *version; /* version of this subdriver */
int (*open)(int *upsfd, /* try to open the next available */
SHUTDevice_t *curDevice, /* device matching USBDeviceMatcher_t */
char *device_path,

View file

@ -43,8 +43,8 @@ extern upsdrv_info_t comm_upsdrv_info;
* @name: can be either "shut" for Serial HID UPS Transfer (from MGE) or "usb"
*/
typedef struct usb_communication_subdriver_s {
char *name; /* name of this subdriver */
char *version; /* version of this subdriver */
const char *name; /* name of this subdriver */
const char *version; /* version of this subdriver */
int (*open)(usb_dev_handle **sdevp, /* try to open the next available */
USBDevice_t *curDevice, /* device matching USBDeviceMatcher_t */
USBDeviceMatcher_t *matcher,

View file

@ -1,4 +1,4 @@
/* liebertgxt2.c - driver for Liebert GXT2, using the ESP2 protocol
/* liebert-esp2.c - driver for Liebert UPS, using the ESP-II protocol
*
* Copyright (C)
* 2009 Richard Gregory <r.gregory liverpool ac uk>
@ -21,9 +21,10 @@
#include "main.h"
#include "serial.h"
#include "timehead.h"
#include "nut_stdint.h"
#define DRIVER_NAME "Liebert GXT2 serial UPS driver"
#define DRIVER_VERSION "0.01"
#define DRIVER_NAME "Liebert ESP-II serial UPS driver"
#define DRIVER_VERSION "0.02"
static int instcmd(const char *cmdname, const char *extra);
static int setvar(const char *varname, const char *val);
@ -40,7 +41,7 @@ upsdrv_info_t upsdrv_info = {
static const unsigned char
/* Bit field information provided by Spiros Ioannou */
/* Ordered on MSB to LSB. Shown as DESCRIPTION (bit number), starting at 0. */
cmd_bitfield1[] = { 1,148,2,1,1,153 }, /* INPUT_OVERVOLTAGE, BATTERY_TEST_STATE, OVERTEMP_WARNING, INRUSH_LIMIT_ON, UTILITY_STATE, ON_INVERTER, DC_DC_CONVERTER_STATE, PFC_ON */
cmd_bitfield1[] = { 1,148,2,1,1,153 }, /* ON_BATTERY(8), INPUT_OVERVOLTAGE(7), BATTERY_TEST_STATE(6), OVERTEMP_WARNING(5), INRUSH_LIMIT_ON(4), UTILITY_STATE(3), ON_INVERTER(2), DC_DC_CONVERTER_STATE(1), PFC_ON(0) */
cmd_bitfield2[] = { 1,148,2,1,2,154 }, /* BUCK_ON (9), DIAG_LINK_SET(7), BOOST_ON(6), REPLACE_BATTERY(5), BATTERY_LIFE_ENHANCER_ON(4), BATTERY_CHARGED (1), ON_BYPASS (0) */
cmd_bitfield3[] = { 1,148,2,1,3,155 }, /* CHECK_AIR_FILTER (10), BAD_BYPASS_PWR (8), OUTPUT_OVERVOLTAGE (7), OUTPUT_UNDERVOLTAGE (6), LOW_BATTERY (5), CHARGER_FAIL (3), SHUTDOWN_PENDING (2), BAD_INPUT_FREQ (1), UPS_OVERLOAD (0) */
cmd_bitfield7[] = { 1,148,2,1,7,159 }, /* AMBIENT_OVERTEMP (2) */
@ -94,16 +95,17 @@ void upsdrv_initinfo(void)
{
struct {
const char *var;
const int len;
} vartab[] = {
{ "ups.model" },
{ "ups.serial" },
{ "ups.mfr.date" },
{ "ups.firmware" },
{ "ups.model", 15 },
{ "ups.firmware", 8 },
{ "ups.serial", 10 },
{ "ups.mfr.date", 4 },
{ NULL }
};
char buf[LARGEBUF], *s;
int i;
char buf[LARGEBUF];
int i, index;
dstate_setinfo("ups.mfr", "%s", "Liebert");
@ -115,22 +117,31 @@ void upsdrv_initinfo(void)
command[5] = cksum(command, 5);
ret = do_command((unsigned char *)command, reply);
if (ret < 8) {
fatalx(EXIT_FAILURE, "GTX2 capable UPS not detected");
if (ret == 8) {
buf[i<<1] = reply[6];
buf[(i<<1)+1] = reply[5];
} else {
buf[i<<1] = '\0';
buf[(i<<1)+1] = '\0';
}
buf[i<<1] = reply[6];
buf[(i<<1)+1] = reply[5];
}
buf[i<<1] = 0;
for (s = strtok(buf, " "), i = 0; s && vartab[i].var; s = strtok(NULL, " "), i++) {
dstate_setinfo(vartab[i].var, "%s", s);
if (strlen(buf) == 0) {
fatalx(EXIT_FAILURE, "ESP-II capable UPS not detected");
}
for (index = 0, i = 0; vartab[i].var; index += vartab[i].len, i++) {
char val[SMALLBUF];
snprintf(val, sizeof(val), "%.*s", vartab[i].len, &buf[index]);
dstate_setinfo(vartab[i].var, "%s", rtrim(val, ' '));
}
upsh.instcmd = instcmd;
upsh.setvar = setvar;
upsh.setvar = setvar;
}
void upsdrv_updateinfo(void)
@ -144,6 +155,8 @@ void upsdrv_updateinfo(void)
{ { 1,149,2,1,4,157 }, "battery.charge", "%.0f", 1.0 },
{ { 1,149,2,1,1,154 }, "battery.runtime", "%.0f", 60 },
{ { 1,149,2,1,2,155 }, "battery.voltage", "%.1f", 0.1 },
{ { 1,149,2,1,3,156 }, "battery.current", "%.2f", 0.01 },
{ { 1,149,2,1,12,165 }, "battery.temperature", "%.1f", 0.1 },
{ { 1,161,2,1,13,178 }, "battery.voltage.nominal", "%.1f", 0.1 },
{ { 1,149,2,1,7,160 }, "ups.load", "%.0f", 1.0 },
{ { 1,149,2,1,6,159 }, "ups.power", "%.0f", 1.0 },
@ -160,20 +173,21 @@ void upsdrv_updateinfo(void)
{ { 0 }, NULL, NULL, 0 }
};
const char *val;
char reply[8];
int ret, i;
for (i = 0; vartab[i].var; i++) {
int val;
int16_t val;
ret = do_command(vartab[i].cmd, reply);
if (ret < 8) {
continue;
}
val = (unsigned char)reply[6];
val = (unsigned char)reply[5];
val <<= 8;
val += (unsigned char)reply[5];
val += (unsigned char)reply[6];
dstate_setinfo(vartab[i].var, vartab[i].fmt, val * vartab[i].mult);
}
@ -187,12 +201,22 @@ void upsdrv_updateinfo(void)
return;
}
if (reply[6] & (1<<0)) { /* ON_BATTERY */
if (reply[5] & (1<<0)) { /* ON_BATTERY */
status_set("OB");
} else {
status_set("OL");
}
val = dstate_getinfo("battery.current");
if (val) {
if (atof(val) > 0.05) {
status_set("CHRG");
}
if (atof(val) < -0.05) {
status_set("DISCHRG");
}
}
ret = do_command(cmd_bitfield2, reply);
if (ret < 8) {
upslogx(LOG_ERR, "Failed reading bitfield #2");
@ -200,23 +224,19 @@ void upsdrv_updateinfo(void)
return;
}
if (reply[5] & (1<<0)) { /* ON_BYPASS */
if (reply[6] & (1<<0)) { /* ON_BYPASS */
status_set("BYPASS");
}
if (reply[5] & (1<<5)) { /* REPLACE_BATTERY */
if (reply[6] & (1<<5)) { /* REPLACE_BATTERY */
status_set("RB");
}
if (!(reply[5] & (1<<1))) { /* not BATTERY_CHARGED */
status_set("CHRG");
}
if (reply[5] & (1<<6)) { /* BOOST_ON */
if (reply[6] & (1<<6)) { /* BOOST_ON */
status_set("BOOST");
}
if (reply[6] & (1<<1)) { /* BUCK_ON */
if (reply[5] & (1<<1)) { /* BUCK_ON */
status_set("TRIM");
}
@ -227,11 +247,11 @@ void upsdrv_updateinfo(void)
return;
}
if (reply[5] & (1<<0) ) { /* UPS_OVERLOAD */
if (reply[6] & (1<<0) ) { /* UPS_OVERLOAD */
status_set("OVER");
}
if (reply[5] & (1<<5) ) { /* LOW_BATTERY */
if (reply[6] & (1<<5) ) { /* LOW_BATTERY */
status_set("LB");
}
@ -278,12 +298,39 @@ void upsdrv_help(void)
/* list flags and values that you want to receive via -x */
void upsdrv_makevartable(void)
{
addvar (VAR_VALUE, "baudrate", "serial line speed");
}
void upsdrv_initups(void)
{
const char *val = getval("baudrate");
speed_t baudrate = B2400;
if (val) {
switch (atoi(val))
{
case 1200:
baudrate = B1200;
break;
case 2400:
baudrate = B2400;
break;
case 4800:
baudrate = B4800;
break;
case 9600:
baudrate = B9600;
break;
case 19200:
baudrate = B19200;
break;
default:
fatalx(EXIT_FAILURE, "Baudrate [%s] unsupported", val);
}
}
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B2400);
ser_set_speed(upsfd, device_path, baudrate);
}
void upsdrv_cleanup(void)

View file

@ -92,15 +92,15 @@ static hid_info_t liebert_hid2nut[] = {
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *liebert_format_model(HIDDevice_t *hd) {
static const char *liebert_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static char *liebert_format_mfr(HIDDevice_t *hd) {
static const char *liebert_format_mfr(HIDDevice_t *hd) {
return hd->Vendor ? hd->Vendor : "Liebert";
}
static char *liebert_format_serial(HIDDevice_t *hd) {
static const char *liebert_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}

View file

@ -330,7 +330,7 @@ int main(int argc, char **argv)
}
/* add a timer for data update */
#ifdef HAVE_GLIB_2_14
#ifdef HAVE_G_TIMEOUT_ADD_SECONDS
g_timeout_add_seconds (poll_interval,
#else
g_timeout_add (1000 * poll_interval, /* seconds */

View file

@ -32,14 +32,14 @@ char *getval(const char *var);
int testvar(const char *var);
/* extended variable table - used for -x defines/flags */
typedef struct {
typedef struct vartab_s {
int vartype; /* VAR_* value, below */
char *var; /* left side of =, or whole word if none */
char *val; /* right side of = */
char *desc; /* 40 character description for -h text */
int found; /* set once encountered, for testvar() */
void *next;
} vartab_t;
struct vartab_s *next;
} vartab_t;
/* flags to define types in the vartab */

View file

@ -92,6 +92,7 @@ static void help_msg(void)
printf(" -V - print version, then exit\n");
printf(" -L - print parseable list of driver variables\n");
printf(" -D - raise debugging level\n");
printf(" -q - raise log level threshold\n");
printf(" -h - display this help\n");
printf(" -k - force shutdown\n");
printf(" -i <int> - poll interval\n");
@ -483,7 +484,7 @@ int main(int argc, char **argv)
/* build the driver's extra (-x) variable table */
upsdrv_makevartable();
while ((i = getopt(argc, argv, "+a:kDhx:Lr:u:Vi:")) != -1) {
while ((i = getopt(argc, argv, "+a:kDhx:Lqr:u:Vi:")) != -1) {
switch (i) {
case 'a':
upsname = optarg;
@ -507,6 +508,9 @@ int main(int argc, char **argv)
case 'L':
listxarg();
exit(EXIT_SUCCESS);
case 'q':
nut_log_level++;
break;
case 'r':
chroot_path = xstrdup(optarg);
break;

View file

@ -33,16 +33,14 @@ char *getval(const char *var);
int testvar(const char *var);
/* extended variable table - used for -x defines/flags */
struct vartab_s {
typedef struct vartab_s {
int vartype; /* VAR_* value, below */
char *var; /* left side of =, or whole word if none */
char *val; /* right side of = */
char *desc; /* 40 character description for -h text */
int found; /* set once encountered, for testvar() */
struct vartab_s *next;
};
typedef struct vartab_s vartab_t;
} vartab_t;
/* flags to define types in the vartab */
@ -54,15 +52,13 @@ typedef struct vartab_s vartab_t;
void addvar(int vartype, const char *name, const char *desc);
/* subdriver description structure */
struct upsdrv_info_s {
typedef struct upsdrv_info_s {
const char *name; /* driver full name, for banner printing, ... */
const char *version; /* driver version */
const char *authors; /* authors name */
const int status; /* driver development status */
struct upsdrv_info_s *subdrv_info[2]; /* sub driver information */
};
typedef struct upsdrv_info_s upsdrv_info_t;
} upsdrv_info_t;
/* flags to define the driver development status */
#define DRV_BROKEN 0x0001 /* dito... */

File diff suppressed because it is too large Load diff

View file

@ -1,42 +0,0 @@
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: t; -*-
*
* megatec.h: support for Megatec protocol based UPSes
*
* Copyright (C) Carlos Rodrigues <carlos.efr at mail.telepac.pt>
*
* megatec.c created on 4/10/2003
*
* 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 MEGATEC_H
#define MEGATEC_H
/* FIXME (AQ): non compliant version (should be X.YZ)
* USB and serial should also be versioned */
#ifdef MEGATEC_SUBDRV
extern upsdrv_info_t megatec_subdrv_info;
void megatec_subdrv_makevartable(void);
void megatec_subdrv_banner(void);
#else
# define megatec_subdrv_makevartable(...)
# define megatec_subdrv_banner(...)
#endif
#endif /* MEGATEC_H */

View file

@ -1,656 +0,0 @@
/* megatec_usb.c - usb communication layer for Megatec protocol based UPSes
*
* Copyright (C) 2006 Andrey Lelikov <nut-driver@lelik.org>
* Copyright (C) 2007 Alexander Gordeev <lasaine@lvk.cs.msu.su>
* Copyright (C) 2007 Jon Gough <jon.gough at eclipsesystems.com.au>
*
* 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 "main.h"
#include "megatec.h"
#include "libusb.h"
#include "serial.h"
#include "usb-common.h"
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#define SUB_DRIVER_VERSION "0.10"
#define SUB_DRIVER_NAME "Serial-over-USB transport layer"
/* driver description structure */
upsdrv_info_t megatec_subdrv_info = {
SUB_DRIVER_NAME,
SUB_DRIVER_VERSION,
"Andrey Lelikov <nut-driver@lelik.org>\n" \
"Alexander Gordeev <lasaine@lvk.cs.msu.su>\n" \
"Jon Gough <jon.gough@eclipsesystems.com.au>",
DRV_STABLE,
{ NULL }
};
/*
This is a communication driver for "USB HID" UPS-es which use proprietary
usb-to-serial converter and speak megatec protocol. Usually these are cheap
models and usb-to-serial converter is a huge oem hack - HID tables are bogus,
device has no UPS reports, etc.
This driver has a table of all known devices which has pointers to device-
specific communication functions (namely send a string to UPS and read a string
from it). Driver takes care of detection, opening a usb device, string
formatting etc. So in order to add support for another usb-to-serial device one
only needs to implement device-specific get/set functions and add an entry into
KnownDevices table.
*/
static usb_communication_subdriver_t *usb = &usb_subdriver;
static usb_dev_handle *udev = NULL;
static USBDevice_t usbdevice;
static USBDeviceMatcher_t *reopen_matcher = NULL;
static USBDeviceMatcher_t *regex_matcher = NULL;
static int (*get_data)(char *buffer, int buffer_size) = NULL;
static int (*set_data)(const char *str) = NULL;
/* agiler-old subdriver definition */
static int get_data_agiler_old(char *buffer, int buffer_size);
static int set_data_agiler_old(const char *str);
static void *agiler_old_subdriver(void)
{
get_data = &get_data_agiler_old;
set_data = &set_data_agiler_old;
return NULL;
}
/* agiler subdriver definition */
static int get_data_agiler(char *buffer, int buffer_size);
static int set_data_agiler(const char *str);
static void *agiler_subdriver(void)
{
get_data = &get_data_agiler;
set_data = &set_data_agiler;
return NULL;
}
/* Phoenixtec Power Co subdriver definition */
static int get_data_phoenix(char *buffer, int buffer_size);
static int set_data_phoenix(const char *str);
static void *phoenix_subdriver(void)
{
get_data = &get_data_phoenix;
set_data = &set_data_phoenix;
return NULL;
}
/* krauler (ablerex) subdriver definition */
static int get_data_krauler(char *buffer, int buffer_size);
static int set_data_krauler(const char *str);
static void *krauler_subdriver(void)
{
get_data = &get_data_krauler;
set_data = &set_data_krauler;
return NULL;
}
/* list of subdrivers for manual overrides */
static const struct {
const char *name;
void *(*handler)(void);
} subdriver[] = {
{ "agiler-old", &agiler_old_subdriver },
{ "agiler", &agiler_subdriver },
{ "phoenix", &phoenix_subdriver },
{ "krauler", &krauler_subdriver },
/* end of list */
{ NULL }
};
/* list of all known devices */
static usb_device_id_t megatec_usb_id[] = {
/* Agiler UPS */
{ USB_DEVICE(0x05b8, 0x0000), &agiler_subdriver},
/* Krauler UP-M500VA */
{ USB_DEVICE(0x0001, 0x0000), &krauler_subdriver},
/* Ablerex 625L USB */
{ USB_DEVICE(0xffff, 0x0000), &krauler_subdriver},
/* Belkin F6C1200-UNV */
{ USB_DEVICE(0x0665, 0x5161), &phoenix_subdriver},
/* Mustek Powermust */
{ USB_DEVICE(0x06da, 0x0003), &phoenix_subdriver},
/* Unitek Alpha 1200Sx */
{ USB_DEVICE(0x0f03, 0x0001), &phoenix_subdriver},
/* end of list */
{-1, -1, NULL}
};
static int subdriver_match_func(USBDevice_t *d, void *privdata)
{
if(getval("subdriver"))
return 1;
switch (is_usb_device_supported(megatec_usb_id, d->VendorID, d->ProductID))
{
case SUPPORTED:
return 1;
case POSSIBLY_SUPPORTED:
case NOT_SUPPORTED:
default:
return 0;
}
}
static USBDeviceMatcher_t subdriver_matcher = {
&subdriver_match_func,
NULL,
NULL
};
static void usb_open_error(const char *port)
{
fatalx(EXIT_FAILURE,
"No supported devices found. Please check your device availability with 'lsusb'\n"
"and make sure you have an up-to-date version of NUT. If this does not help,\n"
"try running the driver with at least 'vendorid' and 'subdriver' options\n"
"specified. Please refer to the man page for details about these options\n"
"(man 8 megatec_usb).\n"
"Please report your results to the NUT user's mailing list\n"
"<nut-upsuser@lists.alioth.debian.org>.\n"
);
}
/* FIXME: Fix "serial" variable (which conflicts with "serial" variable in megatec.c) */
void megatec_subdrv_makevartable()
{
addvar(VAR_VALUE, "vendor", "Regular expression to match UPS Manufacturer string");
addvar(VAR_VALUE, "product", "Regular expression to match UPS Product string");
/* addvar(VAR_VALUE, "serial", "Regular expression to match UPS Serial number"); */
addvar(VAR_VALUE, "vendorid", "Regular expression to match UPS Manufacturer numerical ID (4 digits hexadecimal)");
addvar(VAR_VALUE, "productid", "Regular expression to match UPS Product numerical ID (4 digits hexadecimal)");
addvar(VAR_VALUE, "bus", "Regular expression to match USB bus name");
addvar(VAR_VALUE, "subdriver", "Serial-over-USB subdriver selection");
}
int ser_open(const char *port)
{
char *regex_array[6];
int ret;
char *subdrv = getval("subdriver");
char *vid = getval("vendorid");
char *pid = getval("productid");
char *vend = getval("vendor");
char *prod = getval("product");
/* pick up the subdriver name if set explicitly */
if(subdrv)
{
int i;
if(!vid && !pid && !vend && !prod)
{
upslogx(LOG_WARNING, "It's unsafe to select a subdriver but not specify device!\n"
"Please set some of \"vendor\", \"product\", \"vendorid\", \"productid\""
" variables.\n");
}
for (i = 0; subdriver[i].name; i++)
{
if (!strcasecmp(subdrv, subdriver[i].name))
{
(*subdriver[i].handler)();
break;
}
}
if(!subdriver[i].name)
fatalx(EXIT_FAILURE, "No subdrivers named \"%s\" found!", subdrv);
}
/* FIXME: fix "serial" variable */
/* process the UPS selection options */
regex_array[0] = vid;
regex_array[1] = pid;
regex_array[2] = vend;
regex_array[3] = prod;
regex_array[4] = NULL; /* getval("serial"); */
regex_array[5] = getval("bus");
ret = USBNewRegexMatcher(&regex_matcher, regex_array, REG_ICASE | REG_EXTENDED);
if (ret == -1) {
fatal_with_errno(EXIT_FAILURE, "USBNewRegexMatcher");
} else if (ret) {
fatalx(EXIT_FAILURE, "invalid regular expression: %s", regex_array[ret]);
}
/* link the matchers */
regex_matcher->next = &subdriver_matcher;
ret = usb->open(&udev, &usbdevice, regex_matcher, NULL);
if (ret < 0)
usb_open_error(port);
/* create a new matcher for later reopening */
ret = USBNewExactMatcher(&reopen_matcher, &usbdevice);
if (ret) {
fatal_with_errno(EXIT_FAILURE, "USBNewExactMatcher");
}
/* link the matchers */
reopen_matcher->next = regex_matcher;
/* NOTE: This is here until ser_flush_io() is used in megatec.c */
ser_flush_io(0);
return 0;
}
int ser_set_speed(int fd, const char *port, speed_t speed)
{
return 0;
}
int ser_set_dtr(int fd, int state)
{
return 0;
}
int ser_set_rts(int fd, int state)
{
return 0;
}
int ser_flush_io(int fd)
{
char flush_buf[256];
int i;
/* flush input buffers */
for (i = 0; i < 10; i++) {
if ((*get_data)(flush_buf, sizeof(flush_buf)) < 1)
break;
}
return 0;
}
void ser_comm_fail(const char *fmt, ...)
{
}
void ser_comm_good(void)
{
}
int ser_close(int fd, const char *port)
{
usb->close(udev);
USBFreeExactMatcher(reopen_matcher);
USBFreeRegexMatcher(regex_matcher);
return 0;
}
/*!@brief Try to reconnect once.
* @return 1 if reconnection was successful.
*/
static int reconnect_ups(void)
{
int ret;
upsdebugx(2, "==================================================");
upsdebugx(2, "= device has been disconnected, try to reconnect =");
upsdebugx(2, "==================================================");
usb->close(udev);
ret = usb->open(&udev, &usbdevice, reopen_matcher, NULL);
if (ret < 1) {
upslogx(LOG_INFO, "Reconnecting to UPS failed; will retry later...");
udev = NULL;
return 0;
} else
upslogx(LOG_NOTICE, "Successfully reconnected");
return ret;
}
/*!@brief Report a USB comm failure, and reconnect if necessary
*
* @param[in] res Result code from libusb/libhid call
* @param[in] msg Error message to display
*/
void usb_comm_fail(int res, const char *msg)
{
switch(res) {
case -EBUSY:
upslogx(LOG_WARNING, "%s: Device claimed by another process", msg);
fatalx(EXIT_FAILURE, "Terminating: EBUSY");
default:
upslogx(LOG_WARNING, "%s: Device detached? (error %d: %s)", msg, res, usb_strerror());
if(reconnect_ups()) {
/* upsdrv_initinfo(); */
}
break;
}
}
int ser_send_pace(int fd, unsigned long d_usec, const char *fmt, ...)
{
char buf[128];
size_t len;
va_list ap;
int ret;
if ((udev == NULL) && (! reconnect_ups()))
return -1;
va_start(ap, fmt);
len = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if ((len < 1) || (len >= (int) sizeof(buf))) {
upslogx(LOG_WARNING, "ser_send_pace: vsnprintf needed more than %d bytes", (int) sizeof(buf));
buf[sizeof(buf) - 1] = 0;
}
ret = (*set_data)(buf);
if(ret < 0) {
usb_comm_fail(ret, "ser_send_pace");
}
return ret;
}
int ser_get_line(int fd, void *buf, size_t buflen, char endchar, const char *ignset, long d_sec, long d_usec)
{
int len;
char *src, *dst, c;
if ((udev == NULL) && (! reconnect_ups()))
return -1;
len = (*get_data)((char *)buf, buflen);
if (len < 0) {
usb_comm_fail(len, "ser_get_line");
return len;
}
dst = (char *)buf;
for (src = (char *)buf; src != ((char *)buf + len); src++) {
c = *src;
if (c == endchar)
break;
if ((c == 0) || ((ignset != NULL) && (strchr(ignset, c) != NULL)))
continue;
*(dst++) = c;
}
/* terminate string if we have space */
if (dst != ((char *)buf + len))
*dst = 0;
return (dst - (char *)buf);
}
/************** minidrivers go after this point **************************/
/*
agiler-old subdriver
*/
/* Protocol was reverse-engineered from Windows driver
HID tables are completely bogus
Data is transferred out as one 8-byte packet with report ID 0
Data comes in as 6 8-byte reports per line , padded with zeroes
All constants are hardcoded in windows driver
*/
#define AGILER_REPORT_SIZE 8
#define AGILER_REPORT_COUNT 6
#define AGILER_TIMEOUT 5000
static int set_data_agiler_old(const char *str)
{
unsigned char report_buf[AGILER_REPORT_SIZE];
if (strlen(str) > AGILER_REPORT_SIZE) {
upslogx(LOG_ERR, "set_data_agiler: output string too large");
return -1;
}
memset(report_buf, 0, sizeof(report_buf));
memcpy(report_buf, str, strlen(str));
return usb->set_report(udev, 0, report_buf, sizeof(report_buf));
}
static int get_data_agiler_old(char *buffer, int buffer_size)
{
int i, len;
char buf[AGILER_REPORT_SIZE * AGILER_REPORT_COUNT + 1];
memset(buf, 0, sizeof(buf));
for (i = 0; i < AGILER_REPORT_COUNT; i++) {
len = usb->get_interrupt(udev, (unsigned char *) buf + i * AGILER_REPORT_SIZE, AGILER_REPORT_SIZE, AGILER_TIMEOUT);
if (len != AGILER_REPORT_SIZE) {
if (len < 0)
len = 0;
buf[i * AGILER_REPORT_SIZE + len] = 0;
upsdebug_hex(5, "get_data_agiler: raw dump", buf, i * AGILER_REPORT_SIZE + len);
break;
}
}
len = strlen(buf);
if (len > buffer_size) {
upslogx(LOG_ERR, "get_data_agiler: input buffer too small");
len = buffer_size;
}
memcpy(buffer, buf, len);
return len;
}
/*
Agiler serial-to-usb device.
*/
static int set_data_agiler(const char *str)
{
return usb->set_report(udev, 0, (unsigned char *)str, strlen(str));
}
static int get_data_agiler(char *buffer, int buffer_size)
{
return usb->get_interrupt(udev, (unsigned char *)buffer, buffer_size, 1000);
}
/*
Phoenixtec Power Co serial-to-usb device.
*/
static char phoenix_buffer[32];
static int set_data_phoenix(const char *str)
{
unsigned int count;
memset(phoenix_buffer, '\0', sizeof(phoenix_buffer));
snprintf(phoenix_buffer, sizeof(phoenix_buffer), "%s", str);
if (!strcmp(phoenix_buffer, "I\r") || !strcmp(phoenix_buffer, "C\r")) {
/* Ignore these, since they seem to lock up the connection */
return strlen(phoenix_buffer);
}
for (count = 0; count < strlen(phoenix_buffer); count += 8) {
if (usb->set_report(udev, 0, (unsigned char *)(phoenix_buffer + count), 8) < 1) {
return -1;
}
}
return strlen(phoenix_buffer);
}
static int get_data_phoenix(char *buffer, int buffer_size)
{
int count;
memset(buffer, '\0', buffer_size);
if (!strcmp(phoenix_buffer, "I\r") || !strcmp(phoenix_buffer, "C\r")) {
/* Echo back unsupported commands */
snprintf(buffer, buffer_size, "%s", phoenix_buffer);
return strlen(buffer);
}
for (count = 8; count <= buffer_size; count += 8) {
/* Read data in 8-byte chunks, break on a timeout */
if (usb->get_interrupt(udev, (unsigned char *)&buffer[count-8], 8, 1000) < 0) {
return count-8;
}
upsdebugx(3, "get_data_phoenix: got so far [%s]", buffer);
upsdebug_hex(4, "get_data_phoenix", (unsigned char *)buffer, count);
}
upsdebugx(3, "get_data_phoenix: buffer too small");
return -1;
}
/*
Krauler serial-over-usb device.
Protocol was reverse-engineered using Windows driver.
*/
#define KRAULER_MAX_ATTEMPTS_Q1 4
#define KRAULER_MAX_ATTEMPTS_F 31
#define KRAULER_MAX_ATTEMPTS_I 15
typedef struct {
char *str; /* Megatec command */
int index; /* Krauler string index for this command */
char prefix; /* character to replace the first byte in reply */
int retry; /* number of retries (1 is typically for instant commands) */
} krauler_command_t;
static krauler_command_t krauler_command_lst[] = {
{ "T\r", 0x04, '\0', 1 },
{ "TL\r", 0x05, '\0', 1 },
{ "Q\r", 0x07, '\0', 1 },
{ "C\r", 0x0b, '\0', 1 },
{ "CT\r", 0x0b, '\0', 1 },
{ "Q1\r", 0x03, '(', KRAULER_MAX_ATTEMPTS_Q1 },
{ "I\r", 0x0c, '#', KRAULER_MAX_ATTEMPTS_I },
{ "F\r", 0x0d, '#', KRAULER_MAX_ATTEMPTS_F },
{ NULL, 0, '\0', 0 }
};
/*
Still not implemented:
0x6 T<n> (don't know how to pass the parameter)
0x68 and 0x69 both cause shutdown after an undefined interval
*/
/* an intermediate buffer for 1 command's output */
static char krauler_line_buf[255];
static char krauler_line_buf_len = 0;
static int set_data_krauler(const char *str)
{
krauler_command_t *command;
int retval = strlen(str);
for (command = krauler_command_lst; command->str != NULL; command++) {
int retry;
if (strcmp(str, command->str)) {
continue;
}
upsdebugx(3, "set_data_krauler: index [%02x]", command->index);
krauler_line_buf_len = 0;
for (retry = 0; retry < command->retry; retry++) {
int res;
res = usb->get_string(udev, command->index, krauler_line_buf, sizeof(krauler_line_buf));
if (res < 1) {
/* TODO: handle_error(res) */
upsdebugx(2, "set_data_krauler: connection failure");
return res;
}
/* "UPS No Ack" has a special meaning */
if (!strcmp(krauler_line_buf, "UPS No Ack")) {
upsdebugx(4, "set_data_krauler: retry [%s]", krauler_line_buf);
continue;
}
/* Replace the first byte of what we received with the correct one */
if(command->prefix)
krauler_line_buf[0] = command->prefix;
krauler_line_buf_len = res;
return retval;
}
if(command->retry > 1 && retry == command->retry)
upsdebugx(2, "set_data_krauler: too many attempts, the UPS is probably switched off!");
return retval;
}
upsdebugx(4, "set_data_krauler: unknown command [%s]", str);
/* echo the unknown command back */
strcpy(krauler_line_buf, str);
krauler_line_buf_len = retval;
return retval;
}
static int get_data_krauler(char *buffer, int buffer_size)
{
int retrieved = (buffer_size < krauler_line_buf_len) ? buffer_size : krauler_line_buf_len;
int left = krauler_line_buf_len - retrieved;
memcpy(buffer, krauler_line_buf, retrieved);
memmove(krauler_line_buf, krauler_line_buf + retrieved, left);
krauler_line_buf_len = left;
return retrieved;
}

View file

@ -94,7 +94,7 @@ long int get_long(unsigned char *buffer) { /* return a long integer reading 4 by
return result;
}
void send_zeros() { /* send 100 times the value 0x00.....it seems to be used for resetting */
void send_zeros(void) { /* send 100 times the value 0x00.....it seems to be used for resetting */
unsigned char buf[100]; /* the ups serial port */
int i;

View file

@ -26,7 +26,7 @@
#include "usbhid-ups.h"
#include "mge-hid.h"
#define MGE_HID_VERSION "MGE HID 1.18"
#define MGE_HID_VERSION "MGE HID 1.19"
/* (prev. MGE Office Protection Systems, prev. MGE UPS SYSTEMS) */
/* Eaton */
@ -77,7 +77,7 @@ static char mge_scratch_buf[20];
/* The HID path 'UPS.PowerSummary.Time' reports Unix time (ie the number of
* seconds since 1970-01-01 00:00:00. This has to be split between ups.date and
* ups.time */
static char *mge_date_conversion_fun(double value)
static const char *mge_date_conversion_fun(double value)
{
time_t sec = value;
@ -89,7 +89,7 @@ static char *mge_date_conversion_fun(double value)
return NULL;
}
static char *mge_time_conversion_fun(double value)
static const char *mge_time_conversion_fun(double value)
{
time_t sec = value;
@ -111,8 +111,6 @@ static double mge_date_conversion_nuf(const char *value)
snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%s %s", value, dstate_getinfo("ups.time"));
if (strptime(mge_scratch_buf, "%Y/%m/%d %H:%M:%S", &mge_tm) != NULL) {
/* Ignore DST offset */
mge_tm.tm_isdst = 0;
return mktime(&mge_tm);
}
@ -129,8 +127,6 @@ static double mge_time_conversion_nuf(const char *value)
snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%s %s", dstate_getinfo("ups.date"), value);
if (strptime(mge_scratch_buf, "%Y/%m/%d %H:%M:%S", &mge_tm) != NULL) {
/* Ignore DST offset */
mge_tm.tm_isdst = 0;
return mktime(&mge_tm);
}
@ -158,7 +154,7 @@ static info_lkp_t mge_time_conversion[] = {
/* The HID path 'UPS.PowerSummary.ConfigVoltage' only reports
'battery.voltage.nominal' for specific UPS series. Ignore
the value for other series (default behavior). */
static char *mge_battery_voltage_nominal_fun(double value)
static const char *mge_battery_voltage_nominal_fun(double value)
{
switch (mge_type & 0xFF00) /* Ignore model byte */
{
@ -186,7 +182,7 @@ static info_lkp_t mge_battery_voltage_nominal[] = {
/* The HID path 'UPS.PowerSummary.Voltage' only reports
'battery.voltage' for specific UPS series. Ignore the
value for other series (default behavior). */
static char *mge_battery_voltage_fun(double value)
static const char *mge_battery_voltage_fun(double value)
{
switch (mge_type & 0xFF00) /* Ignore model byte */
{
@ -206,7 +202,7 @@ static info_lkp_t mge_battery_voltage[] = {
{ 0, NULL, mge_battery_voltage_fun }
};
static char *mge_powerfactor_conversion_fun(double value)
static const char *mge_powerfactor_conversion_fun(double value)
{
snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.2f", value / 100);
return mge_scratch_buf;
@ -216,7 +212,7 @@ static info_lkp_t mge_powerfactor_conversion[] = {
{ 0, NULL, mge_powerfactor_conversion_fun }
};
static char *mge_battery_capacity_fun(double value)
static const char *mge_battery_capacity_fun(double value)
{
snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.2f", value / 3600);
return mge_scratch_buf;
@ -278,7 +274,7 @@ info_lkp_t mge_onbatt_info[] = {
{ 0, NULL, NULL }
};
/* allow limiting to ups.model ~= Protection Station */
static char *eaton_check_pegasus_fun(double value)
static const char *eaton_check_pegasus_fun(double value)
{
switch (mge_type & 0xFF00) /* Ignore model byte */
{
@ -301,7 +297,7 @@ static info_lkp_t pegasus_threshold_info[] = {
};
/* Limit nominal output voltage according to HV or LV models */
static char *nominal_output_voltage_fun(double value)
static const char *nominal_output_voltage_fun(double value)
{
static long nominal = -1;
@ -694,7 +690,7 @@ static hid_info_t mge_hid2nut[] =
{ "battery.capacity", 0, 0, "UPS.BatterySystem.Battery.DesignCapacity", NULL, "%s", HU_FLAG_STATIC, mge_battery_capacity }, /* conversion needed from As to Ah */
{ "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL },
{ "battery.runtime.elapsed", 0, 0, "UPS.StatisticSystem.Input.[1].Statistic.[1].Time", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL },
{ "battery.temperature", 0, 0, "UPS.BatterySystem.Battery.Temperature", NULL, "%.1f", 0, NULL },
{ "battery.temperature", 0, 0, "UPS.BatterySystem.Battery.Temperature", NULL, "%s", 0, kelvin_celsius_conversion },
{ "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion },
{ "battery.voltage", 0, 0, "UPS.BatterySystem.Voltage", NULL, "%.1f", 0, NULL },
{ "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%s", 0, mge_battery_voltage },
@ -712,10 +708,10 @@ static hid_info_t mge_hid2nut[] =
{ "ups.timer.start", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.test.result", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "%s", HU_FLAG_SEMI_STATIC, test_read_info },
{ "ups.test.result", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "%s", 0, test_read_info },
{ "ups.test.interval", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.BatterySystem.Battery.TestPeriod", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "ups.beeper.status", 0 ,0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_SEMI_STATIC, beeper_info },
{ "ups.temperature", 0, 0, "UPS.PowerSummary.Temperature", NULL, "%.1f", 0, NULL },
{ "ups.temperature", 0, 0, "UPS.PowerSummary.Temperature", NULL, "%s", 0, kelvin_celsius_conversion },
{ "ups.power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL },
{ "ups.L1.power", 0, 0, "UPS.PowerConverter.Output.Phase.[1].ApparentPower", NULL, "%.0f", 0, NULL },
{ "ups.L2.power", 0, 0, "UPS.PowerConverter.Output.Phase.[2].ApparentPower", NULL, "%.0f", 0, NULL },
@ -941,7 +937,7 @@ static char *get_model_name(const char *iProduct, const char *iModel)
return strdup(model->name);
}
static char *mge_format_model(HIDDevice_t *hd) {
static const char *mge_format_model(HIDDevice_t *hd) {
char product[SMALLBUF];
char model[SMALLBUF];
double value;
@ -969,11 +965,11 @@ static char *mge_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static char *mge_format_mfr(HIDDevice_t *hd) {
static const char *mge_format_mfr(HIDDevice_t *hd) {
return hd->Vendor ? hd->Vendor : "Eaton";
}
static char *mge_format_serial(HIDDevice_t *hd) {
static const char *mge_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}

View file

@ -91,7 +91,7 @@ u_char raw_buf[4096];
float expo(int a, int b);
extern long FormatValue(long Value, u_char Size);
static char *hu_find_infoval(info_lkp_t *hid2info, long value);
static const char *hu_find_infoval(info_lkp_t *hid2info, long value);
/* --------------------------------------------------------------- */
/* UPS Driver Functions */
@ -184,7 +184,7 @@ void upsdrv_initinfo (void)
void upsdrv_updateinfo (void)
{
mge_info_item_t *item;
char *nutvalue;
const char *nutvalue;
upsdebugx(2, "entering upsdrv_updateinfo()");
@ -442,7 +442,7 @@ int shut_identify_ups ()
{
char string[MAX_STRING];
char model[MAX_STRING];
char *finalname = NULL;
const char *finalname = NULL;
int retcode, tries=MAX_TRY;
if (commstatus == 0)
@ -1308,7 +1308,7 @@ float expo(int a, int b)
}
/* Format model names */
char *get_model_name(char *iProduct, char *iModel)
const char *get_model_name(char *iProduct, char *iModel)
{
models_name_t *model = NULL;
@ -1434,7 +1434,7 @@ mge_info_item_t *shut_find_info(const char *varname)
}
/* find the NUT value matching that HID Item value */
static char *hu_find_infoval(info_lkp_t *hid2info, long value)
static const char *hu_find_infoval(info_lkp_t *hid2info, long value)
{
info_lkp_t *info_lkp;

View file

@ -156,9 +156,9 @@ typedef union device_desc_data_u {
/* Model Name formating entries */
/* --------------------------------------------------------------- */
typedef struct {
char *iProduct;
char *iModel;
char *finalname;
const char *iProduct;
const char *iModel;
const char *finalname;
} models_name_t;
models_name_t models_names [] =
@ -269,7 +269,7 @@ models_name_t models_names [] =
/* for lookup between HID values and NUT values*/
typedef struct {
long hid_value; /* HID value */
char *nut_value; /* NUT value */
const char *nut_value; /* NUT value */
} info_lkp_t;
/* Actual value lookup tables => should be fine for all Mfrs (TODO: validate it!) */
@ -344,7 +344,7 @@ typedef struct {
int flags; /* INFO-element flags to set in addinfo */
int length; /* INFO-element length of strings */
const char *item_path; /* HID object (fully qualified string path) */
const char fmt[6]; /* printf format string for INFO entry */
const char *fmt; /* printf format string for INFO entry */
const char *dfl; /* default value */
unsigned long shut_flags; /* specific SHUT flags */
info_lkp_t *hid2info; /* lookup table between HID and NUT values */
@ -506,7 +506,7 @@ int shut_wait_ack (void);
void shut_ups_status(void);
int hid_init_device(void);
char *get_model_name(char *iProduct, char *iModel);
const char *get_model_name(char *iProduct, char *iModel);
int hid_lookup_usage(char *name);
int hid_get_value(const char *item_path);
int hid_set_value(const char *varname, const char *val);

View file

@ -64,7 +64,7 @@
/* --------------------------------------------------------------- */
#define DRIVER_NAME "MGE UPS SYSTEMS/U-Talk driver"
#define DRIVER_VERSION "0.89"
#define DRIVER_VERSION "0.92"
/* driver description structure */
@ -130,7 +130,6 @@ static const char *info_variable_cmd(const char *type);
static bool_t info_variable_ok(const char *type);
static int get_ups_status(void);
static int mge_command(char *reply, int replylen, const char *fmt, ...);
static void format_model_name(char *model);
/* --------------------------------------------------------------- */
/* UPS Driver Functions */
@ -218,17 +217,18 @@ void upsdrv_initups(void)
void upsdrv_initinfo(void)
{
char buf[BUFFLEN];
char *model = NULL;
const char *model = NULL;
char *firmware = NULL;
char *p;
char *v = NULL; /* for parsing Si output, get Version ID */
int table;
int tries;
int status_ok;
int status_ok = 0;
int bytes_rcvd;
int si_data1 = 0;
int si_data2 = 0;
mge_info_item_t *item;
models_name_t *model_info;
mge_model_info_t *legacy_model;
char infostr[32];
int chars_rcvd;
@ -247,10 +247,10 @@ void upsdrv_initinfo(void)
if(bytes_rcvd > 0 && buf[0] != '?') {
dstate_setinfo("ups.id", "%s", buf); /* raw id */
model = buf;
p = strrchr(buf, ' ');
model = buf;
p = strrchr(buf, ' ');
if ( p != NULL ) {
*p = '\0';
firmware = p+1;
@ -258,6 +258,16 @@ void upsdrv_initinfo(void)
if( firmware && strlen(firmware) < 1 )
firmware = NULL; /* no firmware information */
/* Parsing model names table */
for ( model_info = Si1_models_names ; model_info->basename != NULL ; model_info++ ) {
if(!strcasecmp(model_info->basename, model))
{
model = model_info->finalname;
upsdebugx(1, "initinfo: UPS model == >%s<", model);
break;
}
}
}
else
{
@ -286,12 +296,12 @@ void upsdrv_initinfo(void)
si_data2 = atoi(v);
}
/* Parsing legacy model table in order to found it */
for ( legacy_model = mge_model ; legacy_model->name != NULL ; legacy_model++ ) {
if(legacy_model->Data1 == si_data1 && legacy_model->Data2 == si_data2){
model = (char *)legacy_model->name;
upsdebugx(1, "initinfo: UPS model == >%s<", model);
break;
/* Parsing legacy model table in order to find it */
for ( legacy_model = mge_model ; legacy_model->name != NULL ; legacy_model++ ) {
if(legacy_model->Data1 == si_data1 && legacy_model->Data2 == si_data2){
model = legacy_model->name;
upsdebugx(1, "initinfo: UPS model == >%s<", model);
break;
}
}
@ -302,8 +312,14 @@ void upsdrv_initinfo(void)
}
if ( model ) {
format_model_name(model);
dstate_setinfo("ups.model", "%s", model);
upsdebugx(2, "Got model name: %s", model);
/* deal with truncated model names */
if (!strncmp(model, "Evolutio", 8)) {
dstate_setinfo("ups.model", "Evolution %i", atoi(strchr(model, ' ')));
} else {
dstate_setinfo("ups.model", "%s", model);
}
}
if ( firmware && strcmp(firmware, ""))
@ -328,8 +344,8 @@ void upsdrv_initinfo(void)
* information (OL, OB, LB); all else is added later by updateinfo */
status_ok = get_ups_status();
} while ( (!status_ok) && (tries++ < MAXTRIES) && (exit_flag != 0) );
} while ( (!status_ok) && (tries++ < MAXTRIES) && (exit_flag != 1) );
if ( tries == MAXTRIES && !status_ok )
fatalx(EXIT_FAILURE, "Could not get status from UPS.");
@ -398,13 +414,15 @@ void upsdrv_updateinfo(void)
/* update status */
status_ok = get_ups_status(); /* only sys status is critical */
if ( !status_ok ) {
dstate_datastale();
if ( !status_ok )
{
upslogx(LOG_NOTICE, "updateinfo: Cannot update system status");
/* try to re enable communication */
disable_ups_comm();
enable_ups_comm();
} else {
}
else
{
dstate_dataok();
}
@ -427,8 +445,8 @@ void upsdrv_updateinfo(void)
dstate_setinfo(item->type, "%s", infostr);
upsdebugx(2, "updateinfo: %s == >%s<", item->type, infostr);
dstate_dataok();
} else {
dstate_datastale();
} else
{
upslogx(LOG_NOTICE, "updateinfo: Cannot update %s", item->type);
/* try to re enable communication */
disable_ups_comm();
@ -479,17 +497,6 @@ void upsdrv_help(void)
/* Internal Functions */
/* --------------------------------------------------------------- */
/* deal with truncated model names */
void format_model_name(char *model)
{
upsdebugx(2, "Got model name: %s", model);
if(!strncmp(model, "Evolutio", 8))
sprintf(model, "Evolution %i", atoi(strchr(model, ' ')));
}
/* --------------------------------------------------------------- */
/* handler for commands to be sent to UPS */
int instcmd(const char *cmdname, const char *extra)
{

View file

@ -45,8 +45,8 @@
/* Model Name formating entries */
/* --------------------------------------------------------------- */
typedef struct {
char *basename; /* as returned by Si 1 <data 2> */
char *finalname;
const char *basename; /* as returned by Si 1 <data 2> */
const char *finalname;
} models_name_t;
models_name_t Si1_models_names [] =
@ -189,8 +189,8 @@ typedef struct {
const char *type; /* INFO_* element */
int flags; /* INFO-element flags to set in addinfo */
int length; /* INFO-element length of strings */
const char cmd[32]; /* UPS command string to requets element */
const char fmt[32]; /* printf format string for INFO entry */
const char *cmd; /* UPS command string to requets element */
const char *fmt; /* printf format string for INFO entry */
units_t unit; /* unit of measurement, or NONE */
bool_t ok; /* flag indicating if item is available */
} mge_info_item_t;

View file

@ -31,7 +31,7 @@
#include "netxml-ups.h"
#include "mge-xml.h"
#define MGE_XML_VERSION "MGEXML/0.21"
#define MGE_XML_VERSION "MGEXML/0.22"
#define MGE_XML_INITUPS "/"
#define MGE_XML_INITINFO "/mgeups/product.xml /product.xml /ws/product.xml"
@ -507,6 +507,8 @@ static const char *mge_test_result_info(const char *val)
return "in progress";
case 6:
return "no test initiated";
case 7:
return "test scheduled";
}
return NULL;
}
@ -516,7 +518,7 @@ static const char *mge_ambient_info(const char *val)
switch (mge_ambient_value)
{
case 1:
return (char *)val;
return val;
default:
return NULL;
}

View file

@ -90,7 +90,7 @@ static int CheckDataChecksum(unsigned char *Buff, int Len)
}
static char *ErrMessages[] = {
static const char *ErrMessages[] = {
/* 0 */ "errorcode NOT DEFINED", /* default error message */
/* 1 */ "I2C bus busy (e2prom)",
/* 2 */ "Command received: checksum not valid",

View file

@ -38,7 +38,7 @@ static info_lkp_t netvision_batt_info[] = {
{ 2, "" }, /* battery normal */
{ 3, "LB" }, /* battery low */
{ 4, "LB" }, /* battery depleted */
{ 5, "" }, /* battery discharging */
{ 5, "DISCHRG" }, /* battery discharging */
{ 6, "RB" }, /* battery failure */
{ 0, "NULL" }
};
@ -74,15 +74,16 @@ static info_lkp_t netvision_batt_info[] = {
#define NETVISION_OID_OUTPUT_SOURCE ".1.3.6.1.4.1.4555.1.1.1.1.4.1.0"
static info_lkp_t netvision_output_info[] = {
{ 1, "NULL" }, /* output source other */
{ 2, "NULL" }, /* output source none */
{ 1, "" }, /* output source other */
{ 2, "" }, /* output source none */
{ 3, "OL" }, /* output source normal */
{ 4, "OL BYPASS" }, /* output source bypass */
{ 5, "OB" }, /* output source battery */
{ 6, "OL BOOST" }, /* output source booster */
{ 7, "OL TRIM" }, /* output source reducer */
{ 8, "NULL" }, /* output source standby */
{ 9, "NULL" }, /* output source ecomode */
{ 8, "" }, /* output source standby */
{ 9, "" }, /* output source ecomode */
{ 0, "NULL" }
};
/* Snmp2NUT lookup table */
@ -97,7 +98,7 @@ static snmp_info_t netvision_mib[] = {
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, NETVISION_OID_BATTERYSTATUS, "",
SU_FLAG_OK | SU_STATUS_BATT, &netvision_batt_info[0] },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, NETVISION_OID_BATTERYSTATUS, "",
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, NETVISION_OID_OUTPUT_SOURCE, "",
SU_FLAG_OK | SU_STATUS_PWR, &netvision_output_info[0] },
/* ups load */

View file

@ -23,10 +23,10 @@
#include "nut_stdint.h"
struct subdriver_s {
typedef struct {
const char *version; /* name of this subdriver */
char *initups;
char *initinfo;
const char *initups;
const char *initinfo;
char *configure; /* central configuration */
char *subscribe; /* alarm subscriptions */
char *summary; /* used for quick updates */
@ -35,9 +35,7 @@ struct subdriver_s {
int (*startelm_cb)(void *userdata, int parent, const char *nspace, const char *name, const char **atts);
int (*cdata_cb)(void *userdata, int state, const char *cdata, size_t len);
int (*endelm_cb)(void *userdata, int state, const char *nspace, const char *name);
};
typedef struct subdriver_s subdriver_t;
} subdriver_t;
/* ---------------------------------------------------------------------- */
/* data for processing boolean values from UPS */

View file

@ -130,7 +130,7 @@ static ezfill_t _initv[] = {
/* All serial reads of the OPTI-UPS go through here. We always expect a CR/LF terminated
* response. Unknown/Unimplemented commands return ^U (0x15). Actions that complete
* successfully return ^F (0x06). */
static inline int optireadline()
static inline int optireadline(void)
{
int r;
usleep(150000);

View file

@ -50,7 +50,7 @@ static usb_device_id_t powercom_usb_device_table[] = {
static char powercom_scratch_buf[32];
static char *powercom_startup_fun(double value)
static const char *powercom_startup_fun(double value)
{
uint16_t i = value;
@ -76,7 +76,7 @@ static info_lkp_t powercom_startup_info[] = {
{ 0, NULL, powercom_startup_fun, powercom_startup_nuf }
};
static char *powercom_shutdown_fun(double value)
static const char *powercom_shutdown_fun(double value)
{
uint16_t i = value;
@ -258,15 +258,15 @@ static hid_info_t powercom_hid2nut[] = {
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *powercom_format_model(HIDDevice_t *hd) {
static const char *powercom_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static char *powercom_format_mfr(HIDDevice_t *hd) {
static const char *powercom_format_mfr(HIDDevice_t *hd) {
return hd->Vendor ? hd->Vendor : "PowerCOM";
}
static char *powercom_format_serial(HIDDevice_t *hd) {
static const char *powercom_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}
@ -279,6 +279,12 @@ static int powercom_claim(HIDDevice_t *hd)
switch (status)
{
case POSSIBLY_SUPPORTED:
if (hd->ProductID == 0x0002) {
upsdebugx(0,
"This Powercom device (%04x/%04x) is not supported by usbhid-ups.\n"
"Please use the 'powercom' driver instead.\n", hd->VendorID, hd->ProductID);
return 0;
}
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
return 1;

View file

@ -1,7 +1,7 @@
/*
* powercom.h - defines for the newpowercom.c driver
*
* $Id: powercom.h 2336 2010-02-11 20:16:43Z adkorte-guest $
* $Id: powercom.h 2627 2010-10-26 21:09:34Z adkorte-guest $
*
* Copyrights:
* (C) 2002 Simon Rozman <simon@rozman.net>
@ -41,7 +41,7 @@ struct type {
unsigned char num_of_bytes_from_ups;
struct method_of_flow_control {
char *name;
const char *name;
void (*setup_flow_control)(void);
} flowControl;

View file

@ -52,7 +52,7 @@ static int instcmd(const char *cmdname, const char *extra)
pm_err_t rv = -1;
char *cmdsuffix = NULL;
char *cmdindex = NULL;
char *outletname = NULL;
char outletname[SMALLBUF];
upsdebugx(1, "entering instcmd (%s)", cmdname);
@ -69,7 +69,7 @@ static int instcmd(const char *cmdname, const char *extra)
char buf[32];
cmdindex++;
snprintf(buf, sizeof(buf), "outlet.%i.desc", atoi(cmdindex));
outletname = (char *)dstate_getinfo(buf);
snprintf(outletname, sizeof(outletname), "%s", dstate_getinfo(buf));
}
/* Power on the outlet */

View file

@ -118,6 +118,24 @@ static const valtab_t yes_no_info[] = {
{ NULL }
};
/* Older models report the model in a numeric format 'rOnn' */
static const struct {
const char *val;
const char *model;
} modeltab[] = {
{ "rO10", "OP1000AVR" },
{ "rO27", "OP320AVR" },
{ "rO29", "OP500AVR" },
{ "rO31", "OP800AVR" },
{ "rO33", "OP850AVR" },
{ "rO37", "OP900AVR" },
{ "rO39", "OP650AVR" },
{ "rO41", "OP700AVR" },
{ "rO43", "OP1250AVR" },
{ "rO45", "OP1500AVR" },
{ NULL }
};
static const struct {
const char *var;
const char *get;
@ -300,7 +318,7 @@ static int powpan_setvar(const char *varname, const char *val)
return STAT_SET_UNKNOWN;
}
static void powpan_initinfo()
static void powpan_initinfo(void)
{
int i, j;
char *s;
@ -313,7 +331,18 @@ static void powpan_initinfo()
* was used for autodetection of the UPS. No need to do it again.
*/
if ((s = strtok((char *)&powpan_answer[1], ".")) != NULL) {
dstate_setinfo("ups.model", "%s", rtrim(s, ' '));
for (i = 0; modeltab[i].val != NULL; i++) {
if (!strncmp(s, modeltab[i].val, strlen(modeltab[i].val))) {
break;
}
}
if (modeltab[i].model) {
/* model found in table */
dstate_setinfo("ups.model", "%s", modeltab[i].model);
} else {
/* report model value as is */
dstate_setinfo("ups.model", "%s", rtrim(s, ' '));
}
}
if ((s = strtok(NULL, ".")) != NULL) {
dstate_setinfo("input.voltage.nominal", "%d", (unsigned char)s[0]);
@ -429,7 +458,7 @@ static int powpan_status(status_t *status)
return 0;
}
static int powpan_updateinfo()
static int powpan_updateinfo(void)
{
status_t status;
@ -513,7 +542,7 @@ static int powpan_updateinfo()
return (status.flags[0] & 0x80) ? 1 : 0;
}
static int powpan_initups()
static int powpan_initups(void)
{
int ret, i;
@ -581,6 +610,11 @@ static int powpan_initups()
type = OP;
}
/* This is for an older model series, that reports the model numerically */
if (!strncmp((char *)&powpan_answer[1], "rO", 2)) {
type = OP;
}
if (getval("ondelay")) {
fatalx(EXIT_FAILURE, "Setting 'ondelay' not supported by %s driver", powpan_binary.version);
}

View file

@ -47,10 +47,10 @@ static int offdelay = 60; /* seconds */
static char powpan_answer[SMALLBUF];
static const struct {
char *var;
char *get;
char *set;
static struct {
const char *var;
const char *get;
const char *set;
} vartab[] = {
{ "input.transfer.high", "P6\r", "C2:%03d\r" },
{ "input.transfer.low", "P7\r", "C3:%03d\r" },
@ -58,9 +58,9 @@ static const struct {
{ NULL }
};
static const struct {
char *cmd;
char *command;
static struct {
const char *cmd;
const char *command;
} cmdtab[] = {
{ "test.battery.start.quick", "T\r" },
{ "test.battery.stop", "CT\r" },
@ -208,7 +208,7 @@ static int powpan_setvar(const char *varname, const char *val)
return STAT_SET_UNKNOWN;
}
static void powpan_initinfo()
static void powpan_initinfo(void)
{
int i;
char *s;
@ -410,7 +410,7 @@ static int powpan_status(status_t *status)
return 0;
}
static int powpan_updateinfo()
static int powpan_updateinfo(void)
{
status_t status;
@ -466,7 +466,7 @@ static int powpan_updateinfo()
return (status.flags[0] & 0x40) ? 1 : 0;
}
static int powpan_initups()
static int powpan_initups(void)
{
int ret, i;

View file

@ -33,7 +33,7 @@
#define SER_WAIT_USEC 250000
typedef struct {
char *version;
const char *version;
int (*instcmd)(const char *cmdname, const char *extra);
int (*setvar)(const char *varname, const char *val);
int (*initups)(void);

View file

@ -201,7 +201,7 @@ static snmp_info_t pw_mib[] = {
0, NULL },
{ "battery.current", 0, 0.1, PW_OID_BATT_CURRENT, "",
0, NULL },
{ "battery.runtime.low", ST_FLAG_RW, 1.0, IETF_OID_CONF_RUNTIME_LOW, "",
{ "battery.runtime.low", 0, 60.0, IETF_OID_CONF_RUNTIME_LOW, "",
0, NULL },
/* Output page */

View file

@ -128,11 +128,11 @@ static unsigned char EventosRede, EventosSaida, EventosBateria;
// Grupo de Programação
/* Methods */
static void ScanReceivePack();
static void ScanReceivePack(void);
static int AutonomyCalc( int );
static void CommReceive(const unsigned char*, int );
static void getbaseinfo();
static void getupdateinfo();
static void getbaseinfo(void);
static void getupdateinfo(void);
static unsigned char RecPack[37];
@ -550,7 +550,7 @@ static void getbaseinfo(void)
int tam, i, j=0;
time_t *tmt;
struct tm *now;
char *Model;
const char *Model;
tmt = ( time_t * ) malloc( sizeof( time_t ) );
time( tmt );

View file

@ -157,7 +157,7 @@ static void usb_comm_fail(const char *fmt, ...)
upslogx(LOG_WARNING, "Communications with UPS lost: %s", why);
}
static void usb_comm_good()
static void usb_comm_good(void)
{
if (comm_failures == 0) {
return;

View file

@ -122,7 +122,7 @@ static int safenet_command(const char *command)
return 0;
}
static void safenet_update()
static void safenet_update(void)
{
status_init();

View file

@ -289,10 +289,11 @@ int ser_send_buf_pace(int fd, unsigned long d_usec, const void *buf,
{
int ret;
size_t sent;
const char *data = buf;
for (sent = 0; sent < buflen; sent += ret) {
ret = write(fd, &((char *)buf)[sent], (d_usec == 0) ? (buflen - sent) : 1);
ret = write(fd, &data[sent], (d_usec == 0) ? (buflen - sent) : 1);
if (ret < 1) {
return ret;
@ -321,12 +322,13 @@ int ser_get_buf_len(int fd, void *buf, size_t buflen, long d_sec, long d_usec)
{
int ret;
size_t recv;
char *data = buf;
memset(buf, '\0', buflen);
for (recv = 0; recv < buflen; recv += ret) {
ret = select_read(fd, &((char *)buf)[recv], buflen - recv, d_sec, d_usec);
ret = select_read(fd, &data[recv], buflen - recv, d_sec, d_usec);
if (ret < 1) {
return ret;
@ -344,6 +346,7 @@ int ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar,
{
int i, ret;
char tmp[64];
char *data = buf;
size_t count = 0, maxcount;
memset(buf, '\0', buflen);
@ -373,7 +376,7 @@ int ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar,
continue;
}
((char *)buf)[count++] = tmp[i];
data[count++] = tmp[i];
}
}

View file

@ -10,7 +10,6 @@
and possibly also to:
* docs/hid-subdrivers.txt for USB/HID devices
* or docs/snmp-subdrivers.txt for SNMP devices
* or docs/megatec.txt for Megatec / Q1 devices
*/
#include "main.h"

View file

@ -3,7 +3,7 @@
* Based on NetSNMP API (Simple Network Management Protocol V1-2)
*
* Copyright (C)
* 2002 - 2008 Arnaud Quette <arnaud.quette@free.fr>
* 2002 - 2010 Arnaud Quette <arnaud.quette@free.fr>
* 2002 - 2006 Dmitry Frolov <frolov@riss-telecom.ru>
* J.W. Hoogervorst <jeroen@hoogervorst.net>
* Niels Baggesen <niels@baggesen.net>
@ -43,6 +43,7 @@
#include "raritan-pdu-mib.h"
#include "baytech-mib.h"
#include "compaq-mib.h"
#include "bestpower-mib.h"
#include "ietf-mib.h"
static mib2nut_info_t *mib2nut[] = {
@ -55,6 +56,7 @@ static mib2nut_info_t *mib2nut[] = {
&raritan,
&baytech,
&compaq,
&bestpower,
/*
* Prepend vendor specific MIB mappings before IETF, so that
* if a device supports both IETF and vendor specific MIB,
@ -65,6 +67,8 @@ static mib2nut_info_t *mib2nut[] = {
NULL
};
int input_phases, output_phases, bypass_phases;
/* pointer to the Snmp2Nut lookup table */
mib2nut_info_t *mib2nut_info;
/* FIXME: to be trashed */
@ -75,7 +79,7 @@ const char *mibvers;
static void disable_transfer_oids(void);
#define DRIVER_NAME "Generic SNMP UPS driver"
#define DRIVER_VERSION "0.47"
#define DRIVER_VERSION "0.50"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -181,15 +185,27 @@ void upsdrv_makevartable(void)
upsdebugx(1, "entering upsdrv_makevartable()");
addvar(VAR_VALUE, SU_VAR_MIBS,
"Set MIB compliance (default=ietf, allowed mge,apcc,netvision,pw,cpqpower)");
"Set MIB compliance (default=ietf, allowed: mge,apcc,netvision,pw,cpqpower,...)");
addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_COMMUNITY,
"Set community name (default=public)");
"Set community name (default=public)");
addvar(VAR_VALUE, SU_VAR_VERSION,
"Set SNMP version (default=v1, allowed v2c)");
"Set SNMP version (default=v1, allowed v2c)");
addvar(VAR_VALUE, SU_VAR_POLLFREQ,
"Set polling frequency in seconds, to reduce network flow (default=30)");
"Set polling frequency in seconds, to reduce network flow (default=30)");
addvar(VAR_FLAG, "notransferoids",
"Disable transfer OIDs (use on APCC Symmetras)");
"Disable transfer OIDs (use on APCC Symmetras)");
addvar(VAR_VALUE, SU_VAR_SECLEVEL,
"Set the securityLevel used for SNMPv3 messages (default=noAuthNoPriv, allowed: authNoPriv,authPriv)");
addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_SECNAME,
"Set the securityName used for authenticated SNMPv3 messages (no default)");
addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_AUTHPASSWD,
"Set the authentication pass phrase used for authenticated SNMPv3 messages (no default)");
addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_PRIVPASSWD,
"Set the privacy pass phrase used for encrypted SNMPv3 messages (no default)");
addvar(VAR_VALUE, SU_VAR_AUTHPROT,
"Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 messages (default=MD5)");
addvar(VAR_VALUE, SU_VAR_PRIVPROT,
"Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages (default=DES)");
}
void upsdrv_initups(void)
@ -197,16 +213,15 @@ void upsdrv_initups(void)
snmp_info_t *su_info_p;
char model[SU_INFOSIZE];
bool_t status;
const char *community, *version, *mibs;
const char *mibs;
upsdebugx(1, "SNMP UPS driver : entering upsdrv_initups()");
community = testvar(SU_VAR_COMMUNITY) ? getval(SU_VAR_COMMUNITY) : "public";
version = testvar(SU_VAR_VERSION) ? getval(SU_VAR_VERSION) : "v1";
/* Retrieve user's parameters */
mibs = testvar(SU_VAR_MIBS) ? getval(SU_VAR_MIBS) : "auto";
/* init SNMP library, etc... */
nut_snmp_init(progname, device_path, version, community);
nut_snmp_init(progname, device_path);
/* FIXME: first test if the device is reachable to avoid timeouts! */
@ -219,7 +234,7 @@ void upsdrv_initups(void)
else
pollfreq = DEFAULT_POLLFREQ;
/* Get UPS Model node to see if there's a MIB */
/* Get UPS Model node to see if there's a MIB */
su_info_p = su_find_info("ups.model");
status = nut_snmp_get_str(su_info_p->OID, model, sizeof(model), NULL);
@ -228,7 +243,7 @@ void upsdrv_initups(void)
model, device_path, mibname, mibvers);
else
fatalx(EXIT_FAILURE, "%s MIB wasn't found on %s", mibs, g_snmp_sess.peername);
/* No supported device detected */
/* FIXME: "No supported device detected" */
}
void upsdrv_cleanup(void)
@ -240,11 +255,13 @@ void upsdrv_cleanup(void)
* SNMP functions.
* ----------------------------------------------------------- */
void nut_snmp_init(const char *type, const char *hostname, const char *version,
const char *community)
void nut_snmp_init(const char *type, const char *hostname)
{
upsdebugx(2, "SNMP UPS driver : entering nut_snmp_init(%s, %s, %s, %s)",
type, hostname, version, community);
const char *community, *version;
const char *secLevel = NULL, *authPassword, *privPassword;
const char *authProtocol, *privProtocol;
upsdebugx(2, "SNMP UPS driver : entering nut_snmp_init(%s)", type);
/* Initialize the SNMP library */
init_snmp(type);
@ -253,17 +270,104 @@ void nut_snmp_init(const char *type, const char *hostname, const char *version,
snmp_sess_init(&g_snmp_sess);
g_snmp_sess.peername = xstrdup(hostname);
g_snmp_sess.community = (unsigned char *)xstrdup(community);
g_snmp_sess.community_len = strlen(community);
if (strcmp(version, "v1") == 0)
g_snmp_sess.version = SNMP_VERSION_1;
else if (strcmp(version, "v2c") == 0)
g_snmp_sess.version = SNMP_VERSION_2c;
/* Retrieve user parameters */
version = testvar(SU_VAR_VERSION) ? getval(SU_VAR_VERSION) : "v1";
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 (strcmp(version, "v3") == 0) {
/* SNMP v3 related init */
g_snmp_sess.version = SNMP_VERSION_3;
/* Security level */
if (testvar(SU_VAR_SECLEVEL)) {
secLevel = getval(SU_VAR_SECLEVEL);
if (strcmp(secLevel, "noAuthNoPriv") == 0)
g_snmp_sess.securityLevel = SNMP_SEC_LEVEL_NOAUTH;
else if (strcmp(secLevel, "authNoPriv") == 0)
g_snmp_sess.securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
else if (strcmp(secLevel, "authPriv") == 0)
g_snmp_sess.securityLevel = SNMP_SEC_LEVEL_AUTHPRIV;
else
fatalx(EXIT_FAILURE, "Bad SNMPv3 securityLevel: %s", secLevel);
}
else
g_snmp_sess.securityLevel = SNMP_SEC_LEVEL_NOAUTH;
/* Security name */
if (testvar(SU_VAR_SECNAME)) {
g_snmp_sess.securityName = xstrdup(getval(SU_VAR_SECNAME));
g_snmp_sess.securityNameLen = strlen(g_snmp_sess.securityName);
}
else
fatalx(EXIT_FAILURE, "securityName is required for SNMPv3");
/* Process mandatory fields, based on the security level */
authPassword = testvar(SU_VAR_AUTHPASSWD) ? getval(SU_VAR_AUTHPASSWD) : NULL;
privPassword = testvar(SU_VAR_PRIVPASSWD) ? getval(SU_VAR_PRIVPASSWD) : NULL;
switch (g_snmp_sess.securityLevel) {
case SNMP_SEC_LEVEL_AUTHNOPRIV:
if (authPassword == NULL)
fatalx(EXIT_FAILURE, "authPassword is required for SNMPv3 in %s mode", secLevel);
case SNMP_SEC_LEVEL_AUTHPRIV:
if ((authPassword == NULL) || (privPassword == NULL))
fatalx(EXIT_FAILURE, "authPassword and privPassword are required for SNMPv3 in %s mode", secLevel);
default:
case SNMP_SEC_LEVEL_NOAUTH:
/* nothing else needed */
break;
}
/* Process authentication protocol and key */
g_snmp_sess.securityAuthKeyLen = USM_AUTH_KU_LEN;
authProtocol = testvar(SU_VAR_AUTHPROT) ? getval(SU_VAR_AUTHPROT) : "MD5";
if (strcmp(authProtocol, "MD5") == 0) {
g_snmp_sess.securityAuthProto = usmHMACMD5AuthProtocol;
g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid);
}
else if (strcmp(authProtocol, "SHA") == 0) {
g_snmp_sess.securityAuthProto = usmHMACSHA1AuthProtocol;
g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/sizeof(oid);
}
else
fatalx(EXIT_FAILURE, "Bad SNMPv3 authProtocol: %s", authProtocol);
/* set the authentication key to a MD5/SHA1 hashed version of our
* passphrase (must be at least 8 characters long) */
if (generate_Ku(g_snmp_sess.securityAuthProto,
g_snmp_sess.securityAuthProtoLen,
(u_char *) privPassword, strlen(privPassword),
g_snmp_sess.securityAuthKey,
&g_snmp_sess.securityAuthKeyLen) != SNMPERR_SUCCESS) {
fatalx(EXIT_FAILURE, "Error generating Ku from authentication pass phrase");
}
privProtocol = testvar(SU_VAR_PRIVPROT) ? getval(SU_VAR_PRIVPROT) : "DES";
if (strcmp(privProtocol, "DES") == 0) {
g_snmp_sess.securityPrivProto = usmDESPrivProtocol;
g_snmp_sess.securityPrivProtoLen = sizeof(usmDESPrivProtocol)/sizeof(oid);
}
else if (strcmp(privProtocol, "AES") == 0) {
g_snmp_sess.securityPrivProto = usmAESPrivProtocol;
g_snmp_sess.securityPrivProtoLen = sizeof(usmAESPrivProtocol)/sizeof(oid);
}
else
fatalx(EXIT_FAILURE, "Bad SNMPv3 authProtocol: %s", authProtocol);
}
else
fatalx(EXIT_FAILURE, "Bad SNMP version: %s", version);
/* Open the session */
SOCK_STARTUP; /* wrapper not needed on Unix! */
SOCK_STARTUP; /* MS Windows wrapper, not really needed on Unix! */
g_snmp_sess_p = snmp_open(&g_snmp_sess); /* establish the session */
if (g_snmp_sess_p == NULL) {
nut_snmp_perror(&g_snmp_sess, 0, NULL, "nut_snmp_init: snmp_open");
@ -767,7 +871,7 @@ int base_snmp_outlet_index(const char *OID_template)
/* return the NUT offset (increment) based on outlet_index_base
* ie (outlet_index_base == 0) => increment +1
* (outlet_index_base == 1) => increment +0 */
int base_nut_outlet_offset()
int base_nut_outlet_offset(void)
{
return (outlet_index_base==0)?1:0;
}
@ -860,50 +964,86 @@ bool_t snmp_ups_walk(int mode)
continue;
if (su_info_p->flags & SU_INPHASES) {
upsdebugx(1, "Check inphases");
if (input_phases == 0) continue;
upsdebugx(1, "inphases is set");
if (su_info_p->flags & SU_INPUT_1) {
if (input_phases == 1)
su_info_p->flags &= ~SU_INPHASES;
else {
upsdebugx(1, "inphases is not 1");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
upsdebugx(1, "Check input_phases");
if (input_phases == 0) {
continue;
}
else if (su_info_p->flags & SU_INPUT_3) {
if (input_phases == 3)
if (su_info_p->flags & SU_INPUT_1) {
if (input_phases == 1) {
upsdebugx(1, "input_phases is 1");
su_info_p->flags &= ~SU_INPHASES;
else {
upsdebugx(1, "inphases is not 3");
su_info_p->flags &= ~SU_FLAG_OK;
} else {
upsdebugx(1, "input_phases is not 1");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
} else if (su_info_p->flags & SU_INPUT_3) {
if (input_phases == 3) {
upsdebugx(1, "input_phases is 3");
su_info_p->flags &= ~SU_INPHASES;
} else {
upsdebugx(1, "input_phases is not 3");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
} else {
upsdebugx(1, "input_phases is %d", input_phases);
}
}
if (su_info_p->flags & SU_OUTPHASES) {
upsdebugx(1, "Check outphases");
if (output_phases == 0) continue;
upsdebugx(1, "outphases is set");
upsdebugx(1, "Check output_phases");
if (output_phases == 0) {
continue;
}
if (su_info_p->flags & SU_OUTPUT_1) {
if (output_phases == 1)
if (output_phases == 1) {
upsdebugx(1, "output_phases is 1");
su_info_p->flags &= ~SU_OUTPHASES;
else {
upsdebugx(1, "outphases is not 1");
} else {
upsdebugx(1, "output_phases is not 1");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
}
else if (su_info_p->flags & SU_OUTPUT_3) {
if (output_phases == 3)
} else if (su_info_p->flags & SU_OUTPUT_3) {
if (output_phases == 3) {
upsdebugx(1, "output_phases is 3");
su_info_p->flags &= ~SU_OUTPHASES;
else {
upsdebugx(1, "outphases is not 3");
su_info_p->flags &= ~SU_FLAG_OK;
} else {
upsdebugx(1, "output_phases is not 3");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
} else {
upsdebugx(1, "output_phases is %d", output_phases);
}
}
if (su_info_p->flags & SU_BYPPHASES) {
upsdebugx(1, "Check bypass_phases");
if (bypass_phases == 0) {
continue;
}
if (su_info_p->flags & SU_BYPASS_1) {
if (bypass_phases == 1) {
upsdebugx(1, "bypass_phases is 1");
su_info_p->flags &= ~SU_BYPPHASES;
} else {
upsdebugx(1, "bypass_phases is not 1");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
} else if (su_info_p->flags & SU_BYPASS_3) {
if (input_phases == 3) {
upsdebugx(1, "bypass_phases is 3");
su_info_p->flags &= ~SU_BYPPHASES;
} else {
upsdebugx(1, "bypass_phases is not 3");
su_info_p->flags &= ~SU_FLAG_OK;
continue;
}
} else {
upsdebugx(1, "bypass_phases is %d", bypass_phases);
}
}

View file

@ -3,7 +3,7 @@
* Based on NET-SNMP API (Simple Network Management Protocol V1-2)
*
* Copyright (C)
* 2002-2008 Arnaud Quette <arnaud.quette@free.fr>
* 2002-2010 Arnaud Quette <arnaud.quette@free.fr>
* 2002-2006 Dmitry Frolov <frolov@riss-telecom.ru>
* J.W. Hoogervorst <jeroen@hoogervorst.net>
* Niels Baggesen <niels@baggesen.net>
@ -35,19 +35,19 @@ for each OID request we made), instead of sending many small packets
- add support for registration and traps (manager mode),
- complete mib2nut data (add all OID translation to NUT)
- externalize mib2nut data in .m2n files and load at driver startup using parseconf()...
- ... and use Net-SNMP lookup mecanism for OIDs (use string path, not numeric)
- adjust information logging.
- move to numeric OIDs
- move numeric OIDs into th mib2nut tables and remove defines
- move mib2nut into c files (à la usbhid-ups)?
- add a claim function and move to usbhid-ups style
- add a claim function and move to usbhid-ups style for specific processing
- rework the flagging system
*/
#ifndef SNMP_UPS_H
#define SNMP_UPS_H
/* workaround for buggy Net-SNMP config */
/* FIXME: still needed?
* workaround for buggy Net-SNMP config */
#ifdef PACKAGE_BUGREPORT
#undef PACKAGE_BUGREPORT
#endif
@ -143,28 +143,39 @@ typedef struct {
#define SU_STATUS_INDEX(t) (((t) >> 8) & 7)
/* Phase specific data */
#define SU_PHASES (0xF << 12)
#define SU_PHASES (0x3F << 12)
#define SU_INPHASES (0x3 << 12)
#define SU_INPUT_1 (1 << 12) /* only if 1 input phase */
#define SU_INPUT_3 (1 << 13) /* only if 3 input phases */
#define SU_OUTPHASES (0x3 << 14)
#define SU_OUTPUT_1 (1 << 14) /* only if 1 output phase */
#define SU_OUTPUT_3 (1 << 15) /* only if 3 output phases */
#define SU_BYPPHASES (0x3 << 16)
#define SU_BYPASS_1 (1 << 16) /* only if 1 bypass phase */
#define SU_BYPASS_3 (1 << 17) /* only if 3 bypass phases */
/* FIXME: use input.phases and output.phases to replace this */
/* hints for su_ups_set, applicable only to rw vars */
#define SU_TYPE_INT (0 << 16) /* cast to int when setting value */
#define SU_TYPE_STRING (1 << 16) /* cast to string. FIXME: redundant with ST_FLAG_STRING */
#define SU_TYPE_TIME (2 << 16) /* cast to int */
#define SU_TYPE_CMD (3 << 16) /* instant command */
#define SU_TYPE(t) ((t)->flags & (7 << 16))
#define SU_TYPE_INT (0 << 18) /* cast to int when setting value */
#define SU_TYPE_STRING (1 << 18) /* cast to string. FIXME: redundant with ST_FLAG_STRING */
#define SU_TYPE_TIME (2 << 18) /* cast to int */
#define SU_TYPE_CMD (3 << 18) /* instant command */
#define SU_TYPE(t) ((t)->flags & (7 << 18))
#define SU_VAR_COMMUNITY "community"
#define SU_VAR_VERSION "snmp_version"
#define SU_VAR_MIBS "mibs"
#define SU_VAR_SDTYPE "sdtype"
#define SU_VAR_POLLFREQ "pollfreq"
#define SU_VAR_SDTYPE "sdtype"
/* SNMP v3 related parameters */
#define SU_VAR_SECLEVEL "secLevel"
#define SU_VAR_SECNAME "secName"
#define SU_VAR_AUTHPASSWD "authPassword"
#define SU_VAR_PRIVPASSWD "privPassword"
#define SU_VAR_AUTHPROT "authProtocol"
#define SU_VAR_PRIVPROT "privProtocol"
#define SU_INFOSIZE 128
#define SU_BUFSIZE 32
@ -191,8 +202,7 @@ typedef struct {
} mib2nut_info_t;
/* Common SNMP functions */
void nut_snmp_init(const char *type, const char *host, const char *version,
const char *community);
void nut_snmp_init(const char *type, const char *hostname);
void nut_snmp_cleanup(void);
struct snmp_pdu *nut_snmp_get(const char *OID);
bool_t nut_snmp_get_str(const char *OID, char *buf, size_t buf_len,
@ -230,7 +240,7 @@ struct snmp_session g_snmp_sess, *g_snmp_sess_p;
const char *OID_pwr_status;
int g_pwr_battery;
int pollfreq; /* polling frequency */
int input_phases, output_phases;
extern int input_phases, output_phases, bypass_phases;
#endif /* SNMP_UPS_H */

View file

@ -341,13 +341,13 @@ double Bat_LimInfRede, Bat_LimSupRede, Bat_LimInfInv, Bat_LimSupInv, Bat_VoltNom
double AppPower, UtilPower, upscharge;
int ChargePowerFactor, NominalPower, UpsPowerFactor;
static void prnInfo();
static void prnInfo(void);
static int IsToday( unsigned char, int );
static void AutonomyCalc( int );
static void ScanReceivePack();
static void ScanReceivePack(void);
static void CommReceive(const char*, int );
static void getbaseinfo();
static void getupdateinfo();
static void getbaseinfo(void);
static void getupdateinfo(void);
#endif /* INCLUDED_SOLIS_H */

View file

@ -29,7 +29,7 @@
#include "tripplite-hid.h"
#include "usb-common.h"
#define TRIPPLITE_HID_VERSION "TrippLite HID 0.4"
#define TRIPPLITE_HID_VERSION "TrippLite HID 0.6"
/* FIXME: experimental flag to be put in upsdrv_info */
@ -41,13 +41,13 @@
static double battery_scale = 1.0;
/* Specific handlers for USB device matching */
static void *battery_scale_1dot0()
static void *battery_scale_1dot0(void)
{
/* FIXME: we could remove this one since it's the default! */
battery_scale = 1.0;
return NULL;
}
static void *battery_scale_0dot1()
static void *battery_scale_0dot1(void)
{
battery_scale = 0.1;
return NULL;
@ -67,25 +67,60 @@ static usb_device_id_t tripplite_usb_device_table[] = {
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x1007), battery_scale_0dot1 },
/* e.g. TrippLite ECO550UPS */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x1008), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x1009), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x1010), battery_scale_0dot1 },
/* e.g. TrippLite OMNI1000LCD */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2005), battery_scale_0dot1 },
/* e.g. TrippLite OMNI900LCD */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2007), battery_scale_0dot1 },
/* e.g. ? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2008), battery_scale_0dot1 },
/* e.g. TrippLite Smart1000LCD */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2009), battery_scale_0dot1 },
/* e.g. ? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2010), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2011), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2012), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2013), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x2014), battery_scale_0dot1 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3008), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3009), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3010), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3011), battery_scale_1dot0 },
/* e.g. TrippLite smart2200RMXL2U */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3012), battery_scale_1dot0 },
/* e.g. ? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3013), battery_scale_1dot0 },
/* e.g. ? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3014), battery_scale_1dot0 },
/* e.g. ? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3015), battery_scale_1dot0 },
/* e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?) */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4001), battery_scale_1dot0 },
/* e.g. TrippLite SmartOnline SU6000RT4U? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4002), battery_scale_1dot0 },
/* e.g. TrippLite SmartOnline SU1500RTXL2ua */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4003), battery_scale_1dot0 },
/* e.g. TrippLite SmartOnline SU1000XLA */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4004), battery_scale_1dot0 },
/* e.g. ? */
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4005), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4006), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4007), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4008), battery_scale_1dot0 },
/* HP R/T 2200 INTL (like SMART2200RMXL2U) */
{ USB_DEVICE(HP_VENDORID, 0x1f0a), battery_scale_1dot0 },
/* HP T750 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1f06), battery_scale_1dot0 },
/* HP T1000 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1f08), battery_scale_1dot0 },
/* HP T1500 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1f09), battery_scale_1dot0 },
/* HP R/T 2200 INTL (like SMART2200RMXL2U) */
{ USB_DEVICE(HP_VENDORID, 0x1f0a), battery_scale_1dot0 },
/* HP R1500 G2 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1fe0), battery_scale_1dot0 },
/* HP T750 G2 */
{ USB_DEVICE(HP_VENDORID, 0x1fe1), battery_scale_1dot0 },
/* Terminating entry */
{ -1, -1, NULL }
@ -93,7 +128,7 @@ static usb_device_id_t tripplite_usb_device_table[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *tripplite_chemistry_fun(double value)
static const char *tripplite_chemistry_fun(double value)
{
static char buf[20];
const char *model;
@ -119,7 +154,7 @@ static info_lkp_t tripplite_chemistry[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *tripplite_battvolt_fun(double value)
static const char *tripplite_battvolt_fun(double value)
{
static char buf[8];
@ -261,7 +296,8 @@ static hid_info_t tripplite_hid2nut[] = {
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, 0, trim_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, 0, boost_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Overload", NULL, NULL, 0, overload_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Used", NULL, NULL, 0, nobattery_info },
/* This is probably not the correct mapping for all models */
/* { "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Used", NULL, NULL, 0, nobattery_info }, */
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.InternalFailure", NULL, NULL, 0, commfault_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.AwaitingPower", NULL, NULL, 0, awaitingpower_info },
@ -322,15 +358,15 @@ static hid_info_t tripplite_hid2nut[] = {
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};
static char *tripplite_format_model(HIDDevice_t *hd) {
static const char *tripplite_format_model(HIDDevice_t *hd) {
return hd->Product;
}
static char *tripplite_format_mfr(HIDDevice_t *hd) {
static const char *tripplite_format_mfr(HIDDevice_t *hd) {
return hd->Vendor;
}
static char *tripplite_format_serial(HIDDevice_t *hd) {
static const char *tripplite_format_serial(HIDDevice_t *hd) {
return hd->Serial;
}
@ -347,11 +383,16 @@ static int tripplite_claim(HIDDevice_t *hd) {
switch (hd->VendorID)
{
/*
* this vendor makes lots of USB devices that are
* not a UPS, so don't use possibly_supported here
*/
case HP_VENDORID:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
return 1;
}
/*
* this vendor makes lots of USB devices that are
* not a UPS, so don't use possibly_supported here
*/
return 0;
case TRIPPLITE_VENDORID:

View file

@ -178,7 +178,7 @@ static int send_cmd(const char *str, char *buf, size_t len)
return i;
}
static void get_letter_cmd(char *str, char *buf, size_t len)
static void get_letter_cmd(const char *str, char *buf, size_t len)
{
int tries, ret;

View file

@ -130,7 +130,7 @@
POD ("Plain Old Documentation") - run through pod2html or perldoc. See
perlpod(1) for more information.
pod2man --name='TRIPPLITE_USB' --section=8 --release='$Rev: 2336 $' --center='Network UPS Tools (NUT)' tripplite_usb.c
pod2man --name='TRIPPLITE_USB' --section=8 --release='$Rev: 2598 $' --center='Network UPS Tools (NUT)' tripplite_usb.c
=head1 NAME
@ -489,7 +489,7 @@ static int hex2d(const unsigned char *start, unsigned int len)
unsigned char buf[32];
buf[31] = '\0';
strncpy((char *)buf, (char *)start, (len < (sizeof buf) ? len : (sizeof buf - 1)));
strncpy((char *)buf, (const char *)start, (len < (sizeof buf) ? len : (sizeof buf - 1)));
if(len < sizeof(buf)) buf[len] = '\0';
return strtol((char *)buf, NULL, 16);
}
@ -722,7 +722,7 @@ void debug_message(const char *msg, int len)
snprintf(var_name, sizeof(var_name), "ups.debug.%c", *msg);
ret = send_cmd((unsigned char *)msg, len, tmp_value, sizeof(tmp_value));
ret = send_cmd((const unsigned char *)msg, len, tmp_value, sizeof(tmp_value));
if(ret <= 0) {
sprintf(err_msg, "Error reading '%c' value", *msg);
usb_comm_fail(ret, err_msg);
@ -847,12 +847,12 @@ static int instcmd(const char *cmdname, const char *extra)
if(tl_model == TRIPP_LITE_SMARTPRO || tl_model == TRIPP_LITE_SMART_0004) {
if (!strcasecmp(cmdname, "test.battery.start")) {
send_cmd((unsigned char *)"A", 2, buf, sizeof buf);
send_cmd((const unsigned char *)"A", 2, buf, sizeof buf);
return STAT_INSTCMD_HANDLED;
}
if(!strcasecmp(cmdname, "reset.input.minmax")) {
return (send_cmd((unsigned char *)"Z", 2, buf, sizeof buf) == 2) ? STAT_INSTCMD_HANDLED : STAT_INSTCMD_UNKNOWN;
return (send_cmd((const unsigned char *)"Z", 2, buf, sizeof buf) == 2) ? STAT_INSTCMD_HANDLED : STAT_INSTCMD_UNKNOWN;
}
}

View file

@ -20,7 +20,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: upscode2.c 2350 2010-02-16 08:28:21Z adkorte-guest $
$Id: upscode2.c 2391 2010-03-04 15:35:09Z adkorte-guest $
*/
/*
@ -539,8 +539,7 @@ void upsdrv_initinfo(void)
upslogx(LOG_ERR, "No contact with UPS, delaying init.");
status = UPSC_STAT_NOTINIT;
return;
}
else {
} else {
status = 0;
}
@ -549,10 +548,16 @@ void upsdrv_initinfo(void)
upsc_flush_input();
upscsend("UPDA");
}
if (can_upid)
if (can_upid) {
upsc_getvalue("UPID", NULL, "ACID", "ups.id", NULL);
if (can_uppm)
}
if (can_uppm) {
check_uppm();
}
/* make sure we have some sensible defaults */
setvar("ups.delay.shutdown", "10");
setvar("ups.delay.reboot", "60");
upsh.instcmd = instcmd;
upsh.setvar = setvar;
@ -870,27 +875,19 @@ void upsdrv_updateinfo(void)
void upsdrv_shutdown(void)
{
if (upsc_commandlist()) {
if (!can_upsd || !can_uppc) {
fatalx(LOG_EMERG, "Shutdown called, but UPS does not support it");
}
} else {
upslogx(LOG_EMERG, "Can't determine if shutdown is supported, attempting anyway");
}
upslogx(LOG_EMERG, "Emergency shutdown");
upscsend("UPSD"); /* Set shutdown delay */
upscsend("1"); /* 1 second (lowest possible. 0 returns current.*/
upslogx(LOG_EMERG, "Shutting down...");
upscsend("UPPC"); /* Powercycle UPS */
upscsend("IJHLDMGCIU"); /* security code */
/* send shutdown command twice, just to be sure */
instcmd("shutdown.reboot", NULL);
sleep(1);
instcmd("shutdown.reboot", NULL);
sleep(1);
}
static int instcmd (const char *auxcmd, const char *data)
{
cmd_t *cp = commands;
cmd_t *cp;
if (!strcasecmp(auxcmd, "beeper.off")) {
/* compatibility mode for old command */
@ -907,17 +904,20 @@ static int instcmd (const char *auxcmd, const char *data)
}
upsdebugx(1, "Instcmd: %s %s", auxcmd, data ? data : "\"\"");
while (cp->cmd) {
if (strcmp(cp->cmd, auxcmd) == 0) {
upscsend(cp->upsc);
if (cp->upsp)
upscsend(cp->upsp);
else if (data)
upscsend(data);
return STAT_INSTCMD_HANDLED;
for (cp = commands; cp->cmd; cp++) {
if (strcasecmp(cp->cmd, auxcmd)) {
continue;
}
cp++;
upscsend(cp->upsc);
if (cp->upsp) {
upscsend(cp->upsp);
} else if (data) {
upscsend(data);
}
return STAT_INSTCMD_HANDLED;
}
upslogx(LOG_INFO, "instcmd: unknown command %s", auxcmd);
return STAT_INSTCMD_UNKNOWN;
}
@ -925,16 +925,18 @@ static int instcmd (const char *auxcmd, const char *data)
static int setvar (const char *var, const char *data)
{
cmd_t *cp = variables;
cmd_t *cp;
upsdebugx(1, "Setvar: %s %s", var, data);
while (cp->cmd) {
if (strcmp(cp->cmd, var) == 0) {
upsc_getvalue(cp->upsc, data, cp->upsp, cp->cmd, NULL);
return STAT_SET_HANDLED;
for (cp = variables; cp->cmd; cp++) {
if (strcasecmp(cp->cmd, var)) {
continue;
}
cp++;
upsc_getvalue(cp->upsc, data, cp->upsp, cp->cmd, NULL);
return STAT_SET_HANDLED;
}
upslogx(LOG_INFO, "Setvar: unsettable variable %s", var);
return STAT_SET_UNKNOWN;
}
@ -1100,38 +1102,34 @@ static int upsc_commandlist(void)
can_upsd = 1;
else if (strcmp(buf, "UPPC") == 0)
can_uppc = 1;
cp = commands;
while (cp->cmd) {
for (cp = commands; cp->cmd; cp++) {
if (cp->upsc && strcmp(cp->upsc, buf) == 0) {
upsdebugx(1, "instcmd: %s %s", cp->cmd, cp->upsc);
dstate_addcmd(cp->cmd);
cp->enabled = 1;
break;
break;
}
cp++;
}
cp = variables;
while (cp->cmd) {
for (cp = variables; cp->cmd; cp++) {
if (cp->upsc && strcmp(cp->upsc, buf) == 0) {
upsdebugx(1, "setvar: %s %s", cp->cmd, cp->upsc);
cp->enabled = 1;
break;
}
cp++;
}
if (strcmp(buf, "UPCL") == 0)
break;
}
cp = variables;
while (cp->cmd) {
for (cp = variables; cp->cmd; cp++) {
if (cp->enabled) {
upsc_getvalue(cp->upsc, "0", cp->upsp, cp->cmd, NULL);
upsc_getvalue(cp->upsc, "0000", cp->upsp, cp->cmd, NULL);
dstate_setflags(cp->cmd, ST_FLAG_RW | ST_FLAG_STRING);
dstate_setaux(cp->cmd, 7);
}
cp++;
}
return 1;

View file

@ -38,18 +38,18 @@ typedef struct {
void *next;
} ups_t;
static ups_t *upstable = NULL;
static ups_t *upstable = NULL;
static int maxsdorder = 0, testmode = 0, exec_error = 0;
static int maxsdorder = 0, testmode = 0, exec_error = 0;
/* timer - keeps us from getting stuck if a driver hangs */
static int maxstartdelay = 45;
static int maxstartdelay = 45;
/* Directory where driver executables live */
static char *driverpath = NULL;
static char *driverpath = NULL;
/* passthrough to the drivers: chroot path and new user name */
static char *pt_root = NULL, *pt_user = NULL;
static char *pt_root = NULL, *pt_user = NULL;
void do_upsconf_args(char *upsname, char *var, char *val)
{
@ -123,7 +123,7 @@ static void stop_driver(const ups_t *ups)
{
char pidfn[SMALLBUF];
int ret;
struct stat fs;
struct stat fs;
upsdebugx(1, "Stopping UPS: %s", ups->upsname);
@ -131,7 +131,7 @@ static void stop_driver(const ups_t *ups)
ups->driver, ups->upsname);
ret = stat(pidfn, &fs);
if (ret != 0) {
if ((ret != 0) && (ups->port != NULL)) {
snprintf(pidfn, sizeof(pidfn), "%s/%s-%s.pid", altpidpath(),
ups->driver, xbasename(ups->port));
ret = stat(pidfn, &fs);
@ -164,22 +164,20 @@ static void waitpid_timeout(const int sig)
}
/* print out a command line at the given debug level. */
static void debugcmdline(int level, char *msg, char *cmd, char **argv) {
char cmdline[200];
static void debugcmdline(int level, const char *msg, char *const argv[])
{
char cmdline[LARGEBUF];
snprintf(cmdline, sizeof(cmdline), "%s", msg);
cmdline[0] = 0;
strncat(cmdline, msg, 200-strlen(cmdline));
strncat(cmdline, cmd, 200-strlen(cmdline));
argv++; /* don't repeat command name */
while (*argv) {
strncat(cmdline, " ", 200-strlen(cmdline));
strncat(cmdline, *argv, 200-strlen(cmdline));
argv++;
snprintfcat(cmdline, sizeof(cmdline), " %s", *argv++);
}
upsdebugx(level, "%s", cmdline);
}
static void forkexec(const char *prog, char **argv, const ups_t *ups)
static void forkexec(char *const argv[], const ups_t *ups)
{
int ret;
pid_t pid;
@ -239,7 +237,7 @@ static void forkexec(const char *prog, char **argv, const ups_t *ups)
/* child */
ret = execv(prog, argv);
ret = execv(argv[0], argv);
/* shouldn't get here */
fatal_with_errno(EXIT_FAILURE, "execv");
@ -247,9 +245,10 @@ static void forkexec(const char *prog, char **argv, const ups_t *ups)
static void start_driver(const ups_t *ups)
{
char dfn[SMALLBUF], *argv[8];
char *argv[8];
char dfn[SMALLBUF];
int ret, arg = 0;
struct stat fs;
struct stat fs;
upsdebugx(1, "Starting UPS: %s", ups->upsname);
@ -260,29 +259,28 @@ static void start_driver(const ups_t *ups)
fatal_with_errno(EXIT_FAILURE, "Can't start %s", dfn);
argv[arg++] = dfn;
argv[arg++] = "-a";
argv[arg++] = (char *)"-a"; /* FIXME: cast away const */
argv[arg++] = ups->upsname;
/* stick on the chroot / user args if given to us */
if (pt_root) {
argv[arg++] = "-r";
argv[arg++] = (char *)"-r"; /* FIXME: cast away const */
argv[arg++] = pt_root;
}
if (pt_user) {
argv[arg++] = "-u";
argv[arg++] = (char *)"-u"; /* FIXME: cast away const */
argv[arg++] = pt_user;
}
/* tie it off */
argv[arg++] = NULL;
debugcmdline(2, "exec: ", dfn, argv);
debugcmdline(2, "exec: ", argv);
if (testmode)
return;
forkexec(dfn, argv, ups);
if (!testmode) {
forkexec(argv, ups);
}
}
static void help(const char *progname)
@ -307,7 +305,8 @@ static void help(const char *progname)
static void shutdown_driver(const ups_t *ups)
{
char *argv[7], dfn[SMALLBUF];
char *argv[9];
char dfn[SMALLBUF];
int arg = 0;
upsdebugx(1, "Shutdown UPS: %s", ups->upsname);
@ -315,29 +314,28 @@ static void shutdown_driver(const ups_t *ups)
snprintf(dfn, sizeof(dfn), "%s/%s", driverpath, ups->driver);
argv[arg++] = dfn;
argv[arg++] = "-a";
argv[arg++] = (char *)"-a"; /* FIXME: cast away const */
argv[arg++] = ups->upsname;
argv[arg++] = "-k";
argv[arg++] = (char *)"-k"; /* FIXME: cast away const */
/* stick on the chroot / user args if given to us */
if (pt_root) {
argv[arg++] = "-r";
argv[arg++] = (char *)"-r"; /* FIXME: cast away const */
argv[arg++] = pt_root;
}
if (pt_user) {
argv[arg++] = "-u";
argv[arg++] = (char *)"-u"; /* FIXME: cast away const */
argv[arg++] = pt_user;
}
argv[arg++] = NULL;
debugcmdline(2, "exec: ", dfn, argv);
debugcmdline(2, "exec: ", argv);
if (testmode)
return;
forkexec(dfn, argv, ups);
if (!testmode) {
forkexec(argv, ups);
}
}
static void send_one_driver(void (*command)(const ups_t *), const char *upsname)

View file

@ -210,7 +210,7 @@ static int compile_regex(regex_t **compiled, char *regex, int cflags)
static int match_regex(regex_t *preg, char *str)
{
int r;
size_t len;
size_t len = 0;
char *string;
regmatch_t match;
@ -219,31 +219,28 @@ static int match_regex(regex_t *preg, char *str)
}
if (!str) {
str = "";
}
string = xstrdup("");
} else {
/* skip leading whitespace */
for (len = 0; len < strlen(str); len++) {
/* skip leading whitespace */
for (len = 0; len < strlen(str); len++) {
if (!strchr(" \t\n", str[len])) {
break;
if (!strchr(" \t\n", str[len])) {
break;
}
}
}
string = strdup(str+len);
if (!string) {
return -1;
}
string = xstrdup(str+len);
/* skip trailing whitespace */
for (len = strlen(string); len > 0; len--) {
/* skip trailing whitespace */
for (len = strlen(string); len > 0; len--) {
if (!strchr(" \t\n", string[len-1])) {
break;
if (!strchr(" \t\n", string[len-1])) {
break;
}
}
}
string[len] = '\0';
string[len] = '\0';
}
/* test the regular expression */
r = regexec(preg, string, 1, &match, 0);

View file

@ -27,7 +27,7 @@
*/
#define DRIVER_NAME "Generic HID driver"
#define DRIVER_VERSION "0.34"
#define DRIVER_VERSION "0.35"
#include "main.h"
#include "libhid.h"
@ -45,6 +45,7 @@
#include "liebert-hid.h"
#include "powercom-hid.h"
#include "tripplite-hid.h"
#include "idowell-hid.h"
#endif
/* master list of avaiable subdrivers */
@ -60,6 +61,7 @@ static subdriver_t *subdriver_list[] = {
&liebert_subdriver,
&powercom_subdriver,
&tripplite_subdriver,
&idowell_subdriver,
#endif
NULL
};
@ -112,9 +114,9 @@ hid_dev_handle_t udev;
/* support functions */
static hid_info_t *find_nut_info(const char *varname);
static hid_info_t *find_hid_info(const HIDData_t *hiddata);
static char *hu_find_infoval(info_lkp_t *hid2info, const double value);
static const char *hu_find_infoval(info_lkp_t *hid2info, const double value);
static long hu_find_valinfo(info_lkp_t *hid2info, const char* value);
static void process_boolean_info(char *nutvalue);
static void process_boolean_info(const char *nutvalue);
static void ups_alarm_set(void);
static void ups_status_set(void);
static bool_t hid_ups_walk(walkmode_t mode);
@ -172,8 +174,8 @@ typedef enum {
collected from the hardware; not yet converted to official NUT
status or alarms */
typedef struct {
char *status_str; /* ups status string */
int status_mask; /* ups status mask */
const char *status_str; /* ups status string */
const int status_mask; /* ups status mask */
} status_lkp_t;
static status_lkp_t status_info[] = {
@ -382,6 +384,7 @@ info_lkp_t test_read_info[] = {
{ 4, "Aborted", NULL },
{ 5, "In progress", NULL },
{ 6, "No test initiated", NULL },
{ 7, "Test scheduled", NULL },
{ 0, NULL, NULL }
};
@ -406,7 +409,7 @@ info_lkp_t on_off_info[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *date_conversion_fun(double value)
static const char *date_conversion_fun(double value)
{
static char buf[20];
int year, month, day;
@ -430,7 +433,7 @@ info_lkp_t date_conversion[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *hex_conversion_fun(double value)
static const char *hex_conversion_fun(double value)
{
static char buf[20];
@ -445,7 +448,7 @@ info_lkp_t hex_conversion[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *stringid_conversion_fun(double value)
static const char *stringid_conversion_fun(double value)
{
static char buf[20];
@ -458,7 +461,7 @@ info_lkp_t stringid_conversion[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *divide_by_10_conversion_fun(double value)
static const char *divide_by_10_conversion_fun(double value)
{
static char buf[20];
@ -473,7 +476,7 @@ info_lkp_t divide_by_10_conversion[] = {
/* returns statically allocated string - must not use it again before
done with result! */
static char *kelvin_celsius_conversion_fun(double value)
static const char *kelvin_celsius_conversion_fun(double value)
{
static char buf[20];
@ -773,7 +776,7 @@ void upsdrv_updateinfo(void)
continue;
if (nut_debug_level >= 2) {
upsdebugx(2, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %f",
upsdebugx(2, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %g",
HIDGetDataItem(event[i], subdriver->utab),
HIDDataType(event[i]), event[i]->ReportID,
event[i]->Offset, event[i]->Size, value);
@ -984,7 +987,7 @@ void possibly_supported(const char *mfr, HIDDevice_t *hd)
/* Update ups_status to remember this status item. Interpretation is
done in ups_status_set(). */
static void process_boolean_info(char *nutvalue)
static void process_boolean_info(const char *nutvalue)
{
status_lkp_t *status_item;
int clear = 0;
@ -1016,7 +1019,7 @@ static void process_boolean_info(char *nutvalue)
static int callback(hid_dev_handle_t udev, HIDDevice_t *hd, unsigned char *rdbuf, int rdlen)
{
int i;
char *mfr = NULL, *model = NULL, *serial = NULL;
const char *mfr = NULL, *model = NULL, *serial = NULL;
#ifndef SHUT_MODE
int ret;
#endif
@ -1232,7 +1235,7 @@ static bool_t hid_ups_walk(walkmode_t mode)
continue;
}
upsdebugx(2, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %f",
upsdebugx(2, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %g",
item->hidpath, HIDDataType(item->hiddata), item->hiddata->ReportID,
item->hiddata->Offset, item->hiddata->Size, value);
@ -1451,7 +1454,7 @@ static long hu_find_valinfo(info_lkp_t *hid2info, const char* value)
}
/* find the NUT value matching that HID Item value */
static char *hu_find_infoval(info_lkp_t *hid2info, const double value)
static const char *hu_find_infoval(info_lkp_t *hid2info, const double value)
{
info_lkp_t *info_lkp;
@ -1475,7 +1478,7 @@ static char *hu_find_infoval(info_lkp_t *hid2info, const double value)
/* return -1 on failure, 0 for a status update and 1 in all other cases */
static int ups_infoval_set(hid_info_t *item, double value)
{
char *nutvalue;
const char *nutvalue;
/* need lookup'ed translation? */
if (item->hid2info != NULL){

View file

@ -59,9 +59,9 @@ extern bool_t use_interrupt_pipe; /* Set to FALSE if interrupt reports should
/* --------------------------------------------------------------- */
typedef struct {
long hid_value; /* HID value */
char *nut_value; /* NUT value */
char *(*fun)(double hid_value); /* optional HID to NUT mapping */
const long hid_value; /* HID value */
const char *nut_value; /* NUT value */
const char *(*fun)(double hid_value); /* optional HID to NUT mapping */
double (*nuf)(const char *nut_value); /* optional NUT to HID mapping */
} info_lkp_t;
@ -115,13 +115,13 @@ extern info_lkp_t kelvin_celsius_conversion[];
/* --------------------------------------------------------------- */
typedef struct {
char *info_type; /* NUT variable name */
const char *info_type; /* NUT variable name */
int info_flags; /* NUT flags (to set in addinfo) */
int info_len; /* if ST_FLAG_STRING: length of the string */
/* if HU_TYPE_CMD: command value */
char *hidpath; /* Full HID Object path (or NULL for server side vars) */
const char *hidpath; /* Full HID Object path (or NULL for server side vars) */
HIDData_t *hiddata; /* Full HID Object data (for caching purpose, filled at runtime) */
char *dfl; /* if HU_FLAG_ABSENT: default value ; format otherwise */
const char *dfl; /* if HU_FLAG_ABSENT: default value ; format otherwise */
unsigned long hidflags; /* driver's own flags */
info_lkp_t *hid2info; /* lookup table between HID and NUT values */
/* if HU_FLAG_ENUM is set, hid2info is also used
@ -158,17 +158,16 @@ typedef struct {
* particular manufacturer (e.g. MGE, APC, Belkin), or a particular
* range of models. */
struct subdriver_s {
char *name; /* name of this subdriver */
typedef struct {
const char *name; /* name of this subdriver */
int (*claim)(HIDDevice_t *hd); /* return 1 if device covered by
* this subdriver */
usage_tables_t *utab; /* points to array of usage tables */
hid_info_t *hid2nut; /* main table of vars and instcmds */
char *(*format_model)(HIDDevice_t *hd); /* driver-specific methods */
char *(*format_mfr)(HIDDevice_t *hd); /* for preparing human- */
char *(*format_serial)(HIDDevice_t *hd); /* readable information */
};
typedef struct subdriver_s subdriver_t;
const char *(*format_model)(HIDDevice_t *hd); /* driver-specific methods */
const char *(*format_mfr)(HIDDevice_t *hd); /* for preparing human- */
const char *(*format_serial)(HIDDevice_t *hd); /* readable information */
} subdriver_t;
/* the following functions are exported for the benefit of subdrivers */
int instcmd(const char *cmdname, const char *extradata);