Imported Upstream version 2.7.1
This commit is contained in:
parent
a1fa151fc7
commit
0121794af9
451 changed files with 41339 additions and 10887 deletions
|
@ -33,18 +33,20 @@ if WITH_IPMI
|
|||
AM_CFLAGS += $(LIBIPMI_CFLAGS)
|
||||
endif
|
||||
|
||||
SERIAL_DRIVERLIST = bcmxcp belkin belkinunv bestfcom \
|
||||
SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \
|
||||
bestfortress bestuferrups bestups dummy-ups etapro everups \
|
||||
gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \
|
||||
oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \
|
||||
safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
|
||||
blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old
|
||||
blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser \
|
||||
nutdrv_qx
|
||||
SNMP_DRIVERLIST = snmp-ups
|
||||
USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
|
||||
blazer_usb richcomm_usb
|
||||
blazer_usb richcomm_usb riello_usb nutdrv_qx
|
||||
USB_DRIVERLIST = $(USB_LIBUSB_DRIVERLIST)
|
||||
HAL_DRIVERLIST = hald-addon-usbhid-ups hald-addon-bcmxcp_usb \
|
||||
hald-addon-tripplite_usb hald-addon-blazer_usb
|
||||
hald-addon-tripplite_usb hald-addon-blazer_usb hald-addon-riello_usb \
|
||||
hald-addon-nutdrv_qx
|
||||
NEONXML_DRIVERLIST = netxml-ups
|
||||
MACOSX_DRIVERLIST = macosx-ups
|
||||
|
||||
|
@ -96,6 +98,7 @@ upsdrvctl_SOURCES = upsdrvctl.c
|
|||
upsdrvctl_LDADD = $(LDADD_COMMON)
|
||||
|
||||
# serial drivers: all of them use standard LDADD and CFLAGS
|
||||
al175_SOURCES = al175.c
|
||||
apcsmart_SOURCES = apcsmart.c apcsmart_tabs.c
|
||||
apcsmart_old_SOURCES = apcsmart-old.c
|
||||
bcmxcp_SOURCES = bcmxcp.c bcmxcp_ser.c
|
||||
|
@ -137,6 +140,8 @@ tripplitesu_SOURCES = tripplitesu.c
|
|||
upscode2_SOURCES = upscode2.c
|
||||
upscode2_LDADD = $(LDADD) -lm
|
||||
victronups_SOURCES = victronups.c
|
||||
riello_ser_SOURCES = riello.c riello_ser.c
|
||||
riello_ser_LDADD = $(LDADD) -lm
|
||||
|
||||
# non-serial drivers: these use custom LDADD and/or CFLAGS
|
||||
|
||||
|
@ -153,6 +158,11 @@ endif
|
|||
clone_SOURCES = clone.c
|
||||
clone_outlet_SOURCES = clone-outlet.c
|
||||
|
||||
# apcupsd client driver
|
||||
apcupsd_ups_SOURCES = apcupsd-ups.c
|
||||
apcupsd_ups_CFLAGS = $(AM_CFLAGS)
|
||||
apcupsd_ups_LDADD = $(LDADD_DRIVERS)
|
||||
|
||||
# sample skeleton driver
|
||||
|
||||
skel_SOURCES = skel.c
|
||||
|
@ -160,7 +170,8 @@ skel_LDADD = $(LDADD_DRIVERS)
|
|||
|
||||
# USB
|
||||
USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c explore-hid.c \
|
||||
liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c
|
||||
liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \
|
||||
openups-hid.c
|
||||
usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c \
|
||||
usb-common.c $(USBHID_UPS_SUBDRIVERS)
|
||||
usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
|
||||
|
@ -177,6 +188,9 @@ blazer_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
|
|||
richcomm_usb_SOURCES = richcomm_usb.c usb-common.c
|
||||
richcomm_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
|
||||
|
||||
riello_usb_SOURCES = riello.c riello_usb.c libusb.c usb-common.c
|
||||
riello_usb_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS) -lm
|
||||
|
||||
# HID-over-serial
|
||||
mge_shut_SOURCES = usbhid-ups.c libshut.c libhid.c hidparser.c mge-hid.c
|
||||
# per-target CFLAGS are necessary here
|
||||
|
@ -186,7 +200,7 @@ mge_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 \
|
||||
bestpower-mib.c cyberpower-mib.c
|
||||
bestpower-mib.c cyberpower-mib.c delta_ups-mib.c
|
||||
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
|
||||
|
||||
# HAL
|
||||
|
@ -203,6 +217,13 @@ 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
|
||||
|
||||
hald_addon_riello_usb_SOURCES = riello.c riello_usb.c libusb.c
|
||||
hald_addon_riello_usb_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS) -lm
|
||||
|
||||
hald_addon_nutdrv_qx_SOURCES = nutdrv_qx.c libusb.c $(NUTDRV_QX_SUBDRIVERS)
|
||||
hald_addon_nutdrv_qx_LDADD = $(LDADD_HAL_DRIVERS) $(LIBUSB_LIBS) $(LIBHAL_LIBS) -lm
|
||||
hald_addon_nutdrv_qx_CFLAGS = $(AM_CFLAGS) -DQX_USB
|
||||
|
||||
# NEON XML/HTTP
|
||||
netxml_ups_SOURCES = netxml-ups.c mge-xml.c
|
||||
netxml_ups_LDADD = $(LDADD_DRIVERS) $(LIBNEON_LIBS)
|
||||
|
@ -223,6 +244,24 @@ macosx_ups_LDADD = $(LDADD_DRIVERS)
|
|||
macosx_ups_LDFLAGS = $(LDFLAGS) -framework IOKit -framework CoreFoundation
|
||||
macosx_ups_SOURCES = macosx-ups.c
|
||||
|
||||
# nutdrv_qx USB/Serial
|
||||
nutdrv_qx_SOURCES = nutdrv_qx.c
|
||||
nutdrv_qx_LDADD = $(LDADD_DRIVERS) -lm
|
||||
nutdrv_qx_CFLAGS = $(AM_CFLAGS)
|
||||
if WITH_SERIAL
|
||||
nutdrv_qx_CFLAGS += -DQX_SERIAL
|
||||
nutdrv_qx_LDADD += $(SERLIBS) serial.o
|
||||
endif
|
||||
if WITH_USB
|
||||
nutdrv_qx_CFLAGS += -DQX_USB
|
||||
nutdrv_qx_SOURCES += libusb.c usb-common.c
|
||||
nutdrv_qx_LDADD += $(LIBUSB_LIBS)
|
||||
endif
|
||||
NUTDRV_QX_SUBDRIVERS = nutdrv_qx_blazer-common.c nutdrv_qx_mecer.c \
|
||||
nutdrv_qx_megatec.c nutdrv_qx_megatec-old.c nutdrv_qx_mustek.c \
|
||||
nutdrv_qx_voltronic.c nutdrv_qx_zinto.c
|
||||
nutdrv_qx_SOURCES += $(NUTDRV_QX_SUBDRIVERS)
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# List of header files. The purpose of this list is not dependency
|
||||
# tracking (which is automatic), but to ensure these files are
|
||||
|
@ -237,7 +276,10 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \
|
|||
powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \
|
||||
safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \
|
||||
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h \
|
||||
apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h
|
||||
apcsmart.h apcsmart_tabs.h apcsmart-old.h apcupsd-ups.h cyberpower-mib.h riello.h openups-hid.h \
|
||||
delta_ups-mib.h nutdrv_qx.h nutdrv_qx_blazer-common.h nutdrv_qx_mecer.h \
|
||||
nutdrv_qx_megatec.h nutdrv_qx_megatec-old.h nutdrv_qx_mustek.h nutdrv_qx_voltronic.h \
|
||||
nutdrv_qx_zinto.h
|
||||
|
||||
# Define a dummy library so that Automake builds rules for the
|
||||
# corresponding object files. This library is not actually built,
|
||||
|
|
File diff suppressed because it is too large
Load diff
1292
drivers/al175.c
Normal file
1292
drivers/al175.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -36,8 +36,19 @@
|
|||
/* APC */
|
||||
#define APC_VENDORID 0x051d
|
||||
|
||||
/* Tweaks */
|
||||
char * tweak_max_report[] = {
|
||||
/* Back-UPS ES 700 does NOT overflow. */
|
||||
/* Back-UPS ES 725 does NOT overflow. */
|
||||
/* Back-UPS ES 525 overflows on ReportID 0x0c
|
||||
(UPS.PowerSummary.RemainingCapacity).*/
|
||||
"Back-UPS ES 525",
|
||||
/* Back-UPS CS 650 overflows on ReportID 0x46 */
|
||||
"Back-UPS CS",
|
||||
NULL};
|
||||
|
||||
/* Don't use interrupt pipe on 5G models (used by proprietary protocol) */
|
||||
static void *disable_interrupt_pipe(void)
|
||||
static void *disable_interrupt_pipe(USBDevice_t *device)
|
||||
{
|
||||
if (use_interrupt_pipe == TRUE) {
|
||||
upslogx(LOG_INFO, "interrupt pipe disabled (add 'pollonly' flag to 'ups.conf' to get rid of this message)");
|
||||
|
@ -46,10 +57,30 @@ static void *disable_interrupt_pipe(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Some models need special tweaks */
|
||||
static void *general_apc_check(USBDevice_t *device)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* Some models of Back-UPS overflow on some ReportID.
|
||||
* This results in some data not being exposed and IO errors on
|
||||
* WIN32, causing endless reconnection or driver's failure */
|
||||
|
||||
while( tweak_max_report[i] != NULL ) {
|
||||
if(!strncmp(device->Product, tweak_max_report[i],
|
||||
strlen(tweak_max_report[i]))) {
|
||||
max_report_size = 1;
|
||||
return NULL;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* USB IDs device table */
|
||||
static usb_device_id_t apc_usb_device_table[] = {
|
||||
/* various models */
|
||||
{ USB_DEVICE(APC_VENDORID, 0x0002), NULL },
|
||||
{ USB_DEVICE(APC_VENDORID, 0x0002), general_apc_check },
|
||||
/* various 5G models */
|
||||
{ USB_DEVICE(APC_VENDORID, 0x0003), disable_interrupt_pipe },
|
||||
|
||||
|
@ -437,8 +468,7 @@ static const char *apc_format_serial(HIDDevice_t *hd) {
|
|||
* the device is supported by this subdriver, else 0. */
|
||||
static int apc_claim(HIDDevice_t *hd) {
|
||||
|
||||
int status = is_usb_device_supported(apc_usb_device_table, hd->VendorID,
|
||||
hd->ProductID);
|
||||
int status = is_usb_device_supported(apc_usb_device_table, hd);
|
||||
|
||||
switch (status) {
|
||||
|
||||
|
|
|
@ -31,4 +31,6 @@
|
|||
|
||||
extern subdriver_t apc_subdriver;
|
||||
|
||||
extern int max_report_size;
|
||||
|
||||
#endif /* APC_HID_H */
|
||||
|
|
1431
drivers/apcsmart.c
1431
drivers/apcsmart.c
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
|
||||
* (C) 2000 Nigel Metheringham <Nigel.Metheringham@Intechnology.co.uk>
|
||||
* (C) 2011 Michal Soltys <soltys@ziu.info>
|
||||
* (C) 2011+ Michal Soltys <soltys@ziu.info>
|
||||
*
|
||||
* 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
|
||||
|
@ -24,7 +24,7 @@
|
|||
#define __apcsmart_h__
|
||||
|
||||
#define DRIVER_NAME "APC Smart protocol driver"
|
||||
#define DRIVER_VERSION "3.04"
|
||||
#define DRIVER_VERSION "3.1"
|
||||
|
||||
#define ALT_CABLE_1 "940-0095B"
|
||||
|
||||
|
@ -59,11 +59,22 @@
|
|||
* as it's handled by IGNCR at read() level
|
||||
*/
|
||||
|
||||
/*
|
||||
* about CR:
|
||||
* apparently windows is unable to ignore CRs by means of IGNCR flag (or
|
||||
* perhaps there is something else involved); so despite IGNCR we re-aad \015
|
||||
* to ignore sets for now; see:
|
||||
* http://article.gmane.org/gmane.comp.monitoring.nut.user/7762
|
||||
*
|
||||
* furthermore, since the canonical/non-canonical mode is user selectable now,
|
||||
* we have to ignore this character explicitly
|
||||
*/
|
||||
|
||||
/* Basic UPS reply line structure */
|
||||
#define ENDCHAR 10 /* APC ends responses with LF (and CR, but it's IGNCRed) */
|
||||
|
||||
/* what to ignore during alert aware serial reads */
|
||||
#define IGN_AACHARS "|&"
|
||||
#define IGN_AACHARS "\015|&"
|
||||
|
||||
/* what alert_handler() should care about */
|
||||
#define ALERT_CHARS "$!%+#?="
|
||||
|
@ -72,15 +83,15 @@
|
|||
#define IGN_CHARS IGN_AACHARS ALERT_CHARS
|
||||
|
||||
/*
|
||||
* these ones are used only during capability read, due to ^Z sending certain
|
||||
* characters such as #; it seems it could be equal to just IGN_CHARS w/o #
|
||||
* old: #define IGN_CCCHARS "|$!+"
|
||||
* these ones are used only during Capability Check read, due to ^Z sending
|
||||
* certain characters such as #; it seems it could be equal to just IGN_CHARS
|
||||
* w/o # old: #define IGN_CCCHARS "|$!+"
|
||||
*/
|
||||
#define IGN_CCCHARS "|&$!%+?=" /* capability check ignore set */
|
||||
#define IGN_CCCHARS "\015|&$!%+?=" /* capability check ignore set */
|
||||
|
||||
/*
|
||||
* command set 'a' command reports everything - protocol number, alerts and
|
||||
* supported commands
|
||||
* Command Set 'a' reports everything - protocol number, alerts and supported
|
||||
* commands
|
||||
*/
|
||||
#define IGN_CSCHARS "" /* command set ignore set */
|
||||
|
||||
|
@ -95,9 +106,9 @@
|
|||
#define SER_DX 0x002 /* 200 ms for long/repeated cmds, in case of unexpected NAs */
|
||||
#define SER_D1 0x004 /* 1.5 sec. */
|
||||
#define SER_D3 0x008 /* 3 sec. (default) */
|
||||
#define SER_AA 0x010 /* alert aware set */
|
||||
#define SER_CC 0x020 /* capability check ign set */
|
||||
#define SER_CS 0x040 /* command set ign set */
|
||||
#define SER_AA 0x010 /* Alert Aware set */
|
||||
#define SER_CC 0x020 /* Capability Check ign set */
|
||||
#define SER_CS 0x040 /* Command Set ign set */
|
||||
#define SER_TO 0x080 /* timeout allowed */
|
||||
#define SER_HA 0x100 /* handle asterisk */
|
||||
|
||||
|
@ -132,6 +143,7 @@
|
|||
#define APC_GOSMART 'Y'
|
||||
#define APC_GODUMB 'R'
|
||||
#define APC_CMDSET 'a'
|
||||
#define APC_CMDSET_FMT "^[0-9]\\.[^.]*\\.[^.]+$"
|
||||
#define APC_CAPS '\032' /* ^Z */
|
||||
#define APC_NEXTVAL '-'
|
||||
#define APC_FW_OLD 'V'
|
||||
|
@ -141,11 +153,20 @@
|
|||
#define APC_SBUF 32
|
||||
|
||||
/* default a.w.d. value / regex format for command '@' */
|
||||
#define APC_AWDDEF "000"
|
||||
#define APC_AWDFMT "^[0-9]{1,3}$"
|
||||
|
||||
/* maximum number of supported sdtype methods + regex format*/
|
||||
#define APC_SDMAX "5"
|
||||
/* sdtype method regex format*/
|
||||
#define APC_SDFMT "^[0-5]$"
|
||||
|
||||
/* advorder method regex format*/
|
||||
#define APC_ADVFMT "^([0-4]{1,5}|[Nn][Oo])$"
|
||||
|
||||
/* error logging/debug related macros */
|
||||
|
||||
#define fatx(fmt, ...) fatalx(EXIT_FAILURE, "%s: " fmt, __func__ , ## __VA_ARGS__)
|
||||
#define fate(fmt, ...) fatal_with_errno(EXIT_FAILURE, "%s: " fmt, __func__ , ## __VA_ARGS__)
|
||||
|
||||
#define logx(lev, fmt, ...) upslogx(lev, "%s: " fmt, __func__ , ## __VA_ARGS__)
|
||||
#define debx(lev, fmt, ...) upsdebugx(lev, "%s: " fmt, __func__ , ## __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
|
||||
* (C) 2000 Nigel Metheringham <Nigel.Metheringham@Intechnology.co.uk>
|
||||
* (C) 2011 Michal Soltys <soltys@ziu.info>
|
||||
* (C) 2011+ Michal Soltys <soltys@ziu.info>
|
||||
*
|
||||
* 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
|
||||
|
@ -32,10 +32,10 @@ apc_vartab_t apc_vartab[] = {
|
|||
{ "ups.delay.shutdown", 'p', APC_F_SECONDS },
|
||||
{ "ups.id", 'c', APC_STRING },
|
||||
{ "ups.contacts", 'i', APC_POLL|APC_F_HEX },
|
||||
{ "ups.display.language", '\014', 0 },
|
||||
{ "ups.display.language", '\014' },
|
||||
{ "input.voltage", 'L', APC_POLL|APC_F_VOLT },
|
||||
{ "input.frequency", 'F', APC_POLL|APC_F_DEC },
|
||||
{ "input.sensitivity", 's', 0 },
|
||||
{ "input.sensitivity", 's', },
|
||||
{ "input.quality", '9', APC_POLL|APC_F_HEX },
|
||||
{ "input.transfer.low", 'l', APC_F_VOLT },
|
||||
{ "input.transfer.high", 'u', APC_F_VOLT },
|
||||
|
@ -46,29 +46,32 @@ apc_vartab_t apc_vartab[] = {
|
|||
{ "output.voltage", 'O', APC_POLL|APC_F_VOLT },
|
||||
{ "output.voltage.nominal", 'o', APC_F_VOLT },
|
||||
{ "ambient.humidity", 'h', APC_POLL|APC_F_PERCENT },
|
||||
{ "ambient.humidity.high", '{', APC_F_PERCENT },
|
||||
{ "ambient.humidity.low", '}', APC_F_PERCENT },
|
||||
{ "ambient.0.humidity", 'H', APC_POLL|APC_PACK|APC_F_PERCENT },
|
||||
{ "ambient.0.humidity.high", '{', APC_POLL|APC_PACK|APC_F_PERCENT },
|
||||
{ "ambient.0.humidity.low", '}', APC_POLL|APC_PACK|APC_F_PERCENT },
|
||||
{ "ambient.temperature", 't', APC_POLL|APC_F_CELSIUS },
|
||||
{ "ambient.temperature.high", '[', APC_F_CELSIUS },
|
||||
{ "ambient.temperature.low", ']', APC_F_CELSIUS },
|
||||
{ "ambient.0.temperature", 'T', APC_MULTI|APC_POLL|APC_PACK|APC_F_CELSIUS, "^[0-9]{2}\\.[0-9]{2}$" },
|
||||
{ "ambient.0.temperature.high", '[', APC_POLL|APC_PACK|APC_F_CELSIUS },
|
||||
{ "ambient.0.temperature.low", ']', APC_POLL|APC_PACK|APC_F_CELSIUS },
|
||||
{ "battery.date", 'x', APC_STRING },
|
||||
{ "battery.charge", 'f', APC_POLL|APC_F_PERCENT },
|
||||
{ "battery.charge.restart", 'e', APC_F_PERCENT },
|
||||
{ "battery.voltage", 'B', APC_POLL|APC_F_VOLT },
|
||||
{ "battery.voltage.nominal", 'g', 0 },
|
||||
{ "battery.voltage.nominal", 'g', },
|
||||
{ "battery.runtime", 'j', APC_POLL|APC_F_MINUTES },
|
||||
{ "battery.runtime.low", 'q', APC_F_MINUTES },
|
||||
{ "battery.packs", '>', APC_F_DEC },
|
||||
{ "battery.packs.bad", '<', APC_F_DEC },
|
||||
{ "battery.alarm.threshold", 'k', 0 },
|
||||
{ "ups.serial", 'n', 0 },
|
||||
{ "ups.mfr.date", 'm', 0 },
|
||||
{ "ups.model", '\001', 0 },
|
||||
{ "ups.firmware.aux", 'v', 0 },
|
||||
{ "ups.firmware", 'b', APC_MULTI },
|
||||
{ "battery.alarm.threshold", 'k', },
|
||||
{ "device.uptime", 'T', APC_MULTI|APC_POLL|APC_F_HOURS, "^[0-9]{3}\\.[0-9]{1}$" },
|
||||
{ "ups.serial", 'n', },
|
||||
{ "ups.mfr.date", 'm', },
|
||||
{ "ups.model", '\001' },
|
||||
{ "ups.firmware.aux", 'v', },
|
||||
{ "ups.firmware", 'b', APC_MULTI, "^[[:alnum:]]+\\.[[:alnum:]]+\\.[[:alnum:]]+$" },
|
||||
{ "ups.firmware", 'V', APC_MULTI },
|
||||
|
||||
{ 0, 0, 0 }
|
||||
{ NULL }
|
||||
/* todo:
|
||||
|
||||
I = alarm enable (hex field) - split into alarm.n.enable
|
||||
|
@ -81,27 +84,29 @@ apc_vartab_t apc_vartab[] = {
|
|||
};
|
||||
|
||||
/*
|
||||
* apc commands mapped to nut's instant commands extra values are either
|
||||
* exactly 2-char prefix, or longer than 2-char extended regex
|
||||
* APC commands mapped to NUT's instant commands
|
||||
* the format of extra values is matched by extended posix regex
|
||||
* APC_CMD_CUSTOM means that the instant command is handled by separate
|
||||
* function, thus the actual APC cmd in the table is ignored
|
||||
*/
|
||||
apc_cmdtab_t apc_cmdtab[] = {
|
||||
{ "shutdown.return", "^[Aa][Tt]:[0-9]{1,3}$",
|
||||
APC_CMD_GRACEDOWN, APC_NASTY },
|
||||
{ "shutdown.return", "^([Cc][Ss]|)$",
|
||||
APC_CMD_SOFTDOWN, APC_NASTY },
|
||||
{ "shutdown.stayoff", 0, APC_CMD_SHUTDOWN, APC_NASTY|APC_REPEAT },
|
||||
{ "load.off", 0, APC_CMD_OFF, APC_NASTY|APC_REPEAT },
|
||||
{ "load.on", 0, APC_CMD_ON, APC_REPEAT },
|
||||
{ "calibrate.start", 0, APC_CMD_CALTOGGLE, 0 },
|
||||
{ "calibrate.stop", 0, APC_CMD_CALTOGGLE, 0 },
|
||||
{ "test.panel.start", 0, APC_CMD_FPTEST, 0 },
|
||||
{ "test.failure.start", 0, APC_CMD_SIMPWF, 0 },
|
||||
{ "test.battery.start", 0, APC_CMD_BTESTTOGGLE, 0 },
|
||||
{ "test.battery.stop", 0, APC_CMD_BTESTTOGGLE, 0 },
|
||||
{ "shutdown.return", "^at:[0-9]{1,3}$",
|
||||
APC_CMD_GRACEDOWN, APC_NASTY },
|
||||
{ "shutdown.return", "cs", APC_CMD_SOFTDOWN, APC_NASTY },
|
||||
{ "shutdown.return", 0, APC_CMD_SOFTDOWN, APC_NASTY },
|
||||
{ "shutdown.stayoff", 0, APC_CMD_SHUTDOWN, APC_NASTY|APC_REPEAT },
|
||||
{ "load.off", 0, APC_CMD_OFF, APC_NASTY|APC_REPEAT },
|
||||
{ "load.on", 0, APC_CMD_ON, APC_REPEAT },
|
||||
{ "bypass.start", 0, APC_CMD_BYPTOGGLE, 0 },
|
||||
{ "bypass.stop", 0, APC_CMD_BYPTOGGLE, 0 },
|
||||
{ "calibrate.start", 0, APC_CMD_CALTOGGLE, 0 },
|
||||
{ "calibrate.stop", 0, APC_CMD_CALTOGGLE, 0 },
|
||||
|
||||
{ 0, 0, 0, 0 }
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* compatibility with hardware that doesn't do APC_CMDSET ('a') */
|
||||
|
@ -122,11 +127,16 @@ apc_compattab_t apc_compattab[] = {
|
|||
{ "7QI", "@79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
|
||||
{ "7TD", "@79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
|
||||
{ "7TI", "@79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
|
||||
/* SmartUPS 600I */
|
||||
{ "6JI", "@789ABCFGKLMNOPQSTUVWXYZfg", 0 },
|
||||
/* SmartUPS 900I */
|
||||
{ "7II", "@79ABCEFGKLMNOPQSUVWXYZcfg", 0 },
|
||||
{ "7II", "@79ABCEFGKLMNOPQRSUVWXYZcfg", 0 },
|
||||
/* SmartUPS 2000I */
|
||||
{ "9II", "@79ABCEFGKLMNOPQSUVWXYZcfg", 0 },
|
||||
{ "9GI", "@79ABCEFGKLMNOPQSUVWXYZcfg", 0 },
|
||||
{ "9II", "@79ABCEFGKLMNOPQRSUVWXYZcfg", 0 },
|
||||
{ "9GI", "@79ABCEFGKLMNOPQRSUVWXYZcfg", 0 },
|
||||
/* SmartUPS 1250I */
|
||||
{ "8II", "@79ABCEFGKLMNOPQRSUVWXYZcfg", 0 },
|
||||
{ "8GI", "@79ABCEFGKLMNOPQRSUVWXYZfg", 0 },
|
||||
/* SmartUPS 1250 */
|
||||
{ "8QD", "@79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
|
||||
{ "8QI", "@79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
|
||||
|
@ -134,22 +144,18 @@ apc_compattab_t apc_compattab[] = {
|
|||
{ "8TI", "@79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
|
||||
/* CS 350 */
|
||||
{ "5.4.D", "@\1ABPQRSUYbdfgjmnx9", 0 },
|
||||
/* Smart-UPS 600 */
|
||||
{ "D9", "@789ABCEFGKLMNOPQRSUVWXYZ", 0 },
|
||||
{ "D8", "@789ABCEFGKLMNOPQRSUVWXYZ", 0 },
|
||||
{ "D7", "@789ABCEFGKLMNOPQRSUVWXYZ", 0 },
|
||||
{ "D6", "@789ABCEFGKLMNOPQRSUVWXYZ", 0 },
|
||||
{ "D5", "@789ABCEFGKLMNOPQRSUVWXYZ", 0 },
|
||||
{ "D4", "@789ABCEFGKLMNOPQRSUVWXYZ", 0 },
|
||||
/*
|
||||
* certain set of UPSes returning voltage > 255V through 'b'; "set\1"
|
||||
* is matched explicitly (fake key); among the UPS models - some old
|
||||
* APC 600 ones
|
||||
*/
|
||||
{ "set\1", "@789ABCFGKLMNOPQRSUVWXYZ", 0 },
|
||||
|
||||
{ 0, 0, 0 }
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
upsdrv_info_t apc_tab_info = {
|
||||
"APC command table",
|
||||
APC_TABLE_VERSION,
|
||||
0,
|
||||
0,
|
||||
{ 0 }
|
||||
APC_TABLE_VERSION
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 1999 Russell Kroll <rkroll@exploits.org>
|
||||
* (C) 2000 Nigel Metheringham <Nigel.Metheringham@Intechnology.co.uk>
|
||||
* (C) 2011 Michal Soltys <soltys@ziu.info>
|
||||
* (C) 2011+ Michal Soltys <soltys@ziu.info>
|
||||
*
|
||||
* 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
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
#define APC_TABLE_VERSION "version 3.0"
|
||||
#define APC_TABLE_VERSION "version 3.1"
|
||||
|
||||
/* common flags */
|
||||
|
||||
|
@ -43,11 +43,14 @@
|
|||
#define APC_ENUM 0x00000400 /* enumerated type variable */
|
||||
#define APC_STRING 0x00000800 /* string variable */
|
||||
#define APC_MULTI 0x00001000 /* there're other vars like that */
|
||||
#define APC_DEPR 0x00002000 /* deprecated variable */
|
||||
#define APC_PACK 0x00002000 /* packed variable */
|
||||
|
||||
#define APC_PACK_MAX 4 /* max count of subfields in packed var */
|
||||
|
||||
/* variables' format */
|
||||
|
||||
#define APC_F_MASK 0xFF000000 /* Mask for apc data formats */
|
||||
#define APC_F_LEAVE 0x00000000 /* Just pass this through */
|
||||
#define APC_F_PERCENT 0x01000000 /* Data in a percent format */
|
||||
#define APC_F_VOLT 0x02000000 /* Data in a voltage format */
|
||||
#define APC_F_AMP 0x03000000 /* Data in a current/amp format */
|
||||
|
@ -57,13 +60,13 @@
|
|||
#define APC_F_SECONDS 0x07000000 /* Time in seconds */
|
||||
#define APC_F_MINUTES 0x08000000 /* Time in minutes */
|
||||
#define APC_F_HOURS 0x09000000 /* Time in hours */
|
||||
#define APC_F_REASON 0x10000000 /* Reason of transfer */
|
||||
#define APC_F_LEAVE 0x00000000 /* Just pass this through */
|
||||
#define APC_F_REASON 0x0A000000 /* Reason of transfer */
|
||||
|
||||
/* instant commands */
|
||||
|
||||
#define APC_CMD_CUSTOM 0 /* command uses separate function */
|
||||
#define APC_CMD_OFF 'Z'
|
||||
#define APC_CMD_ON '\016' /* ^N */
|
||||
#define APC_CMD_ON '\016' /* ^N */
|
||||
#define APC_CMD_FPTEST 'A'
|
||||
#define APC_CMD_SIMPWF 'U'
|
||||
#define APC_CMD_BTESTTOGGLE 'W'
|
||||
|
@ -78,6 +81,9 @@ typedef struct {
|
|||
const char *name; /* the variable name */
|
||||
char cmd; /* variable character */
|
||||
unsigned int flags; /* various flags */
|
||||
const char *regex; /* variable must match this regex */
|
||||
size_t nlen0; /* var name + null len */
|
||||
int cnt; /* curr. count of subs */
|
||||
} apc_vartab_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
290
drivers/apcupsd-ups.c
Normal file
290
drivers/apcupsd-ups.c
Normal file
|
@ -0,0 +1,290 @@
|
|||
/* apcupsd-ups.c - client for apcupsd
|
||||
|
||||
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 <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "apcupsd-ups.h"
|
||||
|
||||
#define DRIVER_NAME "apcupsd network client UPS driver"
|
||||
#define DRIVER_VERSION "0.04"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
DRIVER_NAME,
|
||||
DRIVER_VERSION,
|
||||
"Andreas Steinmetz <ast@domdv.de>",
|
||||
DRV_STABLE,
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static int port=3551;
|
||||
static struct sockaddr_in host;
|
||||
|
||||
static void process(char *item,char *data)
|
||||
{
|
||||
int i;
|
||||
char *p1;
|
||||
char *p2;
|
||||
|
||||
for(i=0;nut_data[i].info_type;i++)if(!(nut_data[i].apcupsd_item))
|
||||
dstate_setinfo(nut_data[i].info_type,"%s",
|
||||
nut_data[i].default_value);
|
||||
else if(!strcmp(nut_data[i].apcupsd_item,item))
|
||||
switch(nut_data[i].drv_flags&~DU_FLAG_INIT)
|
||||
{
|
||||
case DU_FLAG_STATUS:
|
||||
status_init();
|
||||
if(!strcmp(data,"COMMLOST")||!strcmp(data,"SHUTTING DOWN")||
|
||||
!strcmp(data,"NETWORK ERROR")||!strcmp(data,"ERROR"))
|
||||
status_set("OFF");
|
||||
else if(!strcmp(data,"SELFTEST"))status_set("OB");
|
||||
else for(;(data=strtok(data," "));data=NULL)
|
||||
{
|
||||
if(!strcmp(data,"CAL"))status_set("CAL");
|
||||
else if(!strcmp(data,"TRIM"))status_set("TRIM");
|
||||
else if(!strcmp(data,"BOOST"))status_set("BOOST");
|
||||
else if(!strcmp(data,"ONLINE"))status_set("OL");
|
||||
else if(!strcmp(data,"ONBATT"))status_set("OB");
|
||||
else if(!strcmp(data,"OVERLOAD"))status_set("OVER");
|
||||
else if(!strcmp(data,"LOWBATT"))status_set("LB");
|
||||
else if(!strcmp(data,"REPLACEBATT"))status_set("RB");
|
||||
else if(!strcmp(data,"NOBATT"))status_set("BYPASS");
|
||||
}
|
||||
status_commit();
|
||||
break;
|
||||
|
||||
case DU_FLAG_DATE:
|
||||
if((p1=strchr(data,' ')))
|
||||
{
|
||||
*p1=0;
|
||||
dstate_setinfo(nut_data[i].info_type,"%s",data);
|
||||
*p1=' ';
|
||||
}
|
||||
else dstate_setinfo(nut_data[i].info_type,"%s",data);
|
||||
break;
|
||||
|
||||
case DU_FLAG_TIME:
|
||||
if((p1=strchr(data,' ')))
|
||||
{
|
||||
*p1=0;
|
||||
if((p2=strchr(p1+1,' ')))
|
||||
{
|
||||
*p2=0;
|
||||
dstate_setinfo(nut_data[i].info_type,"%s",p1+1);
|
||||
*p2=' ';
|
||||
}
|
||||
else dstate_setinfo(nut_data[i].info_type,"%s",p1+1);
|
||||
*p1=' ';
|
||||
}
|
||||
break;
|
||||
|
||||
case DU_FLAG_FW1:
|
||||
if((p1=strchr(data,'/')))
|
||||
{
|
||||
for(;p1!=data;p1--)if(p1[-1]!=' ')break;
|
||||
if(*p1==' ')
|
||||
{
|
||||
*p1=0;
|
||||
dstate_setinfo(nut_data[i].info_type,"%s",data);
|
||||
*p1=' ';
|
||||
}
|
||||
else dstate_setinfo(nut_data[i].info_type,"%s",data);
|
||||
}
|
||||
else dstate_setinfo(nut_data[i].info_type,"%s",data);
|
||||
break;
|
||||
|
||||
case DU_FLAG_FW2:
|
||||
if((p1=strchr(data,'/')))
|
||||
{
|
||||
for(;*p1;p1++)if(p1[1]!=' ')break;
|
||||
if(*p1&&p1[1])dstate_setinfo(nut_data[i].info_type,"%s",
|
||||
p1+1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:if(nut_data[i].info_flags&ST_FLAG_STRING)
|
||||
{
|
||||
if((int)strlen(data)>(int)nut_data[i].info_len)
|
||||
data[(int)nut_data[i].info_len]=0;
|
||||
dstate_setinfo(nut_data[i].info_type,"%s",data);
|
||||
}
|
||||
else dstate_setinfo(nut_data[i].info_type,
|
||||
nut_data[i].default_value,
|
||||
atof(data)*nut_data[i].info_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int getdata(void)
|
||||
{
|
||||
int x, fd_flags;
|
||||
short n;
|
||||
char *item;
|
||||
char *data;
|
||||
struct pollfd p;
|
||||
char bfr[1024];
|
||||
|
||||
for(x=0;nut_data[x].info_type;x++)
|
||||
if(!(nut_data[x].drv_flags&DU_FLAG_INIT))
|
||||
dstate_delinfo(nut_data[x].info_type);
|
||||
|
||||
if((p.fd=socket(AF_INET,SOCK_STREAM,0))==-1)
|
||||
{
|
||||
upsdebugx(1,"socket error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(connect(p.fd,(struct sockaddr *)&host,sizeof(host)))
|
||||
{
|
||||
upsdebugx(1,"can't connect to apcupsd");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd_flags = fcntl(p.fd, F_GETFL);
|
||||
fd_flags |= O_NONBLOCK;
|
||||
if(fcntl(p.fd, F_SETFL, fd_flags))
|
||||
{
|
||||
upsdebugx(1,"unexpected fcntl(fd, F_SETFL, fd_flags|O_NONBLOCK) failure");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
p.events=POLLIN;
|
||||
|
||||
n=htons(6);
|
||||
x=write(p.fd,&n,2);
|
||||
x=write(p.fd,"status",6);
|
||||
|
||||
/* TODO: double-check for poll() in configure script */
|
||||
while(poll(&p,1,15000)==1)
|
||||
{
|
||||
if(read(p.fd,&n,2)!=2)
|
||||
{
|
||||
upsdebugx(1,"apcupsd communication error");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(x=ntohs(n)))
|
||||
{
|
||||
close(p.fd);
|
||||
return 0;
|
||||
}
|
||||
else if(x<0||x>=(int)sizeof(bfr))
|
||||
{
|
||||
upsdebugx(1,"apcupsd communication error");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(poll(&p,1,15000)!=1)break;
|
||||
|
||||
if(read(p.fd,bfr,x)!=x)
|
||||
{
|
||||
upsdebugx(1,"apcupsd communication error");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bfr[x]=0;
|
||||
|
||||
if(!(item=strtok(bfr," \t:\r\n")))
|
||||
{
|
||||
upsdebugx(1,"apcupsd communication error");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(data=strtok(NULL,"\r\n")))
|
||||
{
|
||||
upsdebugx(1,"apcupsd communication error");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
while(*data==' '||*data=='\t'||*data==':')data++;
|
||||
|
||||
process(item,data);
|
||||
}
|
||||
|
||||
upsdebugx(1,"unexpected connection close by apcupsd");
|
||||
close(p.fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void upsdrv_initinfo(void)
|
||||
{
|
||||
if(!port)fatalx(EXIT_FAILURE,"invalid host or port specified!");
|
||||
if(getdata())fatalx(EXIT_FAILURE,"can't communicate with apcupsd!");
|
||||
else dstate_dataok();
|
||||
poll_interval=60;
|
||||
}
|
||||
|
||||
void upsdrv_updateinfo(void)
|
||||
{
|
||||
if(getdata())upslogx(LOG_ERR,"can't communicate with apcupsd!");
|
||||
else dstate_dataok();
|
||||
poll_interval=60;
|
||||
}
|
||||
|
||||
void upsdrv_shutdown(void)
|
||||
{
|
||||
fatalx(EXIT_FAILURE, "shutdown not supported");
|
||||
}
|
||||
|
||||
void upsdrv_help(void)
|
||||
{
|
||||
}
|
||||
|
||||
void upsdrv_makevartable(void)
|
||||
{
|
||||
}
|
||||
|
||||
void upsdrv_initups(void)
|
||||
{
|
||||
char *p;
|
||||
struct hostent *h;
|
||||
|
||||
if(device_path&&*device_path)
|
||||
{
|
||||
/* TODO: fix parsing since bare IPv6 addresses contain colons */
|
||||
if((p=strchr(device_path,':')))
|
||||
{
|
||||
*p++=0;
|
||||
port=atoi(p);
|
||||
if(port<1||port>65535)port=0;
|
||||
}
|
||||
}
|
||||
else device_path="localhost";
|
||||
|
||||
if(!(h=gethostbyname(device_path)))port=0;
|
||||
else memcpy(&host.sin_addr,h->h_addr,4);
|
||||
|
||||
/* TODO: add IPv6 support */
|
||||
host.sin_family=AF_INET;
|
||||
host.sin_port=htons(port);
|
||||
}
|
||||
|
||||
void upsdrv_cleanup(void)
|
||||
{
|
||||
}
|
137
drivers/apcupsd-ups.h
Normal file
137
drivers/apcupsd-ups.h
Normal file
|
@ -0,0 +1,137 @@
|
|||
/* apcupsd-ups.h - NUT client driver to apcupsd
|
||||
|
||||
Copyright (C)
|
||||
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
|
||||
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
|
||||
*/
|
||||
|
||||
/* from usbhid-ups.h */
|
||||
/* --------------------------------------------------------------- */
|
||||
/* Struct & data for ups.status processing */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
const char *status_str; /* ups.status string */
|
||||
int status_value; /* ups.status value */
|
||||
} status_lkp_t;
|
||||
|
||||
#define STATUS_CAL 1 /* calibration */
|
||||
#define STATUS_TRIM 2 /* SmartTrim */
|
||||
#define STATUS_BOOST 4 /* SmartBoost */
|
||||
#define STATUS_OL 8 /* on line */
|
||||
#define STATUS_OB 16 /* on battery */
|
||||
#define STATUS_OVER 32 /* overload */
|
||||
#define STATUS_LB 64 /* low battery */
|
||||
#define STATUS_RB 128 /* replace battery */
|
||||
#define STATUS_BYPASS 256 /* on bypass */
|
||||
#define STATUS_OFF 512 /* ups is off */
|
||||
#define STATUS_CHRG 1024 /* charging */
|
||||
#define STATUS_DISCHRG 2048 /* discharging */
|
||||
|
||||
status_lkp_t status_info[] = {
|
||||
{ "CAL", STATUS_CAL },
|
||||
{ "TRIM", STATUS_TRIM },
|
||||
{ "BOOST", STATUS_BOOST },
|
||||
{ "OL", STATUS_OL },
|
||||
{ "OB", STATUS_OB },
|
||||
{ "OVER", STATUS_OVER },
|
||||
{ "LB", STATUS_LB },
|
||||
{ "RB", STATUS_RB },
|
||||
{ "BYPASS", STATUS_BYPASS },
|
||||
{ "OFF", STATUS_OFF },
|
||||
{ "CHRG", STATUS_CHRG },
|
||||
{ "DISCHRG", STATUS_DISCHRG },
|
||||
{ "NULL", 0 },
|
||||
};
|
||||
/* from usbhid-ups.h */
|
||||
|
||||
typedef struct {
|
||||
char hid_value; /* HID value */
|
||||
char *nut_value; /* NUT value */
|
||||
} info_enum_t;
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* Structure containing information about how to get/set data */
|
||||
/* from/to the UPS and convert these to/from NUT standard */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
const char *apcupsd_item;
|
||||
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 */
|
||||
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 */
|
||||
/* interpreter interpret; */ /* FFE: interpreter fct, NULL if not needed */
|
||||
} apcuspd_info_t;
|
||||
|
||||
/* data flags */
|
||||
#define DU_FLAG_NONE 0
|
||||
#define DU_FLAG_INIT 1 /* intialy show element to upsd */
|
||||
#define DU_FLAG_STATUS 2
|
||||
#define DU_FLAG_DATE 4
|
||||
#define DU_FLAG_TIME 8
|
||||
#define DU_FLAG_FW1 16
|
||||
#define DU_FLAG_FW2 32
|
||||
|
||||
/* ------------ */
|
||||
/* Data table */
|
||||
/* ------------ */
|
||||
|
||||
static apcuspd_info_t nut_data[] =
|
||||
{
|
||||
{ NULL, "ups.mfr", ST_FLAG_STRING | ST_FLAG_RW, 32, "APC", DU_FLAG_INIT, NULL },
|
||||
{ "MODEL", "ups.model", ST_FLAG_STRING | ST_FLAG_RW, 32, "Unknown UPS", DU_FLAG_INIT, NULL },
|
||||
{ "STATUS", "ups.status", ST_FLAG_STRING | ST_FLAG_RW, 32, "OFF", DU_FLAG_INIT|DU_FLAG_STATUS, NULL },
|
||||
{ "SERIALNO", "ups.serial", ST_FLAG_STRING | ST_FLAG_RW, 32, NULL, DU_FLAG_NONE, NULL },
|
||||
{ "LOADPCT", "ups.load", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "DATE", "ups.time", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_TIME, NULL },
|
||||
{ "DATE", "ups.date", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_DATE, NULL },
|
||||
{ "MANDATE", "ups.mfr.date", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL },
|
||||
{ "FIRMWARE", "ups.firmware", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_FW1, NULL },
|
||||
{ "FIRMWARE", "ups.firmware.aux", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_FW2, NULL },
|
||||
{ "ITEMP", "ups.temperature", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "UPSNAME", "ups.id", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL },
|
||||
{ "DWAKE", "ups.delay.start", ST_FLAG_RW, 1, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "DSHUTD", "ups.delay.shutdown", ST_FLAG_RW, 1, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "STESTI", "ups.test.interval", ST_FLAG_RW, 1, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "SELFTEST", "ups.test.result", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL },
|
||||
{ "LINEV", "input.voltage", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "MAXLINEV", "input.voltage.maximum", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "MINLINEV", "input.voltage.minimum", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "NOMINV", "input.voltage.nominal", 0, 1, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "NOMOUTV", "output.voltage.nominal", 0, 1, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "LASTXFER", "input.transfer.reason", ST_FLAG_STRING | ST_FLAG_RW, 32, NULL, DU_FLAG_NONE, NULL },
|
||||
{ "LOTRANS", "input.transfer.low", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "HITRANS", "input.transfer.high", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "SENSE", "input.sensitivity", ST_FLAG_STRING | ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
|
||||
{ "LINEFREQ", "input.frequency", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "OUTPUTV", "output.voltage", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "LINEFREQ", "output.frequency", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "BCHARGE", "battery.charge", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "MBATTCHG", "battery.charge.low", ST_FLAG_RW, 1, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "BATTDATE", "battery.date", ST_FLAG_STRING /* | ST_FLAG_RW */, 16, NULL, DU_FLAG_DATE, NULL },
|
||||
{ "BATTV", "battery.voltage", 0, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "NOMBATTV", "battery.voltage.nominal", 0, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "TIMELEFT", "battery.runtime", ST_FLAG_RW, 60, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "MINTIMEL", "battery.runtime.low", ST_FLAG_RW, 60, "%.0f", DU_FLAG_NONE, NULL },
|
||||
{ "RETPCT", "battery.charge.restart", ST_FLAG_RW, 1, "%1.1f", DU_FLAG_NONE, NULL },
|
||||
{ "NOMPOWER", "ups.realpower.nominal", 0, 1, "%1.1f", DU_FLAG_INIT, NULL },
|
||||
{ NULL, NULL, 0, 0, NULL, DU_FLAG_NONE, NULL }
|
||||
};
|
1139
drivers/bcmxcp.c
1139
drivers/bcmxcp.c
File diff suppressed because it is too large
Load diff
901
drivers/bcmxcp.h
901
drivers/bcmxcp.h
|
@ -8,394 +8,587 @@
|
|||
#include "timehead.h"
|
||||
|
||||
/* Have to wait at least 0,25 sec max 16 sec */
|
||||
/* 1 second is too short for PW9120 (leads to communication errors).
|
||||
So we set it to 2 seconds */
|
||||
/* 1 second is too short for PW9120 (leads to communication errors). So we set it to 2 seconds */
|
||||
#define PW_SLEEP 2
|
||||
|
||||
#define PW_MAX_TRY 3 /* How many times we try to send data. */
|
||||
|
||||
#define PW_COMMAND_START_BYTE (unsigned char)0xAB
|
||||
#define PW_LAST_SEQ (unsigned char)0x80 /* bit flag to indicate final sequence */
|
||||
#define PW_SEQ_MASK (unsigned char)0x7F /* bit mask to extract just the sequence # */
|
||||
#define PW_LAST_SEQ (unsigned char)0x80 /* bit flag to indicate final sequence */
|
||||
#define PW_SEQ_MASK (unsigned char)0x7F /* bit mask to extract just the sequence # */
|
||||
|
||||
#define PW_ANSWER_MAX_SIZE 256
|
||||
#define PW_ANSWER_MAX_SIZE 256
|
||||
|
||||
/* No Autorisation required */
|
||||
#define PW_ID_BLOCK_REQ (unsigned char)0x31 /* Model name, ... length 1 */
|
||||
#define PW_STATUS_REQ (unsigned char)0x33 /* On Line, On Bypass, ... length 1-2 */
|
||||
#define PW_METER_BLOCK_REQ (unsigned char)0x34 /* Current UPS status (Load, utility,...) length 1 */
|
||||
#define PW_CUR_ALARM_REQ (unsigned char)0x35 /* Current alarm and event request. length 1 */
|
||||
#define PW_CONFIG_BLOCK_REQ (unsigned char)0x36 /* Model serial#, ... length 1 */
|
||||
#define PW_BATTERY_REQ (unsigned char)0x3B /* Charging, floating, ... length 1 */
|
||||
#define PW_LIMIT_BLOCK_REQ (unsigned char)0x3C /* Configuration (Bypass thresholds,...). length 1 */
|
||||
#define PW_TEST_RESULT_REQ (unsigned char)0x3F /* ??. length 1 */
|
||||
#define PW_COMMAND_LIST_REQ (unsigned char)0x40 /* Available commands. length 1 */
|
||||
#define PW_OUT_MON_BLOCK_REQ (unsigned char)0x41 /* Outlet monitor request length 1 */
|
||||
#define PW_COM_CAP_REQ (unsigned char)0x42 /* Request communication capabilities. length 2 */
|
||||
#define PW_UPS_TOP_DATA_REQ (unsigned char)0x43 /* Requsest ups topology data requset. length 1 */
|
||||
/* No Autorisation required */
|
||||
#define PW_ID_BLOCK_REQ (unsigned char)0x31 /* Model name, ... length 1 */
|
||||
#define PW_EVENT_HISTORY_LOG_REQ (unsigned char)0x32 /* List alarms that have occured. length 1 */
|
||||
#define PW_STATUS_REQ (unsigned char)0x33 /* On Line, On Bypass, ... length 1-2 */
|
||||
#define PW_METER_BLOCK_REQ (unsigned char)0x34 /* Current UPS status (Load, utility,...) length 1 */
|
||||
#define PW_CUR_ALARM_REQ (unsigned char)0x35 /* Current alarm and event request. length 1 */
|
||||
#define PW_CONFIG_BLOCK_REQ (unsigned char)0x36 /* Model serial#, ... length 1 */
|
||||
#define PW_UTILITY_STATISTICS_BLOCK_REQ (unsigned char)0x38 /* List utility power quality. length 1 */
|
||||
#define PW_WAVEFORM_BLOCK_REQ (unsigned char)0x3A /* Sampled waveform data. length 7 */
|
||||
#define PW_BATTERY_REQ (unsigned char)0x3B /* Charging, floating, ... length 1 */
|
||||
#define PW_LIMIT_BLOCK_REQ (unsigned char)0x3C /* Configuration (Bypass thresholds,...). length 1 */
|
||||
#define PW_TEST_RESULT_REQ (unsigned char)0x3F /* Get the results for a system test. length 1 */
|
||||
#define PW_COMMAND_LIST_REQ (unsigned char)0x40 /* Available commands. length 1 */
|
||||
#define PW_OUT_MON_BLOCK_REQ (unsigned char)0x41 /* Outlet monitor request length 1 */
|
||||
#define PW_COM_CAP_REQ (unsigned char)0x42 /* Request communication capabilities. length 2 */
|
||||
#define PW_UPS_TOP_DATA_REQ (unsigned char)0x43 /* Request ups topology data requset. length 1 */
|
||||
#define PW_COM_PORT_LIST_BLOCK_REQ (unsigned char)0x44 /* Request communication port list. length 1 */
|
||||
#define PW_REQUEST_SCRATCHPAD_DATA_REQ (unsigned char)0x45 /* Request data from scratchpad. length 2*/
|
||||
|
||||
/* Need autorisation before this commands */
|
||||
#define PW_UPS_ON (unsigned char)0x89 /* UPS on command. length 1-2 */
|
||||
#define PW_LOAD_OFF_RESTART (unsigned char)0x8A /* Delayed LoadPowerOff & Restart command. length 2-4 */
|
||||
#define PW_UPS_OFF (unsigned char)0x8B /* UPS off command. length 1-2 */
|
||||
#define PW_UPS_ON_TIME (unsigned char)0x91 /* Scheduled UPS on in n minutes. length 3-4 */
|
||||
#define PW_UPS_OFF_TIME (unsigned char)0x93 /* Scheduled UPS off in n minutes. length 3-4 */
|
||||
#define PW_SET_CONF_COMMAND (unsigned char)0x95 /* Set configuration command. length 4 */
|
||||
#define PW_SET_OUTLET_COMMAND (unsigned char)0x97 /* Set outlet parameter command length 5. not in 5115 */
|
||||
#define PW_SET_COM_COMMAND (unsigned char)0x98 /* Set communication parameter command. length 5 */
|
||||
#define PW_SET_REQ_ONLY_MODE (unsigned char)0xA0 /* Set request only mode command. length 1 */
|
||||
#define PW_INIT_BAT_TEST (unsigned char)0xB1 /* Initiate battery test command. length 3 */
|
||||
#define PW_INIT_SYS_TEST (unsigned char)0xB2 /* Initiate general system test command. length 2 */
|
||||
/* Need autorisation before these commands */
|
||||
#define PW_GO_TO_BYPASS (unsigned char)0x88 /* Transfer load from inverter to bypass. length 1 or 3 */
|
||||
#define PW_UPS_ON (unsigned char)0x89 /* UPS on command. length 1-2 */
|
||||
#define PW_LOAD_OFF_RESTART (unsigned char)0x8A /* Delayed LoadPowerOff & Restart command. length 2-4 */
|
||||
#define PW_UPS_OFF (unsigned char)0x8B /* UPS off command. length 1-2 */
|
||||
#define PW_DECREMENT_OUTPUT_VOLTAGE (unsigned char)0x8C /* Decrease output voltage. length 1 */
|
||||
#define PW_INCREMENT_OUTPUT_VOLTAGE (unsigned char)0x8D /* Increase output voltage. length 1 */
|
||||
#define PW_SET_TIME_AND_DATE (unsigned char)0x90 /* Set the real-time clock inside UPS. length 8 */
|
||||
#define PW_UPS_ON_TIME (unsigned char)0x91 /* Scheduled UPS on in n minutes. length 3-4 */
|
||||
#define PW_UPS_ON_AT_TIME (unsigned char)0x92 /* Schedule UPS on at specified date and time. length 7-8 */
|
||||
#define PW_UPS_OFF_TIME (unsigned char)0x93 /* Scheduled UPS off in n minutes. length 3-4 */
|
||||
#define PW_UPS_OFF_AT_TIME (unsigned char)0x94 /* Schedule UPS off at specified date and time. length 7-8 */
|
||||
#define PW_SET_CONF_COMMAND (unsigned char)0x95 /* Set configuration command. length 4 */
|
||||
#define PW_SET_OUTLET_COMMAND (unsigned char)0x97 /* Set outlet parameter command length 5. not in 5115 */
|
||||
#define PW_SET_COM_COMMAND (unsigned char)0x98 /* Set communication parameter command. length 5 */
|
||||
#define PW_SET_SCRATHPAD_SECTOR (unsigned char)0x99 /* Write data to scratchpad. length 3 or 18 */
|
||||
#define PW_SET_POWER_STRATEGY (unsigned char)0x9A /* Set the power strategy. length 2 */
|
||||
#define PW_SET_REQ_ONLY_MODE (unsigned char)0xA0 /* Set request only mode command. length 1 */
|
||||
#define PW_SET_UNREQUESTED_MODE (unsigned char)0xA1 /* Set unrequested mode command. length 1 */
|
||||
#define PW_INIT_BAT_TEST (unsigned char)0xB1 /* Initiate battery test command. length 3 */
|
||||
#define PW_INIT_SYS_TEST (unsigned char)0xB2 /* Initiate general system test command. length 2 */
|
||||
#define PW_SELECT_SUBMODULE (unsigned char)0xCE /* Select a sub module. length 2-7 */
|
||||
#define PW_AUTHORIZATION_CODE (unsigned char)0xCF /* Authorization code. length 4 or 7 */
|
||||
|
||||
/* Define the XCP ACK block responses */
|
||||
#define XCPRESP_ACK 0x31 /* Accepted and executed */
|
||||
#define XCPRESP_NOT_IMPL 0x32 /* Recognized, but not implemented */
|
||||
#define XCPRESP_BUSY 0x33 /* Recognized, but Busy and not executed */
|
||||
#define XCPRESP_UNRECOGN 0x34 /* Unrecognized cmd */
|
||||
#define XCPRESP_OUT_RANGE 0x35 /* Parameter was out of range; not executed */
|
||||
#define XCPRESP_PRM_INVLD 0x36 /* Parameter invalid; not executed */
|
||||
#define XCPRESP_PRM_ADJST 0x37 /* Parameter adjusted to nearest good value */
|
||||
#define XCPRESP_PRM_RDONLY 0x38 /* Parameter is Read-only - cannot be written (at this privilege level) */
|
||||
/* Define the XCP system test */
|
||||
#define PW_SYS_TEST_GENERAL (unsigned char)0x01 /* Initiate General system Test */
|
||||
#define PW_SYS_TEST_SCHEDULE_BATTERY_COMMISSION (unsigned char)0x02 /* Schedule Battery Commissioning Test */
|
||||
#define PW_SYS_TEST_ALTERNATE_AC_INPUT (unsigned char)0x03 /* Test Alternate AC Input */
|
||||
#define PW_SYS_TEST_FLASH_LIGHTS (unsigned char)0x04 /* Flash the Lights Test */
|
||||
#define PW_SYS_TEST_REPORT_CAPABILITIES (unsigned char)0xFF /* Report Systems Test Capabilities */
|
||||
|
||||
/* Outlet operations */
|
||||
#define PW_ALL_OUTLETS 0
|
||||
#define PW_AUTO_OFF_DELAY 1
|
||||
#define PW_AUTO_ON_DELAY 2
|
||||
#define PW_ALL_OUTLETS 0
|
||||
#define PW_AUTO_OFF_DELAY 1
|
||||
#define PW_AUTO_ON_DELAY 2
|
||||
/* 0 means Abort countdown */
|
||||
#define PW_TURN_OFF_DELAY 3
|
||||
#define PW_TURN_ON_DELAY 4
|
||||
#define PW_TURN_OFF_DELAY 3
|
||||
#define PW_TURN_ON_DELAY 4
|
||||
|
||||
/* Config block offsets */
|
||||
#define BCMXCP_CONFIG_BLOCK_MACHINE_TYPE_CODE 0
|
||||
#define BCMXCP_CONFIG_BLOCK_MODEL_NUMBER 2
|
||||
#define BCMXCP_CONFIG_BLOCK_MODEL_CONF_WORD 4
|
||||
#define BCMXCP_CONFIG_BLOCK_INPUT_FREQ_DEV_LIMIT 6
|
||||
#define BCMXCP_CONFIG_BLOCK_NOMINAL_OUTPUT_VOLTAGE 8
|
||||
#define BCMXCP_CONFIG_BLOCK_NOMINAL_OUTPUT_FREQ 10
|
||||
#define BCMXCP_CONFIG_BLOCK_OUTPUT_PHASE_ANGLE 12
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD1 14
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_BYTE3 16 /* KEEP THIS UNTILL PARSING OK. USE THIS BYTE. */
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD2 16
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD3 18
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD4 20
|
||||
#define BCMXCP_CONFIG_BLOCK_BATTERY_DATA_WORD1 22 /* Undefined at this time.*/
|
||||
#define BCMXCP_CONFIG_BLOCK_BATTERY_DATA_WORD2 24 /* Per cell inverter shutdown voltage at full rated load. (volt/cell)* 100 */
|
||||
#define BCMXCP_CONFIG_BLOCK_BATTERY_DATA_WORD3 26 /* LOW BYTE Number of battery strings. HIGH BYTE undefined at this time.*/
|
||||
#define BCMXCP_CONFIG_BLOCK_EXTENDED_BLOCK_LENGTH 47
|
||||
#define BCMXCP_CONFIG_BLOCK_SERIAL_NUMBER 64
|
||||
#define BCMXCP_CONFIG_BLOCK_MACHINE_TYPE_CODE 0
|
||||
#define BCMXCP_CONFIG_BLOCK_MODEL_NUMBER 2
|
||||
#define BCMXCP_CONFIG_BLOCK_MODEL_CONF_WORD 4
|
||||
#define BCMXCP_CONFIG_BLOCK_INPUT_FREQ_DEV_LIMIT 6
|
||||
#define BCMXCP_CONFIG_BLOCK_NOMINAL_OUTPUT_VOLTAGE 8
|
||||
#define BCMXCP_CONFIG_BLOCK_NOMINAL_OUTPUT_FREQ 10
|
||||
#define BCMXCP_CONFIG_BLOCK_OUTPUT_PHASE_ANGLE 12
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD1 14
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_BYTE3 16 /* KEEP THIS UNTILL PARSING OK. USE THIS BYTE. */
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD2 16
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD3 18
|
||||
#define BCMXCP_CONFIG_BLOCK_HW_MODULES_INSTALLED_WORD4 20
|
||||
#define BCMXCP_CONFIG_BLOCK_BATTERY_DATA_WORD1 22 /* Undefined at this time.*/
|
||||
#define BCMXCP_CONFIG_BLOCK_BATTERY_DATA_WORD2 24 /* Per cell inverter shutdown voltage at full rated load. (volt/cell)* 100 */
|
||||
#define BCMXCP_CONFIG_BLOCK_BATTERY_DATA_WORD3 26 /* LOW BYTE Number of battery strings. HIGH BYTE undefined at this time.*/
|
||||
#define BCMXCP_CONFIG_BLOCK_EXTENDED_BLOCK_LENGTH 47
|
||||
#define BCMXCP_CONFIG_BLOCK_PART_NUMBER 48
|
||||
#define BCMXCP_CONFIG_BLOCK_SERIAL_NUMBER 64
|
||||
|
||||
/* Index for Extende Limits block offsets */
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_NOMINAL_INPUT_VOLTAGE 0
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_NOMINAL_INPUT_FREQ 2
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_NOMINAL_TRUE_POWER 4
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_COMM_SPEC_VERSION 6
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_FREQ_DEV_LIMIT 8
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_VOLTAGE_LOW_DEV_LIMIT 10
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_VOLTAGE_HIGE_DEV_LIMIT 12
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_PHASE_DEV_LIMIT 14
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_LOW_BATT_WARNING 16
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_HORN_STATUS 17
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_MIN_INPUT_VOLTAGE 18
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_MAX_INPUT_VOLTAGE 20
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_RETURN_STAB_DELAY 22
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_BATT_CAPACITY_RETURN 24
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_AMBIENT_TEMP_LOW 25
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_AMBIENT_TEMP_HIGE 26
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_NOMINAL_INPUT_VOLTAGE 0
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_NOMINAL_INPUT_FREQ 2
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_NOMINAL_TRUE_POWER 4
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_COMM_SPEC_VERSION 6
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_FREQ_DEV_LIMIT 8
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_VOLTAGE_LOW_DEV_LIMIT 10
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_VOLTAGE_HIGE_DEV_LIMIT 12
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_PHASE_DEV_LIMIT 14
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_LOW_BATT_WARNING 16
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_HORN_STATUS 17
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_MIN_INPUT_VOLTAGE 18
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_MAX_INPUT_VOLTAGE 20
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_RETURN_STAB_DELAY 22
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_BATT_CAPACITY_RETURN 24
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_AMBIENT_TEMP_LOW 25
|
||||
#define BCMXCP_EXT_LIMITS_BLOCK_AMBIENT_TEMP_HIGE 26
|
||||
|
||||
/* Meter map offsets used */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA 23
|
||||
#define BCMXCP_METER_MAP_LOAD_CURR_PHASE_A 65
|
||||
#define BCMXCP_METER_MAP_LOAD_CURR_PHASE_A_BAR_CHART 68
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA_BAR_CHART 71
|
||||
/* Indexes for meter map */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTS_AB 0 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTS_BC 1 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTS_CA 2 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTS_AB 3 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTS_BC 4 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTS_CA 5 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INVERTER_VOLTS_AB 6
|
||||
#define BCMXCP_METER_MAP_INVERTER_VOLTS_BC 7
|
||||
#define BCMXCP_METER_MAP_INVERTER_VOLTS_CA 8
|
||||
#define BCMXCP_METER_MAP_BYPASS_VOLTS_AB 9
|
||||
#define BCMXCP_METER_MAP_BYPASS_VOLTS_BC 10
|
||||
#define BCMXCP_METER_MAP_BYPASS_VOLTS_CA 11
|
||||
#define BCMXCP_METER_MAP_MAIN_LOGIC_POWER 12
|
||||
#define BCMXCP_METER_MAP_SECONDARY_V_PLUS_POWER 13
|
||||
#define BCMXCP_METER_MAP_SECONDARY_V_MINUS_POWER 14
|
||||
#define BCMXCP_METER_MAP_INVERTER_AVG_CURRENT_PHASE_A 15
|
||||
#define BCMXCP_METER_MAP_INVERTER_AVG_CURRENT_PHASE_B 16
|
||||
#define BCMXCP_METER_MAP_INVERTER_AVG_CURRENT_PHASE_C 17
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_PHASE_A 18 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_PHASE_B 19 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_PHASE_C 20 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_WATTS 21
|
||||
#define BCMXCP_METER_MAP_INPUT_WATTS 22 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA 23 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VA 24 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_POWER_FACTOR 25 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_POWER_FACTOR 26 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_FREQUENCY 27 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_FREQUENCY 28 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INVERTER_FREQUENCY 29
|
||||
#define BCMXCP_METER_MAP_BYPASS_FREQUENCY 30 /* mapped */
|
||||
#define BCMXCP_METER_MAP_DC_LINK_VOLTS_DC 31
|
||||
#define BCMXCP_METER_MAP_BATTERY_CURRENT 32 /* mapped */
|
||||
#define BCMXCP_METER_MAP_BATTERY_VOLTAGE 33 /* mapped */
|
||||
#define BCMXCP_METER_MAP_PERCENT_BATTERY_LEFT 34 /* mapped */
|
||||
#define BCMXCP_METER_MAP_BATTERY_TIME_REMAINING 35 /* mapped */
|
||||
#define BCMXCP_METER_MAP_BATTERY_CHARGE_TIME 36
|
||||
#define BCMXCP_METER_MAP_PEAK_INVERTER_CURRENT_PHASE_A 37
|
||||
#define BCMXCP_METER_MAP_PEAK_INVERTER_CURRENT_PHASE_B 38
|
||||
#define BCMXCP_METER_MAP_PEAK_INVERTER_CURRENT_PHASE_C 39
|
||||
#define BCMXCP_METER_MAP_AVG_INPUT_CURRENT_3_PHASE_SUM 40
|
||||
#define BCMXCP_METER_MAP_BATTERY_DCUV_BAR_CHART 41 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_BAR_CHART 42
|
||||
#define BCMXCP_METER_MAP_LOW_BATTERY_WARNING_V_BAR_CHART 43 /* mapped */
|
||||
#define BCMXCP_METER_MAP_DC_VOLTS_BAR_CHART 44
|
||||
#define BCMXCP_METER_MAP_BATTERY_CHARGING_CURRENT_BAR_CHART 45
|
||||
#define BCMXCP_METER_MAP_BATTERY_DISCHARGING_CURRENT_BAR_CHART 46 /* mapped */
|
||||
#define BCMXCP_METER_MAP_PERCENT_LOAD_PHASE_A 47 /* mapped */
|
||||
#define BCMXCP_METER_MAP_PERCENT_LOAD_PHASE_B 48 /* mapped */
|
||||
#define BCMXCP_METER_MAP_PERCENT_LOAD_PHASE_C 49 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA_PHASE_A 50 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA_PHASE_B 51 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA_PHASE_C 52 /* mapped */
|
||||
#define BCMXCP_METER_MAP_BYPASS_VOLTS_PHASE_A 53 /* mapped */
|
||||
#define BCMXCP_METER_MAP_BYPASS_VOLTS_PHASE_B 54 /* mapped */
|
||||
#define BCMXCP_METER_MAP_BYPASS_VOLTS_PHASE_C 55 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTS_PHASE_A 56 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTS_PHASE_B 57 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTS_PHASE_C 58 /* mapped */
|
||||
#define BCMXCP_METER_MAP_INVERTER_VOLTS_PHASE_A 59
|
||||
#define BCMXCP_METER_MAP_INVERTER_VOLTS_PHASE_B 60
|
||||
#define BCMXCP_METER_MAP_INVERTER_VOLTS_PHASE_C 61
|
||||
#define BCMXCP_METER_MAP_AMBIENT_TEMPERATURE 62 /* mapped */
|
||||
#define BCMXCP_METER_MAP_HEATSINK_TEMPERATURE 63 /* mapped */
|
||||
#define BCMXCP_METER_MAP_POWER_SUPPLY_TEMPERATURE 64 /* mapped */
|
||||
#define BCMXCP_METER_MAP_LOAD_CURRENT_PHASE_A 65 /* mapped */
|
||||
#define BCMXCP_METER_MAP_LOAD_CURRENT_PHASE_B 66 /* mapped */
|
||||
#define BCMXCP_METER_MAP_LOAD_CURRENT_PHASE_C 67 /* mapped */
|
||||
#define BCMXCP_METER_MAP_LOAD_CURRENT_PHASE_A_BAR_CHART 68 /* mapped */
|
||||
#define BCMXCP_METER_MAP_LOAD_CURRENT_PHASE_B_BAR_CHART 69 /* mapped */
|
||||
#define BCMXCP_METER_MAP_LOAD_CURRENT_PHASE_C_BAR_CHART 70 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VA_BAR_CHART 71 /* mapped */
|
||||
#define BCMXCP_METER_MAP_DATE 72 /* mapped */
|
||||
#define BCMXCP_METER_MAP_TIME 73 /* mapped */
|
||||
#define BCMXCP_METER_MAP_POSITIVE_DC_LINK_RAIL_VOLTAGE 74
|
||||
#define BCMXCP_METER_MAP_NEGATIVE_DC_LINK_RAIL_VOLTAGE 75
|
||||
#define BCMXCP_METER_MAP_AUTO_BALANCE_VOLTAGE_DC 76
|
||||
#define BCMXCP_METER_MAP_BATTERY_TEMPERATURE 77 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTS_A 78 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTS_B 79 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTS_C 80 /* mapped */
|
||||
#define BCMXCP_METER_MAP_NEUTRAL_CURRENT 81
|
||||
#define BCMXCP_METER_MAP_OUTPUT_WATTS_PHASE_A 82 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_WATTS_PHASE_B 83 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_WATTS_PHASE_C 84 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_WATTS_PHASE_A_B_C_BAR_CHART 85 /* mapped */
|
||||
#define BCMXCP_METER_MAP_RECTIFIER_DC_CURRENT 86
|
||||
#define BCMXCP_METER_MAP_POSITIVE_BATTERY_VOLTAGE 87
|
||||
#define BCMXCP_METER_MAP_NEGATIVE_BATTERY_VOLTAGE 88
|
||||
#define BCMXCP_METER_MAP_POSITIVE_BATTERY_CURRENT 89
|
||||
#define BCMXCP_METER_MAP_NEGATIVE_BATTERY_CURRENT 90
|
||||
#define BCMXCP_METER_MAP_LINE_EVENT_COUNTER 91 /* mapped */
|
||||
#define BCMXCP_METER_MAP_OUTPUT_V1_PERCENT 92
|
||||
#define BCMXCP_METER_MAP_OUTPUT_V2_PERCENT 93
|
||||
#define BCMXCP_METER_MAP_OUTPUT_V3_PERCENT 94
|
||||
#define BCMXCP_METER_MAP_OUTPUT_I1_PERCENT 95
|
||||
#define BCMXCP_METER_MAP_OUTPUT_I2_PERCENT 96
|
||||
#define BCMXCP_METER_MAP_OUTPUT_I3_PERCENT 97
|
||||
#define BCMXCP_METER_MAP_INPUT_V1_PERCENT 98
|
||||
#define BCMXCP_METER_MAP_INPUT_V2_PERCENT 99
|
||||
#define BCMXCP_METER_MAP_INPUT_V3_PERCENT 100
|
||||
#define BCMXCP_METER_MAP_INPUT_I1_PERCENT 101
|
||||
#define BCMXCP_METER_MAP_INPUT_I2_PERCENT 102
|
||||
#define BCMXCP_METER_MAP_INPUT_I3_PERCENT 103
|
||||
#define BCMXCP_METER_MAP_GROUND_CURRENT 104
|
||||
#define BCMXCP_METER_MAP_OUTPUT_CREST_FACTOR_L1 105
|
||||
#define BCMXCP_METER_MAP_OUTPUT_CREST_FACTOR_L2 106
|
||||
#define BCMXCP_METER_MAP_OUTPUT_CREST_FACTOR_L3 107
|
||||
#define BCMXCP_METER_MAP_OUTPUT_KW_HOUR 108
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTAGE_THD_LINE1 109
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTAGE_THD_LINE2 110
|
||||
#define BCMXCP_METER_MAP_INPUT_VOLTAGE_THD_LINE3 111
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_THD_LINE1 112
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_THD_LINE2 113
|
||||
#define BCMXCP_METER_MAP_INPUT_CURRENT_THD_LINE3 114
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTAGE_THD_LINE1 115
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTAGE_THD_LINE2 116
|
||||
#define BCMXCP_METER_MAP_OUTPUT_VOLTAGE_THD_LINE3 117
|
||||
#define BCMXCP_METER_MAP_OUTPUT_CURRENT_THD_LINE1 118
|
||||
#define BCMXCP_METER_MAP_OUTPUT_CURRENT_THD_LINE2 119
|
||||
#define BCMXCP_METER_MAP_OUTPUT_CURRENT_THD_LINE3 120
|
||||
#define BCMXCP_METER_MAP_INPUT_CREST_FACTOR_L1 121
|
||||
#define BCMXCP_METER_MAP_INPUT_CREST_FACTOR_L2 122
|
||||
#define BCMXCP_METER_MAP_INPUT_CREST_FACTOR_L3 123
|
||||
#define BCMXCP_METER_MAP_INPUT_KW_HOUR 124
|
||||
#define BCMXCP_METER_MAP_BATTERY_LIFE_REMAINING 125
|
||||
#define BCMXCP_METER_MAP_SECONDARY_NEUTRAL_CURRENT 126
|
||||
#define BCMXCP_METER_MAP_SECONDARY_GROUND_CURRENT 127
|
||||
#define BCMXCP_METER_MAP_HOURS_OF_OPERATION 128
|
||||
|
||||
/* Indexes for alarm map */
|
||||
#define BCMXCP_ALARM_INVERTER_AC_OVER_VOLTAGE 0
|
||||
#define BCMXCP_ALARM_INVERTER_AC_UNDER_VOLTAGE 1
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_OR_UNDER_FREQ 2
|
||||
#define BCMXCP_ALARM_BYPASS_AC_OVER_VOLTAGE 3
|
||||
#define BCMXCP_ALARM_BYPASS_AC_UNDER_VOLTAGE 4
|
||||
#define BCMXCP_ALARM_BYPASS_OVER_OR_UNDER_FREQ 5
|
||||
#define BCMXCP_ALARM_INPUT_AC_OVER_VOLTAGE 6
|
||||
#define BCMXCP_ALARM_INPUT_AC_UNDER_VOLTAGE 7
|
||||
#define BCMXCP_ALARM_INPUT_UNDER_OR_OVER_FREQ 8
|
||||
#define BCMXCP_ALARM_OUTPUT_OVER_VOLTAGE 9
|
||||
#define BCMXCP_ALARM_OUTPUT_UNDER_VOLTAGE 10
|
||||
#define BCMXCP_ALARM_OUTPUT_UNDER_OR_OVER_FREQ 11
|
||||
#define BCMXCP_ALARM_REMOTE_EMERGENCY_PWR_OFF 12
|
||||
#define BCMXCP_ALARM_REMOTE_GO_TO_BYPASS 13
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_6 14
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_5 15
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_4 16
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_3 17
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_2 18
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_1 19
|
||||
#define BCMXCP_ALARM_STATIC_SWITCH_OVER_TEMP 20
|
||||
#define BCMXCP_ALARM_CHARGER_OVER_TEMP 21
|
||||
#define BCMXCP_ALARM_CHARGER_LOGIC_PWR_FAIL 22
|
||||
#define BCMXCP_ALARM_CHARGER_OVER_VOLTAGE_OR_CURRENT 23
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_TEMP 24
|
||||
#define BCMXCP_ALARM_OUTPUT_OVERLOAD 25
|
||||
#define BCMXCP_ALARM_RECTIFIER_INPUT_OVER_CURRENT 26
|
||||
#define BCMXCP_ALARM_INVERTER_OUTPUT_OVER_CURRENT 27
|
||||
#define BCMXCP_ALARM_DC_LINK_OVER_VOLTAGE 28
|
||||
#define BCMXCP_ALARM_DC_LINK_UNDER_VOLTAGE 29
|
||||
#define BCMXCP_ALARM_RECTIFIER_FAILED 30
|
||||
#define BCMXCP_ALARM_INVERTER_FAULT 31
|
||||
#define BCMXCP_ALARM_BATTERY_CONNECTOR_FAIL 32
|
||||
#define BCMXCP_ALARM_BYPASS_BREAKER_FAIL 33
|
||||
#define BCMXCP_ALARM_CHARGER_FAIL 34
|
||||
#define BCMXCP_ALARM_RAMP_UP_FAILED 35
|
||||
#define BCMXCP_ALARM_STATIC_SWITCH_FAILED 36
|
||||
#define BCMXCP_ALARM_ANALOG_AD_REF_FAIL 37
|
||||
#define BCMXCP_ALARM_BYPASS_UNCALIBRATED 38
|
||||
#define BCMXCP_ALARM_RECTIFIER_UNCALIBRATED 39
|
||||
#define BCMXCP_ALARM_OUTPUT_UNCALIBRATED 40
|
||||
#define BCMXCP_ALARM_INVERTER_UNCALIBRATED 41
|
||||
#define BCMXCP_ALARM_DC_VOLT_UNCALIBRATED 42
|
||||
#define BCMXCP_ALARM_OUTPUT_CURRENT_UNCALIBRATED 43
|
||||
#define BCMXCP_ALARM_RECTIFIER_CURRENT_UNCALIBRATED 44
|
||||
#define BCMXCP_ALARM_BATTERY_CURRENT_UNCALIBRATED 45
|
||||
#define BCMXCP_ALARM_INVERTER_ON_OFF_STAT_FAIL 46
|
||||
#define BCMXCP_ALARM_BATTERY_CURRENT_LIMIT 47
|
||||
#define BCMXCP_ALARM_INVERTER_STARTUP_FAIL 48
|
||||
#define BCMXCP_ALARM_ANALOG_BOARD_AD_STAT_FAIL 49
|
||||
#define BCMXCP_ALARM_OUTPUT_CURRENT_OVER_100 50
|
||||
#define BCMXCP_ALARM_BATTERY_GROUND_FAULT 51
|
||||
#define BCMXCP_ALARM_WAITING_FOR_CHARGER_SYNC 52
|
||||
#define BCMXCP_ALARM_NV_RAM_FAIL 53
|
||||
#define BCMXCP_ALARM_ANALOG_BOARD_AD_TIMEOUT 54
|
||||
#define BCMXCP_ALARM_SHUTDOWN_IMMINENT 55
|
||||
#define BCMXCP_ALARM_BATTERY_LOW 56
|
||||
#define BCMXCP_ALARM_UTILITY_FAIL 57
|
||||
#define BCMXCP_ALARM_OUTPUT_SHORT_CIRCUIT 58
|
||||
#define BCMXCP_ALARM_UTILITY_NOT_PRESENT 59
|
||||
#define BCMXCP_ALARM_FULL_TIME_CHARGING 60
|
||||
#define BCMXCP_ALARM_FAST_BYPASS_COMMAND 61
|
||||
#define BCMXCP_ALARM_AD_ERROR 62
|
||||
#define BCMXCP_ALARM_INTERNAL_COM_FAIL 63
|
||||
#define BCMXCP_ALARM_RECTIFIER_SELFTEST_FAIL 64
|
||||
#define BCMXCP_ALARM_RECTIFIER_EEPROM_FAIL 65
|
||||
#define BCMXCP_ALARM_RECTIFIER_EPROM_FAIL 66
|
||||
#define BCMXCP_ALARM_INPUT_LINE_VOLTAGE_LOSS 67
|
||||
#define BCMXCP_ALARM_BATTERY_DC_OVER_VOLTAGE 68
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_OVER_TEMP 69
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_FAIL 70
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_5V_FAIL 71
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_12V_FAIL 72
|
||||
#define BCMXCP_ALARM_HEATSINK_OVER_TEMP 73
|
||||
#define BCMXCP_ALARM_HEATSINK_TEMP_SENSOR_FAIL 74
|
||||
#define BCMXCP_ALARM_RECTIFIER_CURRENT_OVER_125 75
|
||||
#define BCMXCP_ALARM_RECTIFIER_FAULT_INTERRUPT_FAIL 76
|
||||
#define BCMXCP_ALARM_RECTIFIER_POWER_CAPASITOR_FAIL 77
|
||||
#define BCMXCP_ALARM_INVERTER_PROGRAM_STACK_ERROR 78
|
||||
#define BCMXCP_ALARM_INVERTER_BOARD_SELFTEST_FAIL 79
|
||||
#define BCMXCP_ALARM_INVERTER_AD_SELFTEST_FAIL 80
|
||||
#define BCMXCP_ALARM_INVERTER_RAM_SELFTEST_FAIL 81
|
||||
#define BCMXCP_ALARM_NV_MEMORY_CHECKSUM_FAIL 82
|
||||
#define BCMXCP_ALARM_PROGRAM_CHECKSUM_FAIL 83
|
||||
#define BCMXCP_ALARM_INVERTER_CPU_SELFTEST_FAIL 84
|
||||
#define BCMXCP_ALARM_NETWORK_NOT_RESPONDING 85
|
||||
#define BCMXCP_ALARM_FRONT_PANEL_SELFTEST_FAIL 86
|
||||
#define BCMXCP_ALARM_NODE_EEPROM_VERIFICATION_ERROR 87
|
||||
#define BCMXCP_ALARM_OUTPUT_AC_OVER_VOLT_TEST_FAIL 88
|
||||
#define BCMXCP_ALARM_OUTPUT_DC_OVER_VOLTAGE 89
|
||||
#define BCMXCP_ALARM_INPUT_PHASE_ROTATION_ERROR 90
|
||||
#define BCMXCP_ALARM_INVERTER_RAMP_UP_TEST_FAILED 91
|
||||
#define BCMXCP_ALARM_INVERTER_OFF_COMMAND 92
|
||||
#define BCMXCP_ALARM_INVERTER_ON_COMMAND 93
|
||||
#define BCMXCP_ALARM_TO_BYPASS_COMMAND 94
|
||||
#define BCMXCP_ALARM_FROM_BYPASS_COMMAND 95
|
||||
#define BCMXCP_ALARM_AUTO_MODE_COMMAND 96
|
||||
#define BCMXCP_ALARM_EMERGENCY_SHUTDOWN_COMMAND 97
|
||||
#define BCMXCP_ALARM_SETUP_SWITCH_OPEN 98
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_VOLT_INT 99
|
||||
#define BCMXCP_ALARM_INVERTER_UNDER_VOLT_INT 100
|
||||
#define BCMXCP_ALARM_ABSOLUTE_DCOV_ACOV 101
|
||||
#define BCMXCP_ALARM_PHASE_A_CURRENT_LIMIT 102
|
||||
#define BCMXCP_ALARM_PHASE_B_CURRENT_LIMIT 103
|
||||
#define BCMXCP_ALARM_PHASE_C_CURRENT_LIMIT 104
|
||||
#define BCMXCP_ALARM_BYPASS_NOT_AVAILABLE 105
|
||||
#define BCMXCP_ALARM_RECTIFIER_BREAKER_OPEN 106
|
||||
#define BCMXCP_ALARM_BATTERY_CONTACTOR_OPEN 107
|
||||
#define BCMXCP_ALARM_INVERTER_CONTACTOR_OPEN 108
|
||||
#define BCMXCP_ALARM_BYPASS_BREAKER_OPEN 109
|
||||
#define BCMXCP_ALARM_INV_BOARD_ACOV_INT_TEST_FAIL 110
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_TEMP_TRIP 111
|
||||
#define BCMXCP_ALARM_INV_BOARD_ACUV_INT_TEST_FAIL 112
|
||||
#define BCMXCP_ALARM_INVERTER_VOLTAGE_FEEDBACK_ERROR 113
|
||||
#define BCMXCP_ALARM_DC_UNDER_VOLTAGE_TIMEOUT 114
|
||||
#define BCMXCP_ALARM_AC_UNDER_VOLTAGE_TIMEOUT 115
|
||||
#define BCMXCP_ALARM_DC_UNDER_VOLTAGE_WHILE_CHARGE 116
|
||||
#define BCMXCP_ALARM_INVERTER_VOLTAGE_BIAS_ERROR 117
|
||||
#define BCMXCP_ALARM_RECTIFIER_PHASE_ROTATION 118
|
||||
#define BCMXCP_ALARM_BYPASS_PHASER_ROTATION 119
|
||||
#define BCMXCP_ALARM_SYSTEM_INTERFACE_BOARD_FAIL 120
|
||||
#define BCMXCP_ALARM_PARALLEL_BOARD_FAIL 121
|
||||
#define BCMXCP_ALARM_LOST_LOAD_SHARING_PHASE_A 122
|
||||
#define BCMXCP_ALARM_LOST_LOAD_SHARING_PHASE_B 123
|
||||
#define BCMXCP_ALARM_LOST_LOAD_SHARING_PHASE_C 124
|
||||
#define BCMXCP_ALARM_DC_OVER_VOLTAGE_TIMEOUT 125
|
||||
#define BCMXCP_ALARM_BATTERY_TOTALLY_DISCHARGED 126
|
||||
#define BCMXCP_ALARM_INVERTER_PHASE_BIAS_ERROR 127
|
||||
#define BCMXCP_ALARM_INVERTER_VOLTAGE_BIAS_ERROR_2 128
|
||||
#define BCMXCP_ALARM_DC_LINK_BLEED_COMPLETE 129
|
||||
#define BCMXCP_ALARM_LARGE_CHARGER_INPUT_CURRENT 130
|
||||
#define BCMXCP_ALARM_INV_VOLT_TOO_LOW_FOR_RAMP_LEVEL 131
|
||||
#define BCMXCP_ALARM_LOSS_OF_REDUNDANCY 132
|
||||
#define BCMXCP_ALARM_LOSS_OF_SYNC_BUS 133
|
||||
#define BCMXCP_ALARM_RECTIFIER_BREAKER_SHUNT_TRIP 134
|
||||
#define BCMXCP_ALARM_LOSS_OF_CHARGER_SYNC 135
|
||||
#define BCMXCP_ALARM_INVERTER_LOW_LEVEL_TEST_TIMEOUT 136
|
||||
#define BCMXCP_ALARM_OUTPUT_BREAKER_OPEN 137
|
||||
#define BCMXCP_ALARM_CONTROL_POWER_ON 138
|
||||
#define BCMXCP_ALARM_INVERTER_ON 139
|
||||
#define BCMXCP_ALARM_CHARGER_ON 140
|
||||
#define BCMXCP_ALARM_BYPASS_ON 141
|
||||
#define BCMXCP_ALARM_BYPASS_POWER_LOSS 142
|
||||
#define BCMXCP_ALARM_ON_MANUAL_BYPASS 143
|
||||
#define BCMXCP_ALARM_BYPASS_MANUAL_TURN_OFF 144
|
||||
#define BCMXCP_ALARM_INVERTER_BLEEDING_DC_LINK_VOLT 145
|
||||
#define BCMXCP_ALARM_CPU_ISR_ERROR 146
|
||||
#define BCMXCP_ALARM_SYSTEM_ISR_RESTART 147
|
||||
#define BCMXCP_ALARM_PARALLEL_DC 148
|
||||
#define BCMXCP_ALARM_BATTERY_NEEDS_SERVICE 149
|
||||
#define BCMXCP_ALARM_BATTERY_CHARGING 150
|
||||
#define BCMXCP_ALARM_BATTERY_NOT_CHARGED 151
|
||||
#define BCMXCP_ALARM_DISABLED_BATTERY_TIME 152
|
||||
#define BCMXCP_ALARM_SERIES_7000_ENABLE 153
|
||||
#define BCMXCP_ALARM_OTHER_UPS_ON 154
|
||||
#define BCMXCP_ALARM_PARALLEL_INVERTER 155
|
||||
#define BCMXCP_ALARM_UPS_IN_PARALLEL 156
|
||||
#define BCMXCP_ALARM_OUTPUT_BREAKER_REALY_FAIL 157
|
||||
#define BCMXCP_ALARM_CONTROL_POWER_OFF 158
|
||||
#define BCMXCP_ALARM_LEVEL_2_OVERLOAD_PHASE_A 159
|
||||
#define BCMXCP_ALARM_LEVEL_2_OVERLOAD_PHASE_B 160
|
||||
#define BCMXCP_ALARM_LEVEL_2_OVERLOAD_PHASE_C 161
|
||||
#define BCMXCP_ALARM_LEVEL_3_OVERLOAD_PHASE_A 162
|
||||
#define BCMXCP_ALARM_LEVEL_3_OVERLOAD_PHASE_B 163
|
||||
#define BCMXCP_ALARM_LEVEL_3_OVERLOAD_PHASE_C 164
|
||||
#define BCMXCP_ALARM_LEVEL_4_OVERLOAD_PHASE_A 165
|
||||
#define BCMXCP_ALARM_LEVEL_4_OVERLOAD_PHASE_B 166
|
||||
#define BCMXCP_ALARM_LEVEL_4_OVERLOAD_PHASE_C 167
|
||||
#define BCMXCP_ALARM_UPS_ON_BATTERY 168
|
||||
#define BCMXCP_ALARM_UPS_ON_BYPASS 169
|
||||
#define BCMXCP_ALARM_LOAD_DUMPED 170
|
||||
#define BCMXCP_ALARM_LOAD_ON_INVERTER 171
|
||||
#define BCMXCP_ALARM_UPS_ON_COMMAND 172
|
||||
#define BCMXCP_ALARM_UPS_OFF_COMMAND 173
|
||||
#define BCMXCP_ALARM_LOW_BATTERY_SHUTDOWN 174
|
||||
#define BCMXCP_ALARM_AUTO_ON_ENABLED 175
|
||||
#define BCMXCP_ALARM_SOFTWARE_INCOMPABILITY_DETECTED 176
|
||||
#define BCMXCP_ALARM_INVERTER_TEMP_SENSOR_FAILED 177
|
||||
#define BCMXCP_ALARM_DC_START_OCCURED 178
|
||||
#define BCMXCP_ALARM_IN_PARALLEL_OPERATION 179
|
||||
#define BCMXCP_ALARM_SYNCING_TO_BYPASS 180
|
||||
#define BCMXCP_ALARM_RAMPING_UPS_UP 181
|
||||
#define BCMXCP_ALARM_INVERTER_ON_DELAY 182
|
||||
#define BCMXCP_ALARM_CHARGER_ON_DELAY 183
|
||||
#define BCMXCP_ALARM_WAITING_FOR_UTIL_INPUT 184
|
||||
#define BCMXCP_ALARM_CLOSE_BYPASS_BREAKER 185
|
||||
#define BCMXCP_ALARM_TEMPORARY_BYPASS_OPERATION 186
|
||||
#define BCMXCP_ALARM_SYNCING_TO_OUTPUT 187
|
||||
#define BCMXCP_ALARM_BYPASS_FAILURE 188
|
||||
#define BCMXCP_ALARM_AUTO_OFF_COMMAND_EXECUTED 189
|
||||
#define BCMXCP_ALARM_AUTO_ON_COMMAND_EXECUTED 190
|
||||
#define BCMXCP_ALARM_BATTERY_TEST_FAILED 191
|
||||
#define BCMXCP_ALARM_FUSE_FAIL 192
|
||||
#define BCMXCP_ALARM_FAN_FAIL 193
|
||||
#define BCMXCP_ALARM_SITE_WIRING_FAULT 194
|
||||
#define BCMXCP_ALARM_BACKFEED_CONTACTOR_FAIL 195
|
||||
#define BCMXCP_ALARM_ON_BUCK 196
|
||||
#define BCMXCP_ALARM_ON_BOOST 197
|
||||
#define BCMXCP_ALARM_ON_DOUBLE_BOOST 198
|
||||
#define BCMXCP_ALARM_BATTERIES_DISCONNECTED 199
|
||||
#define BCMXCP_ALARM_UPS_CABINET_OVER_TEMP 200
|
||||
#define BCMXCP_ALARM_TRANSFORMER_OVER_TEMP 201
|
||||
#define BCMXCP_ALARM_AMBIENT_UNDER_TEMP 202
|
||||
#define BCMXCP_ALARM_AMBIENT_OVER_TEMP 203
|
||||
#define BCMXCP_ALARM_CABINET_DOOR_OPEN 204
|
||||
#define BCMXCP_ALARM_CABINET_DOOR_OPEN_VOLT_PRESENT 205
|
||||
#define BCMXCP_ALARM_AUTO_SHUTDOWN_PENDING 206
|
||||
#define BCMXCP_ALARM_TAP_SWITCHING_REALY_PENDING 207
|
||||
#define BCMXCP_ALARM_UNABLE_TO_CHARGE_BATTERIES 208
|
||||
#define BCMXCP_ALARM_STARTUP_FAILURE_CHECK_EPO 209
|
||||
#define BCMXCP_ALARM_AUTOMATIC_STARTUP_PENDING 210
|
||||
#define BCMXCP_ALARM_MODEM_FAILED 211
|
||||
#define BCMXCP_ALARM_INCOMING_MODEM_CALL_STARTED 212
|
||||
#define BCMXCP_ALARM_OUTGOING_MODEM_CALL_STARTED 213
|
||||
#define BCMXCP_ALARM_MODEM_CONNECTION_ESTABLISHED 214
|
||||
#define BCMXCP_ALARM_MODEM_CALL_COMPLETED_SUCCESS 215
|
||||
#define BCMXCP_ALARM_MODEM_CALL_COMPLETED_FAIL 216
|
||||
#define BCMXCP_ALARM_INPUT_BREAKER_FAIL 217
|
||||
#define BCMXCP_ALARM_SYSINIT_IN_PROGRESS 218
|
||||
#define BCMXCP_ALARM_AUTOCALIBRATION_FAIL 219
|
||||
#define BCMXCP_ALARM_SELECTIVE_TRIP_OF_MODULE 220
|
||||
#define BCMXCP_ALARM_INVERTER_OUTPUT_FAILURE 221
|
||||
#define BCMXCP_ALARM_ABNORMAL_OUTPUT_VOLT_AT_STARTUP 222
|
||||
#define BCMXCP_ALARM_RECTIFIER_OVER_TEMP 223
|
||||
#define BCMXCP_ALARM_CONFIG_ERROR 224
|
||||
#define BCMXCP_ALARM_REDUNDANCY_LOSS_DUE_TO_OVERLOAD 225
|
||||
#define BCMXCP_ALARM_ON_ALTERNATE_AC_SOURCE 226
|
||||
#define BCMXCP_ALARM_IN_HIGH_EFFICIENCY_MODE 227
|
||||
#define BCMXCP_ALARM_SYSTEM_NOTICE_ACTIVE 228
|
||||
#define BCMXCP_ALARM_SYSTEM_ALARM_ACTIVE 229
|
||||
#define BCMXCP_ALARM_ALTERNATE_POWER_SOURCE_NOT_AVAILABLE 230
|
||||
#define BCMXCP_ALARM_CURRENT_BALANCE_FAILURE 231
|
||||
#define BCMXCP_ALARM_CHECK_AIR_FILTER 232
|
||||
#define BCMXCP_ALARM_SUBSYSTEM_NOTICE_ACTIVE 233
|
||||
#define BCMXCP_ALARM_SUBSYSTEM_ALARM_ACTIVE 234
|
||||
#define BCMXCP_ALARM_CHARGER_ON_COMMAND 235
|
||||
#define BCMXCP_ALARM_CHARGER_OFF_COMMAND 236
|
||||
#define BCMXCP_ALARM_UPS_NORMAL 237
|
||||
#define BCMXCP_ALARM_INVERTER_PHASE_ROTATION 238
|
||||
#define BCMXCP_ALARM_UPS_OFF 239
|
||||
#define BCMXCP_ALARM_EXTERNAL_COMMUNICATION_FAILURE 240
|
||||
#define BCMXCP_ALARM_BATTERY_TEST_INPROGRESS 256
|
||||
#define BCMXCP_ALARM_SYSTEM_TEST_INPROGRESS 257
|
||||
#define BCMXCP_ALARM_BATTERY_TEST_ABORTED 258
|
||||
#define BCMXCP_ALARM_INVERTER_AC_OVER_VOLTAGE 0
|
||||
#define BCMXCP_ALARM_INVERTER_AC_UNDER_VOLTAGE 1
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_OR_UNDER_FREQ 2
|
||||
#define BCMXCP_ALARM_BYPASS_AC_OVER_VOLTAGE 3
|
||||
#define BCMXCP_ALARM_BYPASS_AC_UNDER_VOLTAGE 4
|
||||
#define BCMXCP_ALARM_BYPASS_OVER_OR_UNDER_FREQ 5
|
||||
#define BCMXCP_ALARM_INPUT_AC_OVER_VOLTAGE 6
|
||||
#define BCMXCP_ALARM_INPUT_AC_UNDER_VOLTAGE 7
|
||||
#define BCMXCP_ALARM_INPUT_UNDER_OR_OVER_FREQ 8
|
||||
#define BCMXCP_ALARM_OUTPUT_OVER_VOLTAGE 9
|
||||
#define BCMXCP_ALARM_OUTPUT_UNDER_VOLTAGE 10
|
||||
#define BCMXCP_ALARM_OUTPUT_UNDER_OR_OVER_FREQ 11
|
||||
#define BCMXCP_ALARM_REMOTE_EMERGENCY_PWR_OFF 12
|
||||
#define BCMXCP_ALARM_REMOTE_GO_TO_BYPASS 13
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_6 14
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_5 15
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_4 16
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_3 17
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_2 18
|
||||
#define BCMXCP_ALARM_BUILDING_ALARM_1 19
|
||||
#define BCMXCP_ALARM_STATIC_SWITCH_OVER_TEMP 20
|
||||
#define BCMXCP_ALARM_CHARGER_OVER_TEMP 21
|
||||
#define BCMXCP_ALARM_CHARGER_LOGIC_PWR_FAIL 22
|
||||
#define BCMXCP_ALARM_CHARGER_OVER_VOLTAGE_OR_CURRENT 23
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_TEMP 24
|
||||
#define BCMXCP_ALARM_OUTPUT_OVERLOAD 25
|
||||
#define BCMXCP_ALARM_RECTIFIER_INPUT_OVER_CURRENT 26
|
||||
#define BCMXCP_ALARM_INVERTER_OUTPUT_OVER_CURRENT 27
|
||||
#define BCMXCP_ALARM_DC_LINK_OVER_VOLTAGE 28
|
||||
#define BCMXCP_ALARM_DC_LINK_UNDER_VOLTAGE 29
|
||||
#define BCMXCP_ALARM_RECTIFIER_FAILED 30
|
||||
#define BCMXCP_ALARM_INVERTER_FAULT 31
|
||||
#define BCMXCP_ALARM_BATTERY_CONNECTOR_FAIL 32
|
||||
#define BCMXCP_ALARM_BYPASS_BREAKER_FAIL 33
|
||||
#define BCMXCP_ALARM_CHARGER_FAIL 34
|
||||
#define BCMXCP_ALARM_RAMP_UP_FAILED 35
|
||||
#define BCMXCP_ALARM_STATIC_SWITCH_FAILED 36
|
||||
#define BCMXCP_ALARM_ANALOG_AD_REF_FAIL 37
|
||||
#define BCMXCP_ALARM_BYPASS_UNCALIBRATED 38
|
||||
#define BCMXCP_ALARM_RECTIFIER_UNCALIBRATED 39
|
||||
#define BCMXCP_ALARM_OUTPUT_UNCALIBRATED 40
|
||||
#define BCMXCP_ALARM_INVERTER_UNCALIBRATED 41
|
||||
#define BCMXCP_ALARM_DC_VOLT_UNCALIBRATED 42
|
||||
#define BCMXCP_ALARM_OUTPUT_CURRENT_UNCALIBRATED 43
|
||||
#define BCMXCP_ALARM_RECTIFIER_CURRENT_UNCALIBRATED 44
|
||||
#define BCMXCP_ALARM_BATTERY_CURRENT_UNCALIBRATED 45
|
||||
#define BCMXCP_ALARM_INVERTER_ON_OFF_STAT_FAIL 46
|
||||
#define BCMXCP_ALARM_BATTERY_CURRENT_LIMIT 47
|
||||
#define BCMXCP_ALARM_INVERTER_STARTUP_FAIL 48
|
||||
#define BCMXCP_ALARM_ANALOG_BOARD_AD_STAT_FAIL 49
|
||||
#define BCMXCP_ALARM_OUTPUT_CURRENT_OVER_100 50
|
||||
#define BCMXCP_ALARM_BATTERY_GROUND_FAULT 51
|
||||
#define BCMXCP_ALARM_WAITING_FOR_CHARGER_SYNC 52
|
||||
#define BCMXCP_ALARM_NV_RAM_FAIL 53
|
||||
#define BCMXCP_ALARM_ANALOG_BOARD_AD_TIMEOUT 54
|
||||
#define BCMXCP_ALARM_SHUTDOWN_IMMINENT 55
|
||||
#define BCMXCP_ALARM_BATTERY_LOW 56
|
||||
#define BCMXCP_ALARM_UTILITY_FAIL 57
|
||||
#define BCMXCP_ALARM_OUTPUT_SHORT_CIRCUIT 58
|
||||
#define BCMXCP_ALARM_UTILITY_NOT_PRESENT 59
|
||||
#define BCMXCP_ALARM_FULL_TIME_CHARGING 60
|
||||
#define BCMXCP_ALARM_FAST_BYPASS_COMMAND 61
|
||||
#define BCMXCP_ALARM_AD_ERROR 62
|
||||
#define BCMXCP_ALARM_INTERNAL_COM_FAIL 63
|
||||
#define BCMXCP_ALARM_RECTIFIER_SELFTEST_FAIL 64
|
||||
#define BCMXCP_ALARM_RECTIFIER_EEPROM_FAIL 65
|
||||
#define BCMXCP_ALARM_RECTIFIER_EPROM_FAIL 66
|
||||
#define BCMXCP_ALARM_INPUT_LINE_VOLTAGE_LOSS 67
|
||||
#define BCMXCP_ALARM_BATTERY_DC_OVER_VOLTAGE 68
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_OVER_TEMP 69
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_FAIL 70
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_5V_FAIL 71
|
||||
#define BCMXCP_ALARM_POWER_SUPPLY_12V_FAIL 72
|
||||
#define BCMXCP_ALARM_HEATSINK_OVER_TEMP 73
|
||||
#define BCMXCP_ALARM_HEATSINK_TEMP_SENSOR_FAIL 74
|
||||
#define BCMXCP_ALARM_RECTIFIER_CURRENT_OVER_125 75
|
||||
#define BCMXCP_ALARM_RECTIFIER_FAULT_INTERRUPT_FAIL 76
|
||||
#define BCMXCP_ALARM_RECTIFIER_POWER_CAPASITOR_FAIL 77
|
||||
#define BCMXCP_ALARM_INVERTER_PROGRAM_STACK_ERROR 78
|
||||
#define BCMXCP_ALARM_INVERTER_BOARD_SELFTEST_FAIL 79
|
||||
#define BCMXCP_ALARM_INVERTER_AD_SELFTEST_FAIL 80
|
||||
#define BCMXCP_ALARM_INVERTER_RAM_SELFTEST_FAIL 81
|
||||
#define BCMXCP_ALARM_NV_MEMORY_CHECKSUM_FAIL 82
|
||||
#define BCMXCP_ALARM_PROGRAM_CHECKSUM_FAIL 83
|
||||
#define BCMXCP_ALARM_INVERTER_CPU_SELFTEST_FAIL 84
|
||||
#define BCMXCP_ALARM_NETWORK_NOT_RESPONDING 85
|
||||
#define BCMXCP_ALARM_FRONT_PANEL_SELFTEST_FAIL 86
|
||||
#define BCMXCP_ALARM_NODE_EEPROM_VERIFICATION_ERROR 87
|
||||
#define BCMXCP_ALARM_OUTPUT_AC_OVER_VOLT_TEST_FAIL 88
|
||||
#define BCMXCP_ALARM_OUTPUT_DC_OVER_VOLTAGE 89
|
||||
#define BCMXCP_ALARM_INPUT_PHASE_ROTATION_ERROR 90
|
||||
#define BCMXCP_ALARM_INVERTER_RAMP_UP_TEST_FAILED 91
|
||||
#define BCMXCP_ALARM_INVERTER_OFF_COMMAND 92
|
||||
#define BCMXCP_ALARM_INVERTER_ON_COMMAND 93
|
||||
#define BCMXCP_ALARM_TO_BYPASS_COMMAND 94
|
||||
#define BCMXCP_ALARM_FROM_BYPASS_COMMAND 95
|
||||
#define BCMXCP_ALARM_AUTO_MODE_COMMAND 96
|
||||
#define BCMXCP_ALARM_EMERGENCY_SHUTDOWN_COMMAND 97
|
||||
#define BCMXCP_ALARM_SETUP_SWITCH_OPEN 98
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_VOLT_INT 99
|
||||
#define BCMXCP_ALARM_INVERTER_UNDER_VOLT_INT 100
|
||||
#define BCMXCP_ALARM_ABSOLUTE_DCOV_ACOV 101
|
||||
#define BCMXCP_ALARM_PHASE_A_CURRENT_LIMIT 102
|
||||
#define BCMXCP_ALARM_PHASE_B_CURRENT_LIMIT 103
|
||||
#define BCMXCP_ALARM_PHASE_C_CURRENT_LIMIT 104
|
||||
#define BCMXCP_ALARM_BYPASS_NOT_AVAILABLE 105
|
||||
#define BCMXCP_ALARM_RECTIFIER_BREAKER_OPEN 106
|
||||
#define BCMXCP_ALARM_BATTERY_CONTACTOR_OPEN 107
|
||||
#define BCMXCP_ALARM_INVERTER_CONTACTOR_OPEN 108
|
||||
#define BCMXCP_ALARM_BYPASS_BREAKER_OPEN 109
|
||||
#define BCMXCP_ALARM_INV_BOARD_ACOV_INT_TEST_FAIL 110
|
||||
#define BCMXCP_ALARM_INVERTER_OVER_TEMP_TRIP 111
|
||||
#define BCMXCP_ALARM_INV_BOARD_ACUV_INT_TEST_FAIL 112
|
||||
#define BCMXCP_ALARM_INVERTER_VOLTAGE_FEEDBACK_ERROR 113
|
||||
#define BCMXCP_ALARM_DC_UNDER_VOLTAGE_TIMEOUT 114
|
||||
#define BCMXCP_ALARM_AC_UNDER_VOLTAGE_TIMEOUT 115
|
||||
#define BCMXCP_ALARM_DC_UNDER_VOLTAGE_WHILE_CHARGE 116
|
||||
#define BCMXCP_ALARM_INVERTER_VOLTAGE_BIAS_ERROR 117
|
||||
#define BCMXCP_ALARM_RECTIFIER_PHASE_ROTATION 118
|
||||
#define BCMXCP_ALARM_BYPASS_PHASER_ROTATION 119
|
||||
#define BCMXCP_ALARM_SYSTEM_INTERFACE_BOARD_FAIL 120
|
||||
#define BCMXCP_ALARM_PARALLEL_BOARD_FAIL 121
|
||||
#define BCMXCP_ALARM_LOST_LOAD_SHARING_PHASE_A 122
|
||||
#define BCMXCP_ALARM_LOST_LOAD_SHARING_PHASE_B 123
|
||||
#define BCMXCP_ALARM_LOST_LOAD_SHARING_PHASE_C 124
|
||||
#define BCMXCP_ALARM_DC_OVER_VOLTAGE_TIMEOUT 125
|
||||
#define BCMXCP_ALARM_BATTERY_TOTALLY_DISCHARGED 126
|
||||
#define BCMXCP_ALARM_INVERTER_PHASE_BIAS_ERROR 127
|
||||
#define BCMXCP_ALARM_INVERTER_VOLTAGE_BIAS_ERROR_2 128
|
||||
#define BCMXCP_ALARM_DC_LINK_BLEED_COMPLETE 129
|
||||
#define BCMXCP_ALARM_LARGE_CHARGER_INPUT_CURRENT 130
|
||||
#define BCMXCP_ALARM_INV_VOLT_TOO_LOW_FOR_RAMP_LEVEL 131
|
||||
#define BCMXCP_ALARM_LOSS_OF_REDUNDANCY 132
|
||||
#define BCMXCP_ALARM_LOSS_OF_SYNC_BUS 133
|
||||
#define BCMXCP_ALARM_RECTIFIER_BREAKER_SHUNT_TRIP 134
|
||||
#define BCMXCP_ALARM_LOSS_OF_CHARGER_SYNC 135
|
||||
#define BCMXCP_ALARM_INVERTER_LOW_LEVEL_TEST_TIMEOUT 136
|
||||
#define BCMXCP_ALARM_OUTPUT_BREAKER_OPEN 137
|
||||
#define BCMXCP_ALARM_CONTROL_POWER_ON 138
|
||||
#define BCMXCP_ALARM_INVERTER_ON 139
|
||||
#define BCMXCP_ALARM_CHARGER_ON 140
|
||||
#define BCMXCP_ALARM_BYPASS_ON 141
|
||||
#define BCMXCP_ALARM_BYPASS_POWER_LOSS 142
|
||||
#define BCMXCP_ALARM_ON_MANUAL_BYPASS 143
|
||||
#define BCMXCP_ALARM_BYPASS_MANUAL_TURN_OFF 144
|
||||
#define BCMXCP_ALARM_INVERTER_BLEEDING_DC_LINK_VOLT 145
|
||||
#define BCMXCP_ALARM_CPU_ISR_ERROR 146
|
||||
#define BCMXCP_ALARM_SYSTEM_ISR_RESTART 147
|
||||
#define BCMXCP_ALARM_PARALLEL_DC 148
|
||||
#define BCMXCP_ALARM_BATTERY_NEEDS_SERVICE 149
|
||||
#define BCMXCP_ALARM_BATTERY_CHARGING 150
|
||||
#define BCMXCP_ALARM_BATTERY_NOT_CHARGED 151
|
||||
#define BCMXCP_ALARM_DISABLED_BATTERY_TIME 152
|
||||
#define BCMXCP_ALARM_SERIES_7000_ENABLE 153
|
||||
#define BCMXCP_ALARM_OTHER_UPS_ON 154
|
||||
#define BCMXCP_ALARM_PARALLEL_INVERTER 155
|
||||
#define BCMXCP_ALARM_UPS_IN_PARALLEL 156
|
||||
#define BCMXCP_ALARM_OUTPUT_BREAKER_REALY_FAIL 157
|
||||
#define BCMXCP_ALARM_CONTROL_POWER_OFF 158
|
||||
#define BCMXCP_ALARM_LEVEL_2_OVERLOAD_PHASE_A 159
|
||||
#define BCMXCP_ALARM_LEVEL_2_OVERLOAD_PHASE_B 160
|
||||
#define BCMXCP_ALARM_LEVEL_2_OVERLOAD_PHASE_C 161
|
||||
#define BCMXCP_ALARM_LEVEL_3_OVERLOAD_PHASE_A 162
|
||||
#define BCMXCP_ALARM_LEVEL_3_OVERLOAD_PHASE_B 163
|
||||
#define BCMXCP_ALARM_LEVEL_3_OVERLOAD_PHASE_C 164
|
||||
#define BCMXCP_ALARM_LEVEL_4_OVERLOAD_PHASE_A 165
|
||||
#define BCMXCP_ALARM_LEVEL_4_OVERLOAD_PHASE_B 166
|
||||
#define BCMXCP_ALARM_LEVEL_4_OVERLOAD_PHASE_C 167
|
||||
#define BCMXCP_ALARM_UPS_ON_BATTERY 168
|
||||
#define BCMXCP_ALARM_UPS_ON_BYPASS 169
|
||||
#define BCMXCP_ALARM_LOAD_DUMPED 170
|
||||
#define BCMXCP_ALARM_LOAD_ON_INVERTER 171
|
||||
#define BCMXCP_ALARM_UPS_ON_COMMAND 172
|
||||
#define BCMXCP_ALARM_UPS_OFF_COMMAND 173
|
||||
#define BCMXCP_ALARM_LOW_BATTERY_SHUTDOWN 174
|
||||
#define BCMXCP_ALARM_AUTO_ON_ENABLED 175
|
||||
#define BCMXCP_ALARM_SOFTWARE_INCOMPABILITY_DETECTED 176
|
||||
#define BCMXCP_ALARM_INVERTER_TEMP_SENSOR_FAILED 177
|
||||
#define BCMXCP_ALARM_DC_START_OCCURED 178
|
||||
#define BCMXCP_ALARM_IN_PARALLEL_OPERATION 179
|
||||
#define BCMXCP_ALARM_SYNCING_TO_BYPASS 180
|
||||
#define BCMXCP_ALARM_RAMPING_UPS_UP 181
|
||||
#define BCMXCP_ALARM_INVERTER_ON_DELAY 182
|
||||
#define BCMXCP_ALARM_CHARGER_ON_DELAY 183
|
||||
#define BCMXCP_ALARM_WAITING_FOR_UTIL_INPUT 184
|
||||
#define BCMXCP_ALARM_CLOSE_BYPASS_BREAKER 185
|
||||
#define BCMXCP_ALARM_TEMPORARY_BYPASS_OPERATION 186
|
||||
#define BCMXCP_ALARM_SYNCING_TO_OUTPUT 187
|
||||
#define BCMXCP_ALARM_BYPASS_FAILURE 188
|
||||
#define BCMXCP_ALARM_AUTO_OFF_COMMAND_EXECUTED 189
|
||||
#define BCMXCP_ALARM_AUTO_ON_COMMAND_EXECUTED 190
|
||||
#define BCMXCP_ALARM_BATTERY_TEST_FAILED 191
|
||||
#define BCMXCP_ALARM_FUSE_FAIL 192
|
||||
#define BCMXCP_ALARM_FAN_FAIL 193
|
||||
#define BCMXCP_ALARM_SITE_WIRING_FAULT 194
|
||||
#define BCMXCP_ALARM_BACKFEED_CONTACTOR_FAIL 195
|
||||
#define BCMXCP_ALARM_ON_BUCK 196
|
||||
#define BCMXCP_ALARM_ON_BOOST 197
|
||||
#define BCMXCP_ALARM_ON_DOUBLE_BOOST 198
|
||||
#define BCMXCP_ALARM_BATTERIES_DISCONNECTED 199
|
||||
#define BCMXCP_ALARM_UPS_CABINET_OVER_TEMP 200
|
||||
#define BCMXCP_ALARM_TRANSFORMER_OVER_TEMP 201
|
||||
#define BCMXCP_ALARM_AMBIENT_UNDER_TEMP 202
|
||||
#define BCMXCP_ALARM_AMBIENT_OVER_TEMP 203
|
||||
#define BCMXCP_ALARM_CABINET_DOOR_OPEN 204
|
||||
#define BCMXCP_ALARM_CABINET_DOOR_OPEN_VOLT_PRESENT 205
|
||||
#define BCMXCP_ALARM_AUTO_SHUTDOWN_PENDING 206
|
||||
#define BCMXCP_ALARM_TAP_SWITCHING_REALY_PENDING 207
|
||||
#define BCMXCP_ALARM_UNABLE_TO_CHARGE_BATTERIES 208
|
||||
#define BCMXCP_ALARM_STARTUP_FAILURE_CHECK_EPO 209
|
||||
#define BCMXCP_ALARM_AUTOMATIC_STARTUP_PENDING 210
|
||||
#define BCMXCP_ALARM_MODEM_FAILED 211
|
||||
#define BCMXCP_ALARM_INCOMING_MODEM_CALL_STARTED 212
|
||||
#define BCMXCP_ALARM_OUTGOING_MODEM_CALL_STARTED 213
|
||||
#define BCMXCP_ALARM_MODEM_CONNECTION_ESTABLISHED 214
|
||||
#define BCMXCP_ALARM_MODEM_CALL_COMPLETED_SUCCESS 215
|
||||
#define BCMXCP_ALARM_MODEM_CALL_COMPLETED_FAIL 216
|
||||
#define BCMXCP_ALARM_INPUT_BREAKER_FAIL 217
|
||||
#define BCMXCP_ALARM_SYSINIT_IN_PROGRESS 218
|
||||
#define BCMXCP_ALARM_AUTOCALIBRATION_FAIL 219
|
||||
#define BCMXCP_ALARM_SELECTIVE_TRIP_OF_MODULE 220
|
||||
#define BCMXCP_ALARM_INVERTER_OUTPUT_FAILURE 221
|
||||
#define BCMXCP_ALARM_ABNORMAL_OUTPUT_VOLT_AT_STARTUP 222
|
||||
#define BCMXCP_ALARM_RECTIFIER_OVER_TEMP 223
|
||||
#define BCMXCP_ALARM_CONFIG_ERROR 224
|
||||
#define BCMXCP_ALARM_REDUNDANCY_LOSS_DUE_TO_OVERLOAD 225
|
||||
#define BCMXCP_ALARM_ON_ALTERNATE_AC_SOURCE 226
|
||||
#define BCMXCP_ALARM_IN_HIGH_EFFICIENCY_MODE 227
|
||||
#define BCMXCP_ALARM_SYSTEM_NOTICE_ACTIVE 228
|
||||
#define BCMXCP_ALARM_SYSTEM_ALARM_ACTIVE 229
|
||||
#define BCMXCP_ALARM_ALTERNATE_POWER_SOURCE_NOT_AVAILABLE 230
|
||||
#define BCMXCP_ALARM_CURRENT_BALANCE_FAILURE 231
|
||||
#define BCMXCP_ALARM_CHECK_AIR_FILTER 232
|
||||
#define BCMXCP_ALARM_SUBSYSTEM_NOTICE_ACTIVE 233
|
||||
#define BCMXCP_ALARM_SUBSYSTEM_ALARM_ACTIVE 234
|
||||
#define BCMXCP_ALARM_CHARGER_ON_COMMAND 235
|
||||
#define BCMXCP_ALARM_CHARGER_OFF_COMMAND 236
|
||||
#define BCMXCP_ALARM_UPS_NORMAL 237
|
||||
#define BCMXCP_ALARM_INVERTER_PHASE_ROTATION 238
|
||||
#define BCMXCP_ALARM_UPS_OFF 239
|
||||
#define BCMXCP_ALARM_EXTERNAL_COMMUNICATION_FAILURE 240
|
||||
#define BCMXCP_ALARM_BATTERY_TEST_INPROGRESS 256
|
||||
#define BCMXCP_ALARM_SYSTEM_TEST_INPROGRESS 257
|
||||
#define BCMXCP_ALARM_BATTERY_TEST_ABORTED 258
|
||||
|
||||
#define BCMXCP_METER_MAP_MAX 91 /* Max no of entries in BCM/XCP meter map */
|
||||
#define BCMXCP_ALARM_MAP_MAX 260 /* Max no of entries in BCM/XCP alarm map (adjusted upwards to nearest multi of 8 */
|
||||
#define BCMXCP_COMMAND_MAP_MAX 208 /* Max no of entries in BCM/XCP meter map (adjusted upwards to nearest multi of 8) */
|
||||
#define BCMXCP_METER_MAP_MAX 136 /* Max no of entries in BCM/XCP meter map (adjusted upwards to nearest multi of 8) */
|
||||
#define BCMXCP_ALARM_MAP_MAX 264 /* Max no of entries in BCM/XCP alarm map (adjusted upwards to nearest multi of 8) */
|
||||
|
||||
/* Return codes for XCP ACK block responses */
|
||||
#define BCMXCP_RETURN_ACCEPTED 0x31 /* Accepted and executed (or execution in progress) */
|
||||
#define BCMXCP_RETURN_NOT_IMPLEMENTED 0x32 /* Recognized but not implemented */
|
||||
#define BCMXCP_RETURN_BUSY 0x33 /* Recognized but not currently able to execute (busy) */
|
||||
#define BCMXCP_RETURN_UNRECOGNISED 0x34 /* Unrecognized -- e.g., command byte not in valid range, or command has been corrupted (bad checksum) */
|
||||
#define BCMXCP_RETURN_PARAMETER_OUT_OF_RANGE 0x35 /* Command recognized, but its Parameter value is out of range */
|
||||
#define BCMXCP_RETURN_INVALID_PARAMETER 0x36 /* Command recognized, but its Parameter is invalid (e.g., no such parameter, bad Outlet number) */
|
||||
#define BCMXCP_RETURN_ACCEPTED_PARAMETER_ADJUST 0x37 /* Accepted, with parameter adjusted to nearest good value */
|
||||
/*#define BCMXCP_RETURN_READONLY 0x38 */ /* Parameter is Read-only - cannot be written (at this privilege level) (this is not listed in spec document */
|
||||
|
||||
/* UPS status */
|
||||
#define BCMXCP_STATUS_ONLINE 0x50
|
||||
#define BCMXCP_STATUS_ONBATTERY 0xf0
|
||||
#define BCMXCP_STATUS_OVERLOAD 0xe0
|
||||
#define BCMXCP_STATUS_TRIM 0x63
|
||||
#define BCMXCP_STATUS_BOOST1 0x61
|
||||
#define BCMXCP_STATUS_BOOST2 0x62
|
||||
#define BCMXCP_STATUS_BYPASS 0x60
|
||||
#define BCMXCP_STATUS_OFF 0x10
|
||||
|
||||
/* UPS topology block info */
|
||||
#define BCMXCP_TOPOLOGY_NONE 0x0000 /* None; use the Table of Elements */
|
||||
#define BCMXCP_TOPOLOGY_OFFLINE_SWITCHER_1P 0x0010 /* Off-line switcher, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_LINEINT_UPS_1P 0x0020 /* Line-Interactive UPS, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_LINEINT_UPS_2P 0x0021 /* Line-Interactive UPS, Two Phase */
|
||||
#define BCMXCP_TOPOLOGY_LINEINT_UPS_3P 0x0022 /* Line-Interactive UPS, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_DUAL_AC_ONLINE_UPS_1P 0x0030 /* Dual AC Input, On-Line UPS, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_DUAL_AC_ONLINE_UPS_2P 0x0031 /* Dual AC Input, On-Line UPS, Two Phase */
|
||||
#define BCMXCP_TOPOLOGY_DUAL_AC_ONLINE_UPS_3P 0x0032 /* Dual AC Input, On-Line UPS, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_ONLINE_UPS_1P 0x0040 /* On-Line UPS, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_ONLINE_UPS_2P 0x0041 /* On-Line UPS, Two Phase */
|
||||
#define BCMXCP_TOPOLOGY_ONLINE_UPS_3P 0x0042 /* On-Line UPS, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_PARA_REDUND_ONLINE_UPS_1P 0x0050 /* Parallel Redundant On-Line UPS, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_PARA_REDUND_ONLINE_UPS_2P 0x0051 /* Parallel Redundant On-Line UPS, Two Phase */
|
||||
#define BCMXCP_TOPOLOGY_PARA_REDUND_ONLINE_UPS_3P 0x0052 /* Parallel Redundant On-Line UPS, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_PARA_CAPACITY_ONLINE_UPS_1P 0x0060 /* Parallel for Capacity On-Line UPS, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_PARA_CAPACITY_ONLINE_UPS_2P 0x0061 /* Parallel for Capacity On-Line UPS, Two Phase */
|
||||
#define BCMXCP_TOPOLOGY_PARA_CAPACITY_ONLINE_UPS_3P 0x0062 /* Parallel for Capacity On-Line UPS, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_SYSTEM_BYPASS_MODULE_3P 0x0102 /* System Bypass Module, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_HOT_TIE_CABINET_3P 0x0122 /* Hot-Tie Cabinet, Three Phase */
|
||||
#define BCMXCP_TOPOLOGY_OUTLET_CONTROLLER_1P 0x0200 /* Outlet Controller, Single Phase */
|
||||
#define BCMXCP_TOPOLOGY_DUAL_AC_STATIC_SWITCH_3P 0x0222 /* Dual AC Input Static Switch Module, 3 Phase */
|
||||
|
||||
typedef struct { /* Entry in BCM/XCP - UPS mapping table */
|
||||
const char *command_desc; /* Description of this command */
|
||||
unsigned char command_byte; /* The command byte for this command, 0 = not supported */
|
||||
} BCMXCP_COMMAND_MAP_ENTRY_t;
|
||||
|
||||
extern BCMXCP_COMMAND_MAP_ENTRY_t bcmxcp_command_map[BCMXCP_COMMAND_MAP_MAX];
|
||||
|
||||
typedef struct { /* Entry in BCM/XCP - UPS - NUT mapping table */
|
||||
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;
|
||||
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;
|
||||
|
||||
extern BCMXCP_METER_MAP_ENTRY_t
|
||||
bcmxcp_meter_map[BCMXCP_METER_MAP_MAX];
|
||||
extern BCMXCP_METER_MAP_ENTRY_t bcmxcp_meter_map[BCMXCP_METER_MAP_MAX];
|
||||
|
||||
typedef struct { /* Entry in BCM/XCP - UPS mapping table */
|
||||
int alarm_block_index; /* Index of this alarm in alarm block. -1 = not existing */
|
||||
const char *alarm_desc; /* Description of this alarm */
|
||||
} BCMXCP_ALARM_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 */
|
||||
const char *alarm_desc; /* Description of this alarm */
|
||||
} BCMXCP_ALARM_MAP_ENTRY_t;
|
||||
|
||||
extern BCMXCP_ALARM_MAP_ENTRY_t
|
||||
bcmxcp_alarm_map[BCMXCP_ALARM_MAP_MAX];
|
||||
extern BCMXCP_ALARM_MAP_ENTRY_t bcmxcp_alarm_map[BCMXCP_ALARM_MAP_MAX];
|
||||
|
||||
typedef struct { /* A place to store status info and other data not for NUT */
|
||||
unsigned char topology_mask; /* Configuration block byte 16, masks valid status bits */
|
||||
unsigned int lowbatt; /* Seconds of runtime left left when LB alarm is set */
|
||||
unsigned int shutdowndelay; /* Shutdown delay in seconds, from ups.conf */
|
||||
int alarm_on_battery; /* On Battery alarm active? */
|
||||
int alarm_low_battery; /* Battery Low alarm active? */
|
||||
int alarm_replace_battery; /* Battery needs replacement! */
|
||||
} BCMXCP_STATUS_t;
|
||||
typedef struct { /* A place to store status info and other data not for NUT */
|
||||
unsigned char topology_mask; /* Configuration block byte 16, masks valid status bits */
|
||||
unsigned int lowbatt; /* Seconds of runtime left left when LB alarm is set */
|
||||
unsigned int shutdowndelay; /* Shutdown delay in seconds, from ups.conf */
|
||||
int alarm_on_battery; /* On Battery alarm active? */
|
||||
int alarm_low_battery; /* Battery Low alarm active? */
|
||||
int alarm_replace_battery; /* Battery needs replacement! */
|
||||
} BCMXCP_STATUS_t;
|
||||
|
||||
extern BCMXCP_STATUS_t
|
||||
bcmxcp_status;
|
||||
extern BCMXCP_STATUS_t bcmxcp_status;
|
||||
|
||||
int checksum_test(const unsigned char*);
|
||||
unsigned char calc_checksum(const unsigned char *buf);
|
||||
|
||||
/* from usbhid-ups.h */
|
||||
typedef struct {
|
||||
const long xcp_value; /* XCP value */
|
||||
const char *nut_value; /* NUT value */
|
||||
const char *(*fun)(double xcp_value); /* optional XCP to NUT mapping */
|
||||
double (*nuf)(const char *nut_value); /* optional NUT to HID mapping */
|
||||
const long xcp_value; /* XCP value */
|
||||
const char *nut_value; /* NUT value */
|
||||
const char *(*fun)(double xcp_value); /* optional XCP to NUT mapping */
|
||||
double (*nuf)(const char *nut_value); /* optional NUT to HID mapping */
|
||||
} info_lkp_t;
|
||||
|
||||
/* use explicit booleans */
|
||||
#ifndef FALSE
|
||||
typedef enum ebool { FALSE, TRUE } bool_t;
|
||||
#else
|
||||
typedef int bool_t;
|
||||
#endif
|
||||
|
||||
#endif /*_POWERWARE_H */
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef BCMXCP_IO__
|
||||
#define BCMXCP_IO__
|
||||
|
||||
#include "main.h" /* for usbdrv_info_t */
|
||||
#include "main.h" /* for usbdrv_info_t */
|
||||
|
||||
void send_read_command(unsigned char command);
|
||||
void send_write_command(unsigned char *command, int command_length);
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
#include "bcmxcp_io.h"
|
||||
#include "serial.h"
|
||||
|
||||
#define PW_MAX_BAUD 5
|
||||
|
||||
#define SUBDRIVER_NAME "RS-232 communication subdriver"
|
||||
#define SUBDRIVER_VERSION "0.19"
|
||||
#define SUBDRIVER_NAME "RS-232 communication subdriver"
|
||||
#define SUBDRIVER_VERSION "0.20"
|
||||
|
||||
/* communication driver description structure */
|
||||
upsdrv_info_t comm_upsdrv_info = {
|
||||
|
@ -17,23 +16,27 @@ upsdrv_info_t comm_upsdrv_info = {
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
#define PW_MAX_BAUD 5
|
||||
|
||||
struct pw_baud_rate {
|
||||
int rate;
|
||||
int name;
|
||||
} pw_baud_rates[] = {
|
||||
{ B1200, 1200 },
|
||||
{ B2400, 2400 },
|
||||
{ B4800, 4800 },
|
||||
{ B9600, 9600 },
|
||||
{ B19200, 19200 },
|
||||
{ B9600, 9600 },
|
||||
{ B4800, 4800 },
|
||||
{ B2400, 2400 },
|
||||
{ B1200, 1200 },
|
||||
/* end of structure. */
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
unsigned char AUT[4] = {0xCF, 0x69, 0xE8, 0xD5}; /* Autorisation command */
|
||||
unsigned char AUT[4] = {0xCF, 0x69, 0xE8, 0xD5}; /* Autorisation command */
|
||||
|
||||
static void send_command(unsigned char *command, int command_length)
|
||||
{
|
||||
int retry = 0, sent;
|
||||
unsigned char sbuf[128];
|
||||
int retry = 0, sent;
|
||||
unsigned char sbuf[128];
|
||||
|
||||
/* Prepare the send buffer */
|
||||
sbuf[0] = PW_COMMAND_START_BYTE;
|
||||
|
@ -50,7 +53,7 @@ static void send_command(unsigned char *command, int command_length)
|
|||
while (retry++ < PW_MAX_TRY) {
|
||||
|
||||
if (retry == PW_MAX_TRY) {
|
||||
ser_send_char(upsfd, 0x1d); /* last retry is preceded by a ESC.*/
|
||||
ser_send_char(upsfd, 0x1d); /* last retry is preceded by a ESC.*/
|
||||
usleep(250000);
|
||||
}
|
||||
|
||||
|
@ -75,7 +78,7 @@ void send_write_command(unsigned char *command, int command_length)
|
|||
/* get the answer of a command from the ups. And check that the answer is for this command */
|
||||
int get_answer(unsigned char *data, unsigned char command)
|
||||
{
|
||||
unsigned char my_buf[128]; /* packet has a maximum length of 121+5 bytes */
|
||||
unsigned char my_buf[128]; /* packet has a maximum length of 121+5 bytes */
|
||||
int length, end_length = 0, res, endblock = 0, start = 0;
|
||||
unsigned char block_number, sequence, pre_sequence = 0;
|
||||
|
||||
|
@ -199,7 +202,7 @@ int get_answer(unsigned char *data, unsigned char command)
|
|||
|
||||
static int command_sequence(unsigned char *command, int command_length, unsigned char *answer)
|
||||
{
|
||||
int bytes_read, retry = 0;
|
||||
int bytes_read, retry = 0;
|
||||
|
||||
while (retry++ < PW_MAX_TRY) {
|
||||
|
||||
|
@ -222,7 +225,7 @@ static int command_sequence(unsigned char *command, int command_length, unsigned
|
|||
/* Sends a single command (length=1). and get the answer */
|
||||
int command_read_sequence(unsigned char command, unsigned char *answer)
|
||||
{
|
||||
int bytes_read;
|
||||
int bytes_read;
|
||||
|
||||
bytes_read = command_sequence(&command, 1, answer);
|
||||
|
||||
|
@ -236,7 +239,7 @@ int command_read_sequence(unsigned char command, unsigned char *answer)
|
|||
/* Sends a setup command (length > 1) */
|
||||
int command_write_sequence(unsigned char *command, int command_length, unsigned char *answer)
|
||||
{
|
||||
int bytes_read;
|
||||
int bytes_read;
|
||||
|
||||
bytes_read = command_sequence(command, command_length, answer);
|
||||
|
||||
|
@ -254,10 +257,10 @@ void upsdrv_comm_good()
|
|||
|
||||
void pw_comm_setup(const char *port)
|
||||
{
|
||||
unsigned char command = PW_SET_REQ_ONLY_MODE;
|
||||
unsigned char id_command = PW_ID_BLOCK_REQ;
|
||||
unsigned char answer[256];
|
||||
int i = 0, baud, mybaud = 0, ret = -1;
|
||||
unsigned char command = PW_SET_REQ_ONLY_MODE;
|
||||
unsigned char id_command = PW_ID_BLOCK_REQ;
|
||||
unsigned char answer[256];
|
||||
int i = 0, baud, mybaud = 0, ret = -1;
|
||||
|
||||
if (getval("baud_rate") != NULL)
|
||||
{
|
||||
|
@ -275,7 +278,7 @@ void pw_comm_setup(const char *port)
|
|||
}
|
||||
|
||||
ser_set_speed(upsfd, device_path, mybaud);
|
||||
ser_send_char(upsfd, 0x1d); /* send ESC to take it out of menu */
|
||||
ser_send_char(upsfd, 0x1d); /* send ESC to take it out of menu */
|
||||
usleep(90000);
|
||||
send_write_command(AUT, 4);
|
||||
usleep(500000);
|
||||
|
@ -298,7 +301,7 @@ void pw_comm_setup(const char *port)
|
|||
for (i=0; i<PW_MAX_BAUD; i++) {
|
||||
|
||||
ser_set_speed(upsfd, device_path, pw_baud_rates[i].rate);
|
||||
ser_send_char(upsfd, 0x1d); /* send ESC to take it out of menu */
|
||||
ser_send_char(upsfd, 0x1d); /* send ESC to take it out of menu */
|
||||
usleep(90000);
|
||||
send_write_command(AUT, 4);
|
||||
usleep(500000);
|
||||
|
@ -334,3 +337,4 @@ void upsdrv_cleanup(void)
|
|||
void upsdrv_reconnect(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include <unistd.h>
|
||||
#include <usb.h>
|
||||
|
||||
#define SUBDRIVER_NAME "USB communication subdriver"
|
||||
#define SUBDRIVER_VERSION "0.21"
|
||||
#define SUBDRIVER_NAME "USB communication subdriver"
|
||||
#define SUBDRIVER_VERSION "0.22"
|
||||
|
||||
/* communication driver description structure */
|
||||
upsdrv_info_t comm_upsdrv_info = {
|
||||
|
@ -26,13 +26,13 @@ upsdrv_info_t comm_upsdrv_info = {
|
|||
#define MAX_TRY 4
|
||||
|
||||
/* Powerware */
|
||||
#define POWERWARE 0x0592
|
||||
#define POWERWARE 0x0592
|
||||
|
||||
/* Phoenixtec Power Co., Ltd */
|
||||
#define PHOENIXTEC 0x06da
|
||||
#define PHOENIXTEC 0x06da
|
||||
|
||||
/* Hewlett Packard */
|
||||
#define HP_VENDORID 0x03f0
|
||||
#define HP_VENDORID 0x03f0
|
||||
|
||||
/* USB functions */
|
||||
usb_dev_handle *nutusb_open(const char *port);
|
||||
|
@ -51,7 +51,7 @@ static int usb_set_powerware(usb_dev_handle *udev, unsigned char type, unsigned
|
|||
return usb_control_msg(udev, USB_ENDPOINT_OUT, USB_REQ_SET_DESCRIPTOR, (type << 8) + index, 0, buf, size, 1000);
|
||||
}
|
||||
|
||||
static void *powerware_ups(void) {
|
||||
static void *powerware_ups(USBDevice_t *device) {
|
||||
usb_set_descriptor = &usb_set_powerware;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ static int usb_set_phoenixtec(usb_dev_handle *udev, unsigned char type, unsigned
|
|||
return usb_control_msg(udev, 0x42, 0x0d, (0x00 << 8) + 0x0, 0, buf, size, 1000);
|
||||
}
|
||||
|
||||
static void *phoenixtec_ups(void) {
|
||||
static void *phoenixtec_ups(USBDevice_t *device) {
|
||||
usb_set_descriptor = &usb_set_phoenixtec;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -85,14 +85,14 @@ static usb_device_id_t pw_usb_device_table[] = {
|
|||
};
|
||||
|
||||
/* limit the amount of spew that goes in the syslog when we lose the UPS */
|
||||
#define USB_ERR_LIMIT 10 /* start limiting after 10 in a row */
|
||||
#define USB_ERR_RATE 10 /* then only print every 10th error */
|
||||
#define USB_ERR_LIMIT 10 /* start limiting after 10 in a row */
|
||||
#define USB_ERR_RATE 10 /* then only print every 10th error */
|
||||
#define XCP_USB_TIMEOUT 5000
|
||||
|
||||
/* global variables */
|
||||
usb_dev_handle *upsdev = NULL;
|
||||
extern int exit_flag;
|
||||
static unsigned int comm_failures = 0;
|
||||
extern int exit_flag;
|
||||
static unsigned int comm_failures = 0;
|
||||
|
||||
/* Functions implementations */
|
||||
void send_read_command(unsigned char command)
|
||||
|
@ -139,13 +139,13 @@ int get_answer(unsigned char *data, unsigned char command)
|
|||
if (upsdev == NULL)
|
||||
return -1;
|
||||
|
||||
length = 1; /* non zero to enter the read loop */
|
||||
end_length = 0; /* total length of sequence(s), not counting header(s) */
|
||||
endblock = 0; /* signal the last sequence in the block */
|
||||
bytes_read = 0; /* total length of data read, including XCP header */
|
||||
length = 1; /* non zero to enter the read loop */
|
||||
end_length = 0; /* total length of sequence(s), not counting header(s) */
|
||||
endblock = 0; /* signal the last sequence in the block */
|
||||
bytes_read = 0; /* total length of data read, including XCP header */
|
||||
res = 0;
|
||||
ellapsed_time = 0;
|
||||
seq_num = 1; /* current theoric sequence */
|
||||
seq_num = 1; /* current theoric sequence */
|
||||
|
||||
upsdebugx(1, "entering get_answer(%x)", command);
|
||||
|
||||
|
@ -155,7 +155,7 @@ int get_answer(unsigned char *data, unsigned char command)
|
|||
while ( (!endblock) && ((XCP_USB_TIMEOUT - ellapsed_time) > 0) ) {
|
||||
|
||||
/* Get (more) data if needed */
|
||||
if ((length - bytes_read) > 0) {
|
||||
if ((length - (bytes_read - 5)) > 0) {
|
||||
res = usb_interrupt_read(upsdev, 0x81,
|
||||
(char *)&buf[bytes_read],
|
||||
(PW_ANSWER_MAX_SIZE - bytes_read),
|
||||
|
@ -295,7 +295,7 @@ int command_read_sequence(unsigned char command, unsigned char *data)
|
|||
}
|
||||
|
||||
/* Sends a setup command (length > 1) */
|
||||
int command_write_sequence(unsigned char *command, int command_length, unsigned char *answer)
|
||||
int command_write_sequence(unsigned char *command, int command_length, unsigned char *answer)
|
||||
{
|
||||
int bytes_read = 0;
|
||||
int retry = 0;
|
||||
|
@ -335,7 +335,10 @@ void upsdrv_cleanup(void)
|
|||
|
||||
void upsdrv_reconnect(void)
|
||||
{
|
||||
upslogx(LOG_WARNING, "RECONNECT USB DEVICE\n");
|
||||
upsdebugx(4, "==================================================");
|
||||
upsdebugx(4, "= device has been disconnected, try to reconnect =");
|
||||
upsdebugx(4, "==================================================");
|
||||
|
||||
nutusb_close(upsdev, "USB");
|
||||
upsdev = NULL;
|
||||
upsdrv_initups();
|
||||
|
@ -359,7 +362,8 @@ static usb_dev_handle *open_powerware_usb(void)
|
|||
{
|
||||
struct usb_bus *busses = usb_get_busses();
|
||||
struct usb_bus *bus;
|
||||
|
||||
USBDevice_t curDevice;
|
||||
|
||||
for (bus = busses; bus; bus = bus->next)
|
||||
{
|
||||
struct usb_device *dev;
|
||||
|
@ -370,8 +374,18 @@ static usb_dev_handle *open_powerware_usb(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (is_usb_device_supported(pw_usb_device_table,
|
||||
dev->descriptor.idVendor, dev->descriptor.idProduct) == SUPPORTED) {
|
||||
curDevice.VendorID = dev->descriptor.idVendor;
|
||||
curDevice.ProductID = dev->descriptor.idProduct;
|
||||
curDevice.Bus = strdup(bus->dirname);
|
||||
|
||||
/* FIXME: we should also retrieve
|
||||
* dev->descriptor.iManufacturer
|
||||
* dev->descriptor.iProduct
|
||||
* dev->descriptor.iSerialNumber
|
||||
* as in libusb.c->libusb_open()
|
||||
* This is part of the things to put in common... */
|
||||
|
||||
if (is_usb_device_supported(pw_usb_device_table, &curDevice) == SUPPORTED) {
|
||||
return usb_open(dev);
|
||||
}
|
||||
}
|
||||
|
@ -463,13 +477,13 @@ int nutusb_close(usb_dev_handle *dev_h, const char *port)
|
|||
|
||||
void nutusb_comm_fail(const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
char why[SMALLBUF];
|
||||
va_list ap;
|
||||
int ret;
|
||||
char why[SMALLBUF];
|
||||
va_list ap;
|
||||
|
||||
/* this means we're probably here because select was interrupted */
|
||||
if (exit_flag != 0)
|
||||
return; /* ignored, since we're about to exit anyway */
|
||||
return; /* ignored, since we're about to exit anyway */
|
||||
|
||||
comm_failures++;
|
||||
|
||||
|
@ -484,6 +498,7 @@ void nutusb_comm_fail(const char *fmt, ...)
|
|||
if ((comm_failures > USB_ERR_LIMIT) &&
|
||||
((comm_failures % USB_ERR_LIMIT) != 0)) {
|
||||
/* Try reconnection */
|
||||
upsdebugx(1, "Got to reconnect!\n");
|
||||
upsdrv_reconnect();
|
||||
return;
|
||||
}
|
||||
|
@ -514,3 +529,4 @@ void nutusb_comm_good(void)
|
|||
upslogx(LOG_NOTICE, "Communications with UPS re-established");
|
||||
comm_failures = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -568,7 +568,7 @@ static const char *belkin_format_serial(HIDDevice_t *hd) {
|
|||
* the device is supported by this subdriver, else 0. */
|
||||
static int belkin_claim(HIDDevice_t *hd)
|
||||
{
|
||||
int status = is_usb_device_supported(belkin_usb_device_table, hd->VendorID, hd->ProductID);
|
||||
int status = is_usb_device_supported(belkin_usb_device_table, hd);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
|
|
@ -332,7 +332,7 @@ void upsdrv_updateinfo(void)
|
|||
|
||||
/* Compute battery percent left based on battery voltages. */
|
||||
battpercent = ((vbatt - fc.emptyvolts)
|
||||
/ (fc.fullvolts - fc.emptyvolts) * 100.0);
|
||||
/ (fc.idealbvolts - fc.emptyvolts) * 100.0);
|
||||
if (battpercent < 0.0)
|
||||
battpercent = 0.0;
|
||||
else if (battpercent > 100.0)
|
||||
|
|
|
@ -407,6 +407,8 @@ static int blazer_instcmd(const char *cmdname, const char *extra)
|
|||
char buf[SMALLBUF] = "";
|
||||
int i;
|
||||
|
||||
upslogx(LOG_INFO, "instcmd(%s, %s)", cmdname, extra ? extra : "[NULL]");
|
||||
|
||||
for (i = 0; instcmd[i].cmd; i++) {
|
||||
|
||||
if (strcasecmp(cmdname, instcmd[i].cmd)) {
|
||||
|
@ -417,10 +419,14 @@ static int blazer_instcmd(const char *cmdname, const char *extra)
|
|||
|
||||
/*
|
||||
* If a command is invalid, it will be echoed back
|
||||
* As an exception, Best UPS units will report "ACK" in case of success!
|
||||
* Other UPSes will reply "(ACK" in case of success.
|
||||
*/
|
||||
if (blazer_command(buf, buf, sizeof(buf)) > 0) {
|
||||
upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
|
||||
return STAT_INSTCMD_FAILED;
|
||||
if (strncmp(buf, "ACK", 3) && strncmp(buf, "(ACK", 4)) {
|
||||
upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
|
||||
return STAT_INSTCMD_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
upslogx(LOG_INFO, "instcmd: command [%s] handled", cmdname);
|
||||
|
@ -428,28 +434,56 @@ static int blazer_instcmd(const char *cmdname, const char *extra)
|
|||
}
|
||||
|
||||
if (!strcasecmp(cmdname, "shutdown.return")) {
|
||||
|
||||
/*
|
||||
* Sn: Shutdown after n minutes and then turn on when mains is back
|
||||
* SnRm: Shutdown after n minutes and then turn on after m minutes
|
||||
* Accepted values for n: .2 -> .9 , 01 -> 10
|
||||
* Accepted values for m: 0001 -> 9999
|
||||
* Note: "S01R0001" and "S01R0002" may not work on early (GE)
|
||||
* firmware versions. The failure mode is that the UPS turns
|
||||
* off and never returns. The fix is to push the return value
|
||||
* up by 2, i.e. S01R0003, and it will return online properly.
|
||||
* (thus the default of ondelay=3 mins)
|
||||
*/
|
||||
if (offdelay < 60) {
|
||||
|
||||
if (ondelay == 0) {
|
||||
|
||||
if (offdelay < 60) {
|
||||
snprintf(buf, sizeof(buf), "S.%d\r", offdelay / 6);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "S%02d\r", offdelay / 60);
|
||||
}
|
||||
|
||||
} else if (offdelay < 60) {
|
||||
|
||||
snprintf(buf, sizeof(buf), "S.%dR%04d\r", offdelay / 6, ondelay);
|
||||
|
||||
} else {
|
||||
|
||||
snprintf(buf, sizeof(buf), "S%02dR%04d\r", offdelay / 60, ondelay);
|
||||
|
||||
}
|
||||
|
||||
} else if (!strcasecmp(cmdname, "shutdown.stayoff")) {
|
||||
|
||||
/*
|
||||
* SnR0000
|
||||
* Shutdown after n minutes and stay off
|
||||
* Accepted values for n: .2 -> .9 , 01 -> 10
|
||||
*/
|
||||
|
||||
if (offdelay < 60) {
|
||||
snprintf(buf, sizeof(buf), "S.%dR0000\r", offdelay / 6);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "S%02dR0000\r", offdelay / 60);
|
||||
}
|
||||
|
||||
} else if (!strcasecmp(cmdname, "test.battery.start")) {
|
||||
int delay = extra ? strtol(extra, NULL, 10) : 10;
|
||||
|
||||
if ((delay < 0) || (delay > 99)) {
|
||||
if ((delay < 1) || (delay > 99)) {
|
||||
upslogx(LOG_ERR, "instcmd: command [%s] failed, delay [%s] out of range", cmdname, extra);
|
||||
return STAT_INSTCMD_FAILED;
|
||||
}
|
||||
|
||||
|
@ -462,9 +496,10 @@ static int blazer_instcmd(const char *cmdname, const char *extra)
|
|||
/*
|
||||
* If a command is invalid, it will be echoed back.
|
||||
* As an exception, Best UPS units will report "ACK" in case of success!
|
||||
* Other UPSes will reply "(ACK" in case of success.
|
||||
*/
|
||||
if (blazer_command(buf, buf, sizeof(buf)) > 0) {
|
||||
if (strncmp(buf, "ACK", 3)) {
|
||||
if (strncmp(buf, "ACK", 3) && strncmp(buf, "(ACK", 4)) {
|
||||
upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
|
||||
return STAT_INSTCMD_FAILED;
|
||||
}
|
||||
|
@ -509,8 +544,8 @@ void blazer_initups(void)
|
|||
offdelay = strtol(val, NULL, 10);
|
||||
}
|
||||
|
||||
if ((offdelay < 6) || (offdelay > 600)) {
|
||||
fatalx(EXIT_FAILURE, "Shutdown delay '%d' out of range [6..600]", offdelay);
|
||||
if ((offdelay < 12) || (offdelay > 600)) {
|
||||
fatalx(EXIT_FAILURE, "Shutdown delay '%d' out of range [12..600]", offdelay);
|
||||
}
|
||||
|
||||
/* Truncate to nearest setable value */
|
||||
|
@ -538,7 +573,7 @@ static void blazer_initbattery(void)
|
|||
|
||||
/* If no values were provided by the user in ups.conf, try to guesstimate
|
||||
* battery.charge, but announce it! */
|
||||
if ((batt.volt.nom != 1) && (batt.volt.high == -1) && (batt.volt.high == -1)) {
|
||||
if ((batt.volt.nom != 1) && ((batt.volt.high == -1) || (batt.volt.low == -1))) {
|
||||
upslogx(LOG_INFO, "No values provided for battery high/low voltages in ups.conf\n");
|
||||
|
||||
/* Basic formula, which should cover most cases */
|
||||
|
@ -778,17 +813,30 @@ void upsdrv_shutdown(void)
|
|||
{
|
||||
int retry;
|
||||
|
||||
/* Stop pending shutdowns */
|
||||
for (retry = 1; retry <= MAXTRIES; retry++) {
|
||||
|
||||
if (blazer_instcmd("shutdown.stop", NULL) != STAT_INSTCMD_HANDLED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (retry > MAXTRIES) {
|
||||
upslogx(LOG_NOTICE, "No shutdown pending");
|
||||
}
|
||||
|
||||
/* Shutdown */
|
||||
for (retry = 1; retry <= MAXTRIES; retry++) {
|
||||
|
||||
if (blazer_instcmd("shutdown.return", NULL) != STAT_INSTCMD_HANDLED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fatalx(EXIT_SUCCESS, "Shutting down in %d seconds", offdelay);
|
||||
|
||||
}
|
||||
|
||||
fatalx(EXIT_FAILURE, "Shutdown failed!");
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "blazer.h"
|
||||
|
||||
#define DRIVER_NAME "Megatec/Q1 protocol serial driver"
|
||||
#define DRIVER_VERSION "1.55"
|
||||
#define DRIVER_VERSION "1.56"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
|
@ -114,6 +114,7 @@ void upsdrv_makevartable(void)
|
|||
|
||||
void upsdrv_initups(void)
|
||||
{
|
||||
#ifndef TESTING
|
||||
const struct {
|
||||
const char *val;
|
||||
const int dtr;
|
||||
|
@ -129,7 +130,7 @@ void upsdrv_initups(void)
|
|||
int i;
|
||||
|
||||
const char *val;
|
||||
#ifndef TESTING
|
||||
|
||||
struct termios tio;
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "blazer.h"
|
||||
|
||||
#define DRIVER_NAME "Megatec/Q1 protocol USB driver"
|
||||
#define DRIVER_VERSION "0.09"
|
||||
#define DRIVER_VERSION "0.10"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
|
@ -40,6 +40,8 @@ upsdrv_info_t upsdrv_info = {
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
#ifndef TESTING
|
||||
|
||||
static usb_communication_subdriver_t *usb = &usb_subdriver;
|
||||
static usb_dev_handle *udev = NULL;
|
||||
static USBDevice_t usbdevice;
|
||||
|
@ -313,28 +315,28 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen)
|
|||
}
|
||||
|
||||
|
||||
static void *cypress_subdriver(void)
|
||||
static void *cypress_subdriver(USBDevice_t *device)
|
||||
{
|
||||
subdriver_command = &cypress_command;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void *ippon_subdriver(void)
|
||||
static void *ippon_subdriver(USBDevice_t *device)
|
||||
{
|
||||
subdriver_command = &ippon_command;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void *krauler_subdriver(void)
|
||||
static void *krauler_subdriver(USBDevice_t *device)
|
||||
{
|
||||
subdriver_command = &krauler_command;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void *phoenix_subdriver(void)
|
||||
static void *phoenix_subdriver(USBDevice_t *device)
|
||||
{
|
||||
subdriver_command = &phoenix_command;
|
||||
return NULL;
|
||||
|
@ -365,7 +367,7 @@ static int device_match_func(USBDevice_t *hd, void *privdata)
|
|||
return 1;
|
||||
}
|
||||
|
||||
switch (is_usb_device_supported(blazer_usb_id, hd->VendorID, hd->ProductID))
|
||||
switch (is_usb_device_supported(blazer_usb_id, hd))
|
||||
{
|
||||
case SUPPORTED:
|
||||
return 1;
|
||||
|
@ -384,6 +386,8 @@ static USBDeviceMatcher_t device_matcher = {
|
|||
NULL
|
||||
};
|
||||
|
||||
#endif /* TESTING */
|
||||
|
||||
|
||||
/*
|
||||
* Generic command processing function. Send a command and read a reply.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
*
|
||||
* Note: this subdriver was initially generated as a "stub" by the
|
||||
* path-to-subdriver script. It must be customized.
|
||||
* gen-usbhid-subdriver script. It must be customized.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
static double battery_scale = 1;
|
||||
|
||||
static void *cps_battery_scale(void)
|
||||
static void *cps_battery_scale(USBDevice_t *device)
|
||||
{
|
||||
battery_scale = 0.667;
|
||||
return NULL;
|
||||
|
@ -193,8 +193,7 @@ static const char *cps_format_serial(HIDDevice_t *hd) {
|
|||
* the device is supported by this subdriver, else 0. */
|
||||
static int cps_claim(HIDDevice_t *hd) {
|
||||
|
||||
int status = is_usb_device_supported(cps_usb_device_table, hd->VendorID,
|
||||
hd->ProductID);
|
||||
int status = is_usb_device_supported(cps_usb_device_table, hd);
|
||||
|
||||
switch (status) {
|
||||
|
||||
|
|
361
drivers/delta_ups-mib.c
Normal file
361
drivers/delta_ups-mib.c
Normal file
|
@ -0,0 +1,361 @@
|
|||
/* delta_ups-mib.c - subdriver to monitor delta_ups SNMP devices with NUT
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2011 - 2012 Arnaud Quette <arnaud.quette@free.fr>
|
||||
*
|
||||
* Note: this subdriver was initially generated as a "stub" by the
|
||||
* gen-snmp-subdriver.sh script. It must be customized!
|
||||
*
|
||||
* MIB reference: http://www.networkupstools.org/ups-protocols/snmp/DeltaUPSv4.mib
|
||||
*
|
||||
* 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 "delta_ups-mib.h"
|
||||
|
||||
#define DELTA_UPS_MIB_VERSION "0.2"
|
||||
|
||||
#define DELTA_UPS_SYSOID ".1.3.6.1.4.1.2254.2.4"
|
||||
|
||||
/* To create a value lookup structure (as needed on the 2nd line of the example
|
||||
* below), use the following kind of declaration, outside of the present snmp_info_t[]:
|
||||
* static info_lkp_t onbatt_info[] = {
|
||||
* { 1, "OB" },
|
||||
* { 2, "OL" },
|
||||
* { 0, "NULL" }
|
||||
* };
|
||||
*/
|
||||
|
||||
static info_lkp_t delta_ups_upstype_info[] = {
|
||||
{ 1, "on-line" },
|
||||
{ 2, "off-line" },
|
||||
{ 3, "line-interactive" },
|
||||
{ 4, "3phase" },
|
||||
{ 5, "splite-phase" },
|
||||
{ 0, "NULL" }
|
||||
};
|
||||
|
||||
static info_lkp_t delta_ups_pwr_info[] = {
|
||||
{ 0, "OL" }, /* normal */
|
||||
{ 1, "OB" }, /* battery */
|
||||
{ 2, "BYPASS" }, /* bypass */
|
||||
{ 3, "TRIM" }, /* reducing */
|
||||
{ 4, "BOOST" }, /* boosting */
|
||||
{ 5, "BYPASS" }, /* manualBypass */
|
||||
/*{ 6, "NULL" },*/ /* other */
|
||||
{ 7, "OFF" }, /* none */
|
||||
{ 0, "NULL" }
|
||||
} ;
|
||||
|
||||
/* DELTA_UPS Snmp2NUT lookup table */
|
||||
static snmp_info_t delta_ups_mib[] = {
|
||||
|
||||
/* Data format:
|
||||
* { info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar },
|
||||
*
|
||||
* info_type: NUT INFO_ or CMD_ element name
|
||||
* info_flags: flags to set in addinfo
|
||||
* info_len: length of strings if STR
|
||||
* cmd value if CMD, multiplier otherwise
|
||||
* OID: SNMP OID or NULL
|
||||
* dfl: default value
|
||||
* flags: snmp-ups internal flags (FIXME: ...)
|
||||
* oid2info: lookup table between OID and NUT values
|
||||
* setvar: variable to set for SU_FLAG_SETINT
|
||||
*
|
||||
* Example:
|
||||
* { "input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL },
|
||||
* { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, onbatt_info },
|
||||
*
|
||||
* To create a value lookup structure (as needed on the 2nd line), use the
|
||||
* following kind of declaration, outside of the present snmp_info_t[]:
|
||||
* static info_lkp_t onbatt_info[] = {
|
||||
* { 1, "OB" },
|
||||
* { 2, "OL" },
|
||||
* { 0, "NULL" }
|
||||
* };
|
||||
*/
|
||||
|
||||
/* dupsIdentManufacturer.0 = STRING: "Socomec" */
|
||||
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.1.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsIdentModel.0 = STRING: "NETYS RT 1/1 UPS" */
|
||||
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.1.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsIdentAgentSoftwareVersion.0 = STRING: "2.0h " */
|
||||
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.1.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsIdentUPSSoftwareVersion.0 = STRING: "1.1" */
|
||||
{ "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.1.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsType.0 = INTEGER: on-line(1) */
|
||||
{ "ups.type", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.19.0", NULL, SU_FLAG_OK, delta_ups_upstype_info },
|
||||
/* dupsOutputLoad1.0 = INTEGER: 29 */
|
||||
{ "ups.load", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRatingOutputVA.0 = INTEGER: 2200 */
|
||||
{ "ups.power", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRatingOutputVoltage.0 = INTEGER: 230 */
|
||||
{ "output.voltage.nominal", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputVoltage1.0 = INTEGER: 2300 */
|
||||
{ "output.voltage", 0, 0.1, ".1.3.6.1.4.1.2254.2.4.5.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRatingOutputFrequency.0 = INTEGER: 50 */
|
||||
{ "output.frequency.nominal", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputCurrent1.0 = INTEGER: 23 */
|
||||
{ "output.current", 0, 0.1, ".1.3.6.1.4.1.2254.2.4.5.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRatingInputVoltage.0 = INTEGER: 230 */
|
||||
{ "input.voltage.nominal", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputVoltage1.0 = INTEGER: 2280 */
|
||||
{ "input.voltage", 0, 0.1, ".1.3.6.1.4.1.2254.2.4.4.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRatingInputFrequency.0 = INTEGER: 50 */
|
||||
{ "input.frequency.nominal", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.11.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputFrequency1.0 = INTEGER: 499 */
|
||||
{ "input.frequency", 0, 0.1, ".1.3.6.1.4.1.2254.2.4.4.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputSource.0 = INTEGER: normal(0) */
|
||||
{ "ups.status", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.1.0", NULL, SU_FLAG_OK, delta_ups_pwr_info },
|
||||
|
||||
/* Remaining unmapped variables.
|
||||
* Mostly the first field (string) is to be changed
|
||||
* Check docs/nut-names.txt for the right variable names
|
||||
*/
|
||||
#if 0
|
||||
/* dupsIdentName.0 = "" */
|
||||
{ "unmapped.dupsIdentName", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAttachedDevices.0 = "" */
|
||||
{ "unmapped.dupsAttachedDevices", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRatingBatteryVoltage.0 = INTEGER: 0 */
|
||||
{ "unmapped.dupsRatingBatteryVoltage", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.12.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsLowTransferVoltUpBound.0 = INTEGER: 0 Volt */
|
||||
{ "unmapped.dupsLowTransferVoltUpBound", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.13.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsLowTransferVoltLowBound.0 = INTEGER: 0 Volt */
|
||||
{ "unmapped.dupsLowTransferVoltLowBound", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.14.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsHighTransferVoltUpBound.0 = INTEGER: 0 Volt */
|
||||
{ "unmapped.dupsHighTransferVoltUpBound", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.15.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsHighTransferVoltLowBound.0 = INTEGER: 0 Volt */
|
||||
{ "unmapped.dupsHighTransferVoltLowBound", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.16.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsLowBattTime.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsLowBattTime", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.17.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutletRelays.0 = INTEGER: 2 */
|
||||
{ "unmapped.dupsOutletRelays", 0, 1, ".1.3.6.1.4.1.2254.2.4.1.18.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsShutdownType.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsShutdownType", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAutoReboot.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAutoReboot", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsShutdownAction.0 = INTEGER: 0 */
|
||||
{ "unmapped.dupsShutdownAction", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRestartAction.0 = INTEGER: 0 */
|
||||
{ "unmapped.dupsRestartAction", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsSetOutletRelay.0 = INTEGER: 1 */
|
||||
{ "unmapped.dupsSetOutletRelay", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRelayOffDelay.0 = INTEGER: 0 */
|
||||
{ "unmapped.dupsRelayOffDelay", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsRelayOnDelay.0 = INTEGER: 0 */
|
||||
{ "unmapped.dupsRelayOnDelay", 0, 1, ".1.3.6.1.4.1.2254.2.4.2.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigBuzzerAlarm.0 = INTEGER: alarm(1) */
|
||||
{ "unmapped.dupsConfigBuzzerAlarm", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigBuzzerState.0 = INTEGER: disable(2) */
|
||||
{ "unmapped.dupsConfigBuzzerState", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigSensitivity.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsConfigSensitivity", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigLowVoltageTransferPoint.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsConfigLowVoltageTransferPoint", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigHighVoltageTransferPoint.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsConfigHighVoltageTransferPoint", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigShutdownOSDelay.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsConfigShutdownOSDelay", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigUPSBootDelay.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsConfigUPSBootDelay", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsConfigExternalBatteryPack.0 = INTEGER: 0 */
|
||||
{ "unmapped.dupsConfigExternalBatteryPack", 0, 1, ".1.3.6.1.4.1.2254.2.4.3.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputNumLines.0 = INTEGER: 1 */
|
||||
{ "unmapped.dupsInputNumLines", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputCurrent1.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputCurrent1", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputFrequency2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputFrequency2", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputVoltage2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputVoltage2", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputCurrent2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputCurrent2", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputFrequency3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputFrequency3", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputVoltage3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputVoltage3", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsInputCurrent3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsInputCurrent3", 0, 1, ".1.3.6.1.4.1.2254.2.4.4.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputFrequency.0 = INTEGER: 499 0.1 Hertz */
|
||||
{ "unmapped.dupsOutputFrequency", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputNumLines.0 = INTEGER: 1 */
|
||||
{ "unmapped.dupsOutputNumLines", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputPower1.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputPower1", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputVoltage2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputVoltage2", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputCurrent2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputCurrent2", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputPower2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputPower2", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputLoad2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputLoad2", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.11.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputVoltage3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputVoltage3", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.12.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputCurrent3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputCurrent3", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.13.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputPower3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputPower3", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.14.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsOutputLoad3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsOutputLoad3", 0, 1, ".1.3.6.1.4.1.2254.2.4.5.15.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassFrequency.0 = INTEGER: 499 0.1 Hertz */
|
||||
{ "unmapped.dupsBypassFrequency", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassNumLines.0 = INTEGER: 1 */
|
||||
{ "unmapped.dupsBypassNumLines", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassVoltage1.0 = INTEGER: 2280 */
|
||||
{ "unmapped.dupsBypassVoltage1", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassCurrent1.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassCurrent1", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassPower1.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassPower1", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassVoltage2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassVoltage2", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassCurrent2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassCurrent2", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassPower2.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassPower2", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassVoltage3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassVoltage3", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassCurrent3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassCurrent3", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypassPower3.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBypassPower3", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.11.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypass.12.0 = NULL */
|
||||
{ "unmapped.dupsBypass", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.12.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypass.13.0 = NULL */
|
||||
{ "unmapped.dupsBypass", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.13.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBypass.14.0 = NULL */
|
||||
{ "unmapped.dupsBypass", 0, 1, ".1.3.6.1.4.1.2254.2.4.6.14.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryCondiction.0 = INTEGER: good(0) */
|
||||
{ "unmapped.dupsBatteryCondiction", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryStatus.0 = INTEGER: ok(0) */
|
||||
{ "unmapped.dupsBatteryStatus", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryCharge.0 = INTEGER: charging(1) */
|
||||
{ "unmapped.dupsBatteryCharge", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsSecondsOnBattery.0 = INTEGER: 0 seconds */
|
||||
{ "unmapped.dupsSecondsOnBattery", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryEstimatedTime.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBatteryEstimatedTime", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryVoltage.0 = INTEGER: 550 0.1 Volt DC */
|
||||
{ "unmapped.dupsBatteryVoltage", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryCurrent.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsBatteryCurrent", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsBatteryCapacity.0 = INTEGER: 100 percent */
|
||||
{ "unmapped.dupsBatteryCapacity", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsTemperature.0 = INTEGER: 32 degrees Centigrade */
|
||||
{ "unmapped.dupsTemperature", 0, 1, ".1.3.6.1.4.1.2254.2.4.7.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsLastReplaceDate.0 = Wrong Type (should be OCTET STRING): NULL */
|
||||
{ "unmapped.dupsLastReplaceDate", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.7.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsNextReplaceDate.0 = Wrong Type (should be OCTET STRING): NULL */
|
||||
{ "unmapped.dupsNextReplaceDate", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.7.11.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsTestType.0 = INTEGER: abort(0) */
|
||||
{ "unmapped.dupsTestType", 0, 1, ".1.3.6.1.4.1.2254.2.4.8.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsTestResultsSummary.0 = INTEGER: noTestsInitiated(0) */
|
||||
{ "unmapped.dupsTestResultsSummary", 0, 1, ".1.3.6.1.4.1.2254.2.4.8.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsTestResultsDetail.0 = Wrong Type (should be OCTET STRING): NULL */
|
||||
{ "unmapped.dupsTestResultsDetail", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2254.2.4.8.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmDisconnect.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmDisconnect", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmPowerFail.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmPowerFail", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmBatteryLow.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmBatteryLow", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmLoadWarning.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmLoadWarning", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmLoadSeverity.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmLoadSeverity", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmLoadOnBypass.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmLoadOnBypass", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmUPSFault.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmUPSFault", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmBatteryGroundFault.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmBatteryGroundFault", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmTestInProgress.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmTestInProgress", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmBatteryTestFail.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmBatteryTestFail", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmFuseFailure.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmFuseFailure", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.11.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOutputOverload.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmOutputOverload", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.12.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOutputOverCurrent.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmOutputOverCurrent", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.13.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmInverterAbnormal.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmInverterAbnormal", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.14.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmRectifierAbnormal.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmRectifierAbnormal", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.15.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmReserveAbnormal.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmReserveAbnormal", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.16.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmLoadOnReserve.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsAlarmLoadOnReserve", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.17.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOverTemperature.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmOverTemperature", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.18.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOutputBad.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmOutputBad", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.19.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmBypassBad.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmBypassBad", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.20.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmUPSOff.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmUPSOff", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.21.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmChargerFail.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmChargerFail", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.22.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmFanFail.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmFanFail", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.23.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmEconomicMode.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmEconomicMode", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.24.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOutputOff.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmOutputOff", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.25.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmSmartShutdown.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmSmartShutdown", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.26.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmEmergencyPowerOff.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmEmergencyPowerOff", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.27.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmUPSShutdown.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmUPSShutdown", 0, 1, ".1.3.6.1.4.1.2254.2.4.9.28.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvTemperature.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsEnvTemperature", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.1.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvHumidity.0 = Wrong Type (should be INTEGER): NULL */
|
||||
{ "unmapped.dupsEnvHumidity", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.2.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvSetTemperatureLimit.0 = INTEGER: 40 degrees Centigrade */
|
||||
{ "unmapped.dupsEnvSetTemperatureLimit", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.3.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvSetHumidityLimit.0 = INTEGER: 90 percentage */
|
||||
{ "unmapped.dupsEnvSetHumidityLimit", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.4.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvSetEnvRelay1.0 = INTEGER: normalOpen(0) */
|
||||
{ "unmapped.dupsEnvSetEnvRelay1", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.5.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvSetEnvRelay2.0 = INTEGER: normalOpen(0) */
|
||||
{ "unmapped.dupsEnvSetEnvRelay2", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.6.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvSetEnvRelay3.0 = INTEGER: normalOpen(0) */
|
||||
{ "unmapped.dupsEnvSetEnvRelay3", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.7.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsEnvSetEnvRelay4.0 = INTEGER: normalOpen(0) */
|
||||
{ "unmapped.dupsEnvSetEnvRelay4", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.8.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOverEnvTemperature.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmOverEnvTemperature", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.9.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmOverEnvHumidity.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmOverEnvHumidity", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.10.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmEnvRelay1.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmEnvRelay1", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.11.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmEnvRelay2.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmEnvRelay2", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.12.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmEnvRelay3.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmEnvRelay3", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.13.0", NULL, SU_FLAG_OK, NULL },
|
||||
/* dupsAlarmEnvRelay4.0 = INTEGER: off(0) */
|
||||
{ "unmapped.dupsAlarmEnvRelay4", 0, 1, ".1.3.6.1.4.1.2254.2.4.10.14.0", NULL, SU_FLAG_OK, NULL },
|
||||
#endif /* #if 0 */
|
||||
|
||||
/* end of structure. */
|
||||
{ NULL, 0, 0, NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
mib2nut_info_t delta_ups = { "delta_ups", DELTA_UPS_MIB_VERSION, NULL, NULL, delta_ups_mib, DELTA_UPS_SYSOID };
|
29
drivers/delta_ups-mib.h
Normal file
29
drivers/delta_ups-mib.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* delta_ups-mib.h - subdriver to monitor delta_ups SNMP devices with NUT
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2011 - 2012 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
|
||||
*/
|
||||
|
||||
#ifndef DELTA_UPS_MIB_H
|
||||
#define DELTA_UPS_MIB_H
|
||||
|
||||
#include "main.h"
|
||||
#include "snmp-ups.h"
|
||||
|
||||
extern mib2nut_info_t delta_ups;
|
||||
|
||||
#endif /* DELTA_UPS_MIB_H */
|
|
@ -387,7 +387,17 @@ int dstate_addenum(const char *var, const char *fmt, ...)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int dstate_addrange(const char *var, const int min, const int max)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const st_tree_t *dstate_getroot(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int dstate_delinfo(const char *var)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -60,6 +60,7 @@ int dstate_setinfo(const char *var, const char *fmt, ...)
|
|||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
int dstate_addenum(const char *var, const char *fmt, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
int dstate_addrange(const char *var, const int min, const int max);
|
||||
void dstate_setflags(const char *var, int flags);
|
||||
void dstate_setaux(const char *var, int aux);
|
||||
const char *dstate_getinfo(const char *var);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* 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.
|
||||
* gen-usbhid-subdriver script. It must be customized.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -137,7 +137,7 @@ static const char *idowell_format_serial(HIDDevice_t *hd) {
|
|||
* 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);
|
||||
int status = is_usb_device_supported(idowell_usb_device_table, hd);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
|
|
@ -184,18 +184,18 @@ static snmp_info_t ietf_mib[] = {
|
|||
{ "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 },
|
||||
{ "input.bypass.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.2.1", "", SU_BYPASS_1, NULL }, /* upsBypassVoltage */
|
||||
{ "input.bypass.L1-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.2.1", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.L2-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.2.2", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.L3-N.voltage", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.2.3", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.3.1", "", SU_BYPASS_1, NULL }, /* upsBypassCurrent */
|
||||
{ "input.bypass.L1.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.3.1", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.L2.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.3.2", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.L3.current", 0, 0.1, IETF_OID_UPS_MIB "5.3.1.3.3", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.4.1", "", SU_BYPASS_1, NULL }, /* upsBypassPower */
|
||||
{ "input.bypass.L1.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.4.1", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.L2.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.4.2", "", SU_BYPASS_3, NULL },
|
||||
{ "input.bypass.L3.realpower", 0, 1.0, IETF_OID_UPS_MIB "5.3.1.4.3", "", SU_BYPASS_3, NULL },
|
||||
|
||||
/* Alarm Group */
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -56,6 +56,9 @@ static int path_to_string(char *string, size_t size, const HIDPath_t *path, usag
|
|||
static int8_t get_unit_expo(const HIDData_t *hiddata);
|
||||
static double exponent(double a, int8_t b);
|
||||
|
||||
/* Tweak flag for APC Back-UPS */
|
||||
int max_report_size = 0;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* report buffering system */
|
||||
|
||||
|
@ -137,6 +140,9 @@ reportbuf_t *new_report_buffer(HIDDesc_t *pDesc)
|
|||
seconds, then the report is freshly read from the USB
|
||||
device. Otherwise, it is unchanged.
|
||||
Return 0 on success, -1 on error with errno set. */
|
||||
/* because buggy firmwares from APC return wrong report size, we either
|
||||
ask the report with the found report size or with the whole buffer size
|
||||
depending on the max_report_size flag */
|
||||
static int refresh_report_buffer(reportbuf_t *rbuf, hid_dev_handle_t udev, HIDData_t *pData, int age)
|
||||
{
|
||||
int id = pData->ReportID;
|
||||
|
@ -148,7 +154,9 @@ static int refresh_report_buffer(reportbuf_t *rbuf, hid_dev_handle_t udev, HIDDa
|
|||
return 0;
|
||||
}
|
||||
|
||||
r = comm_driver->get_report(udev, id, rbuf->data[id], rbuf->len[id]);
|
||||
r = comm_driver->get_report(udev, id, rbuf->data[id],
|
||||
max_report_size ? (int)sizeof(rbuf->data[id]):rbuf->len[id]);
|
||||
|
||||
if (r <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -256,7 +264,7 @@ static struct {
|
|||
|
||||
/* CAUTION: be careful when modifying the output format of this function,
|
||||
* since it's used to produce sub-drivers "stub" using
|
||||
* scripts/subdriver/path-to-subdriver.sh
|
||||
* scripts/subdriver/gen-usbhid-subdriver.sh
|
||||
*/
|
||||
void HIDDumpTree(hid_dev_handle_t udev, usage_tables_t *utab)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "common.h" /* for xmalloc, upsdebugx prototypes */
|
||||
|
||||
#define SHUT_DRIVER_NAME "SHUT communication driver"
|
||||
#define SHUT_DRIVER_VERSION "0.83"
|
||||
#define SHUT_DRIVER_VERSION "0.84"
|
||||
|
||||
/* communication driver description structure */
|
||||
upsdrv_info_t comm_upsdrv_info = {
|
||||
|
@ -312,7 +312,7 @@ int libshut_open(int *upsfd, SHUTDevice_t *curDevice, char *device_path,
|
|||
/* FIXME: add variable baudrate detection */
|
||||
*upsfd = ser_open(device_path);
|
||||
ser_set_speed(*upsfd, device_path, B2400);
|
||||
setline(*upsfd, 1);
|
||||
setline(*upsfd, 0);
|
||||
|
||||
/* initialise communication */
|
||||
if (!shut_synchronise(*upsfd))
|
||||
|
|
|
@ -33,12 +33,11 @@
|
|||
#include "usb-common.h"
|
||||
#include "libusb.h"
|
||||
|
||||
/* USB standard state 5000, but we've decreased it to
|
||||
* improve reactivity */
|
||||
#define USB_TIMEOUT 4000
|
||||
/* USB standard timeout */
|
||||
#define USB_TIMEOUT 5000
|
||||
|
||||
#define USB_DRIVER_NAME "USB communication driver"
|
||||
#define USB_DRIVER_VERSION "0.31"
|
||||
#define USB_DRIVER_VERSION "0.32"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t comm_upsdrv_info = {
|
||||
|
|
|
@ -108,8 +108,7 @@ static const char *liebert_format_serial(HIDDevice_t *hd) {
|
|||
* the device is supported by this subdriver, else 0. */
|
||||
static int liebert_claim(HIDDevice_t *hd) {
|
||||
|
||||
int status = is_usb_device_supported(liebert_usb_device_table, hd->VendorID,
|
||||
hd->ProductID);
|
||||
int status = is_usb_device_supported(liebert_usb_device_table, hd);
|
||||
|
||||
switch (status) {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "usbhid-ups.h"
|
||||
#include "mge-hid.h"
|
||||
|
||||
#define MGE_HID_VERSION "MGE HID 1.31"
|
||||
#define MGE_HID_VERSION "MGE HID 1.32"
|
||||
|
||||
/* (prev. MGE Office Protection Systems, prev. MGE UPS SYSTEMS) */
|
||||
/* Eaton */
|
||||
|
@ -268,6 +268,12 @@ static info_lkp_t mge_battery_capacity[] = {
|
|||
{ 0, NULL, mge_battery_capacity_fun }
|
||||
};
|
||||
|
||||
info_lkp_t eaton_enable_disable_info[] = {
|
||||
{ 0, "disabled", NULL },
|
||||
{ 1, "enabled", NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static info_lkp_t mge_upstype_conversion[] = {
|
||||
{ 1, "offline / line interactive", NULL },
|
||||
{ 2, "online", NULL },
|
||||
|
@ -893,6 +899,7 @@ static hid_info_t mge_hid2nut[] =
|
|||
{ "ups.start.auto", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Input.[1].AutomaticRestart", NULL, "%s", HU_FLAG_SEMI_STATIC, yes_no_info },
|
||||
{ "ups.start.battery", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Input.[3].StartOnBattery", NULL, "%s", HU_FLAG_SEMI_STATIC, yes_no_info },
|
||||
{ "ups.start.reboot", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerConverter.Output.ForcedReboot", NULL, "%s", HU_FLAG_SEMI_STATIC, yes_no_info },
|
||||
{ "ups.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.PresentStatus.Switchable", NULL, "%s", HU_FLAG_SEMI_STATIC | HU_FLAG_ENUM, eaton_enable_disable_info },
|
||||
#ifdef HAVE_STRPTIME
|
||||
{ "ups.date", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.Time", NULL, "%s", 0, mge_date_conversion },
|
||||
{ "ups.time", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.Time", NULL, "%s", 0, mge_time_conversion },
|
||||
|
@ -924,8 +931,11 @@ static hid_info_t mge_hid2nut[] =
|
|||
{ "BOOL", 0, 0, "UPS.PowerConverter.Input.[1].PresentStatus.VoltageOutOfRange", NULL, NULL, 0, vrange_info },
|
||||
{ "BOOL", 0, 0, "UPS.PowerConverter.Input.[1].PresentStatus.FrequencyOutOfRange", NULL, NULL, 0, frange_info },
|
||||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, 0, off_info },
|
||||
#if 0
|
||||
/* TODO: UPS.BatterySystem.Charger.PresentStatus.Used is related to ABM */
|
||||
{ "BOOL", 0, 0, "UPS.BatterySystem.Charger.PresentStatus.Used", NULL, NULL, 0, off_info },
|
||||
/* FIXME: on Dell, the above requires an "AND" with "UPS.BatterySystem.Charger.Mode = 4 (ABM Resting)" */
|
||||
#endif
|
||||
{ "BOOL", 0, 0, "UPS.PowerConverter.Input.[2].PresentStatus.Used", NULL, NULL, 0, bypass_auto_info }, /* Automatic bypass */
|
||||
{ "BOOL", 0, 0, "UPS.PowerConverter.Input.[4].PresentStatus.Used", NULL, NULL, 0, bypass_manual_info }, /* Manual bypass */
|
||||
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FanFailure", NULL, NULL, 0, fanfail_info },
|
||||
|
@ -1099,7 +1109,13 @@ static char *get_model_name(const char *iProduct, const char *iModel)
|
|||
|
||||
/* Search for device type and formatting rules */
|
||||
for (model = mge_model_names; model->iProduct; model++) {
|
||||
upsdebugx(2, "comparing with: %s", model->name);
|
||||
if(model->name) {
|
||||
upsdebugx(2, "comparing with: %s", model->name);
|
||||
}
|
||||
else {
|
||||
upsdebugx(2, "comparing with: %s %s", model->iProduct,
|
||||
model->iModel);
|
||||
}
|
||||
|
||||
if (strcmp(iProduct, model->iProduct)) {
|
||||
continue;
|
||||
|
@ -1167,8 +1183,7 @@ static const char *mge_format_serial(HIDDevice_t *hd) {
|
|||
static int mge_claim(HIDDevice_t *hd) {
|
||||
|
||||
#ifndef SHUT_MODE
|
||||
int status = is_usb_device_supported(mge_usb_device_table, hd->VendorID,
|
||||
hd->ProductID);
|
||||
int status = is_usb_device_supported(mge_usb_device_table, hd);
|
||||
|
||||
switch (status) {
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2002 - 2005
|
||||
* Arnaud Quette <arnaud.quette@gmail.com>
|
||||
* Hans Ekkehard Plesser <hans.plesser@itf.nlh.no>
|
||||
* Martin Loyer <martin@ouifi.net>
|
||||
* Martin Loyer <martin@degraaf.fr>
|
||||
* Patrick Agrain <patrick.agrain@alcatel.fr>
|
||||
* Nicholas Reilly <nreilly@magma.ca>
|
||||
* Dave Abbott <d.abbott@dcs.shef.ac.uk>
|
||||
|
@ -64,7 +64,7 @@
|
|||
/* --------------------------------------------------------------- */
|
||||
|
||||
#define DRIVER_NAME "MGE UPS SYSTEMS/U-Talk driver"
|
||||
#define DRIVER_VERSION "0.92"
|
||||
#define DRIVER_VERSION "0.93"
|
||||
|
||||
|
||||
/* driver description structure */
|
||||
|
@ -73,7 +73,7 @@ upsdrv_info_t upsdrv_info = {
|
|||
DRIVER_VERSION,
|
||||
"Arnaud Quette <ArnaudQuette@gmail.com>\n" \
|
||||
"Hans Ekkehard Plesser <hans.plesser@itf.nlh.no>\n" \
|
||||
"Martin Loyer <martin@ouifi.net>\n" \
|
||||
"Martin Loyer <martin@degraaf.fr>\n" \
|
||||
"Patrick Agrain <patrick.agrain@alcatel.fr>\n" \
|
||||
"Nicholas Reilly <nreilly@magma.ca>\n" \
|
||||
"Dave Abbott <d.abbott@dcs.shef.ac.uk>\n" \
|
||||
|
@ -652,11 +652,12 @@ static void enable_ups_comm(void)
|
|||
{
|
||||
char buf[8];
|
||||
|
||||
/* send Z twice --- speeds up re-connect */
|
||||
mge_command(NULL, 0, "Z");
|
||||
mge_command(NULL, 0, "Z");
|
||||
/* only enable communication if needed! */
|
||||
if ( mge_command(buf, 8, "Si") <= 0)
|
||||
{
|
||||
mge_command(NULL, 0, "Z"); /* send Z twice --- speeds up re-connect */
|
||||
mge_command(NULL, 0, "Z");
|
||||
mge_command(NULL, 0, "Ax 1");
|
||||
usleep(MGE_CONNECT_DELAY);
|
||||
}
|
||||
|
@ -873,8 +874,9 @@ static int mge_command(char *reply, int replylen, const char *fmt, ...)
|
|||
|
||||
va_end(ap);
|
||||
|
||||
/* Delay a bit to avoid overlap of a previous answer */
|
||||
usleep(100000);
|
||||
/* Delay a bit to avoid overlap of a previous answer (500 ms), as per
|
||||
* http://old.networkupstools.org/protocols/mge/9261zwfa.pdf § 6.1. Timings */
|
||||
usleep(500000);
|
||||
|
||||
/* flush received, unread data */
|
||||
tcflush(upsfd, TCIFLUSH);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2002 - 2005
|
||||
* Arnaud Quette <arnaud.quette@free.fr> & <arnaud.quette@mgeups.com>
|
||||
* Hans Ekkehard Plesser <hans.plesser@itf.nlh.no>
|
||||
* Martin Loyer <martin@ouifi.net>
|
||||
* Martin Loyer <martin@degraaf.fr>
|
||||
* Patrick Agrain <patrick.agrain@alcatel.fr>
|
||||
* Nicholas Reilly <nreilly@magma.ca>
|
||||
* Dave Abbott <d.abbott@dcs.shef.ac.uk>
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#define ST_FLAG_RW 0x0001
|
||||
#define ST_FLAG_STATIC 0x0002
|
||||
|
||||
extern int shutdown_duration;
|
||||
|
||||
static int mge_ambient_value = 0;
|
||||
|
||||
static char mge_scratch_buf[256];
|
||||
|
@ -45,6 +47,8 @@ static char mge_scratch_buf[256];
|
|||
static char var[128];
|
||||
static char val[128];
|
||||
|
||||
static int mge_shutdown_pending = 0;
|
||||
|
||||
typedef enum {
|
||||
ROOTPARENT = NE_XML_STATEROOT,
|
||||
|
||||
|
@ -125,6 +129,10 @@ static const char *discharging_info(const char *val)
|
|||
{
|
||||
if (val[0] == '1') {
|
||||
STATUS_SET(DISCHRG);
|
||||
/* Workaround NMC bug: both charging and discharging set to 1 */
|
||||
if(STATUS_BIT(CHRG)) {
|
||||
STATUS_CLR(CHRG);
|
||||
}
|
||||
} else {
|
||||
STATUS_CLR(DISCHRG);
|
||||
}
|
||||
|
@ -255,7 +263,8 @@ static const char *fanfail_info(const char *val)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
|
||||
#if 0
|
||||
static const char *shutdownimm_info(const char *val)
|
||||
{
|
||||
if (val[0] == '1') {
|
||||
|
@ -266,7 +275,8 @@ static const char *shutdownimm_info(const char *val)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
static const char *overheat_info(const char *val)
|
||||
{
|
||||
if (val[0] == '1') {
|
||||
|
@ -524,24 +534,328 @@ static const char *mge_ambient_info(const char *val)
|
|||
}
|
||||
}
|
||||
|
||||
static const char *mge_timer_shutdown(const char *val)
|
||||
static const char *mge_timer_shutdown(const char *delay_before_shutoff)
|
||||
{
|
||||
const char *delay = dstate_getinfo("ups.delay.shutdown");
|
||||
|
||||
if ((delay) && (atoi(val) > -1) && (atoi(val) < atoi(delay))) {
|
||||
if (atoi(delay_before_shutoff) > -1 ) {
|
||||
STATUS_SET(SHUTDOWNIMM);
|
||||
mge_shutdown_pending = 1;
|
||||
|
||||
if( atoi(delay_before_shutoff) > shutdown_duration ) {
|
||||
STATUS_CLR(SHUTDOWNIMM);
|
||||
mge_shutdown_pending = 0;
|
||||
}
|
||||
} else {
|
||||
STATUS_CLR(SHUTDOWNIMM);
|
||||
mge_shutdown_pending = 0;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static const char *mge_shutdown_imminent(const char *val)
|
||||
{
|
||||
const int shutdown_delay = atoi(val);
|
||||
|
||||
/* shutdown is already managed by mge_timer_shutdown, give up */
|
||||
if(mge_shutdown_pending) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We may have "NONE" or "-1" or ?? as value
|
||||
* We also double check both the string and numeric values to be zero!*/
|
||||
if ((val) && (val[0] == '0') && (shutdown_delay == 0)) {
|
||||
STATUS_SET(SHUTDOWNIMM);
|
||||
} else {
|
||||
STATUS_CLR(SHUTDOWNIMM);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static xml_info_t mge_xml2nut[] = {
|
||||
/* NMC configuration (mapped 1:1 for now) */
|
||||
{ "device.contact", ST_FLAG_RW, 0, "System.Contact", 0, 0, NULL },
|
||||
{ "device.location", ST_FLAG_RW, 0, "System.Location", 0, 0, NULL },
|
||||
/* Not used for now; might however be used in future for history & stats collection
|
||||
{ "System.History.Log.Interval", ST_FLAG_RW, 0, "System.History.Log.Interval", 0, 0, NULL },
|
||||
*/
|
||||
{ "System.Environment.Log.Interval", ST_FLAG_RW, 0, "System.Environment.Log.Interval", 0, 0, NULL },
|
||||
{ "System.Outlet[1].iName", ST_FLAG_RW, 0, "System.Outlet[1].iName", 0, 0, NULL },
|
||||
/* Mapped as ups.delay.shutdown
|
||||
{ "System.ShutdownDuration", ST_FLAG_RW, 0, "System.ShutdownDuration", 0, 0, NULL },
|
||||
*/
|
||||
{ "System.ShutdownTimerSelected", ST_FLAG_RW, 0, "System.ShutdownTimerSelected", 0, 0, NULL },
|
||||
{ "System.ShutdownTimer", ST_FLAG_RW, 0, "System.ShutdownTimer", 0, 0, NULL },
|
||||
/* Mapped as battery.runtime.low
|
||||
{ "System.RunTimeToEmptyLimit", ST_FLAG_RW, 0, "System.RunTimeToEmptyLimit", 0, 0, NULL },
|
||||
*/
|
||||
{ "System.RemainingCapacityLimit", ST_FLAG_RW, 0, "System.RemainingCapacityLimit", 0, 0, NULL },
|
||||
{ "System.RestartLevel", ST_FLAG_RW, 0, "System.RestartLevel", 0, 0, NULL },
|
||||
{ "System.Outlet[2].iName", ST_FLAG_RW, 0, "System.Outlet[2].iName", 0, 0, NULL },
|
||||
/* Mapped as outlet.1.delay.shutdown
|
||||
{ "System.Outlet[2].ShutdownDuration", ST_FLAG_RW, 0, "System.Outlet[2].ShutdownDuration", 0, 0, NULL },
|
||||
*/
|
||||
{ "System.Outlet[2].ShutdownTimer", ST_FLAG_RW, 0, "System.Outlet[2].ShutdownTimer", 0, 0, NULL },
|
||||
{ "System.Outlet[2].StartupTimer", ST_FLAG_RW, 0, "System.Outlet[2].StartupTimer", 0, 0, NULL },
|
||||
{ "System.Outlet[2].RemainingCapacityLimit", ST_FLAG_RW, 0, "System.Outlet[2].RemainingCapacityLimit", 0, 0, NULL },
|
||||
/* For future extension, and support of shutdown on load segment
|
||||
* { "System.Outlet[2].RunTimeToShutdown", ST_FLAG_RW, 0, "System.Outlet[2].RunTimeToShutdown", 0, 0, NULL }, */
|
||||
{ "System.Outlet[3].iName", ST_FLAG_RW, 0, "System.Outlet[3].iName", 0, 0, NULL },
|
||||
/* Mapped as outlet.2.delay.shutdown
|
||||
{ "System.Outlet[3].ShutdownDuration", ST_FLAG_RW, 0, "System.Outlet[3].ShutdownDuration", 0, 0, NULL },
|
||||
*/
|
||||
{ "System.Outlet[3].ShutdownTimer", ST_FLAG_RW, 0, "System.Outlet[3].ShutdownTimer", 0, 0, NULL },
|
||||
{ "System.Outlet[3].StartupTimer", ST_FLAG_RW, 0, "System.Outlet[3].StartupTimer", 0, 0, NULL },
|
||||
{ "System.Outlet[3].RemainingCapacityLimit", ST_FLAG_RW, 0, "System.Outlet[3].RemainingCapacityLimit", 0, 0, NULL },
|
||||
/* For future extension, and support of shutdown on load segment
|
||||
* { "System.Outlet[3].RunTimeToShutdown", ST_FLAG_RW, 0, "System.Outlet[3].RunTimeToShutdown", 0, 0, NULL }, */
|
||||
{ "System.Outlet[1].OffDelay", ST_FLAG_RW, 0, "System.Outlet[1].OffDelay", 0, 0, NULL },
|
||||
{ "System.Outlet[1].Toggle", ST_FLAG_RW, 0, "System.Outlet[1].Toggle", 0, 0, NULL },
|
||||
{ "System.Outlet[1].OnDelay", ST_FLAG_RW, 0, "System.Outlet[1].OnDelay", 0, 0, NULL },
|
||||
{ "System.Outlet[2].OffDelay", ST_FLAG_RW, 0, "System.Outlet[2].OffDelay", 0, 0, NULL },
|
||||
{ "System.Outlet[2].Toggle", ST_FLAG_RW, 0, "System.Outlet[2].Toggle", 0, 0, NULL },
|
||||
{ "System.Outlet[2].OnDelay", ST_FLAG_RW, 0, "System.Outlet[2].OnDelay", 0, 0, NULL },
|
||||
{ "System.Outlet[3].OffDelay", ST_FLAG_RW, 0, "System.Outlet[3].OffDelay", 0, 0, NULL },
|
||||
{ "System.Outlet[3].Toggle", ST_FLAG_RW, 0, "System.Outlet[3].Toggle", 0, 0, NULL },
|
||||
{ "System.Outlet[3].OnDelay", ST_FLAG_RW, 0, "System.Outlet[3].OnDelay", 0, 0, NULL },
|
||||
{ "System.Login", ST_FLAG_RW, 0, "System.Login", 0, 0, NULL },
|
||||
{ "System.Password", ST_FLAG_RW, 0, "System.Password", 0, 0, NULL },
|
||||
{ "System.Security", ST_FLAG_RW, 0, "System.Security", 0, 0, NULL },
|
||||
{ "System.FirmwareUpgrade", ST_FLAG_RW, 0, "System.FirmwareUpgrade", 0, 0, NULL },
|
||||
#if (0) /* not interresting for NUT */
|
||||
{ "System.Network.SNMP.ReadCommunity", ST_FLAG_RW, 0, "System.Network.SNMP.ReadCommunity", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.ReadCommunityName", 0, 0, "System.Network.SNMP.ReadCommunityName", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.ReadCommunitySecurityLevel", 0, 0, "System.Network.SNMP.ReadCommunitySecurityLevel", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.ReadCommunitySecurityRight", 0, 0, "System.Network.SNMP.ReadCommunitySecurityRight", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.WriteCommunity", ST_FLAG_RW, 0, "System.Network.SNMP.WriteCommunity", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.WriteCommunityName", 0, 0, "System.Network.SNMP.WriteCommunityName", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.WriteCommunitySecurityLevel", 0, 0, "System.Network.SNMP.WriteCommunitySecurityLevel", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.WriteCommunitySecurityRight", ST_FLAG_RW, 0, "System.Network.SNMP.WriteCommunitySecurityRight", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.Admin", ST_FLAG_RW, 0, "System.Network.SNMP.Admin", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.AdminPassword", ST_FLAG_RW, 0, "System.Network.SNMP.AdminPassword", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.AdminSecurityLevel", ST_FLAG_RW, 0, "System.Network.SNMP.AdminSecurityLevel", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.AdminSecurityRight", 0, 0, "System.Network.SNMP.AdminSecurityRight", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.User", ST_FLAG_RW, 0, "System.Network.SNMP.User", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.UserPassword", ST_FLAG_RW, 0, "System.Network.SNMP.UserPassword", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.UserSecurityLevel", ST_FLAG_RW, 0, "System.Network.SNMP.UserSecurityLevel", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.UserSecurityRight", 0, 0, "System.Network.SNMP.UserSecurityRight", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.NotificationUserName", ST_FLAG_RW, 0, "System.Network.SNMP.NotificationUserName", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.snmpVersion", ST_FLAG_RW, 0, "System.Network.SNMP.snmpVersion", 0, 0, NULL },
|
||||
{ "System.Network.SNMP.engineBoots", 0, 0, "System.Network.SNMP.engineBoots", 0, 0, NULL },
|
||||
{ "System.Network.Telnet.Access", ST_FLAG_RW, 0, "System.Network.Telnet.Access", 0, 0, NULL },
|
||||
{ "System.Network.Telnet.Security", ST_FLAG_RW, 0, "System.Network.Telnet.Security", 0, 0, NULL },
|
||||
{ "System.Network.Telnet.Console", ST_FLAG_RW, 0, "System.Network.Telnet.Console", 0, 0, NULL },
|
||||
{ "System.Email.Sender", ST_FLAG_RW, 0, "System.Email.Sender", 0, 0, NULL },
|
||||
{ "System.Email.Subject", ST_FLAG_RW, 0, "System.Email.Subject", 0, 0, NULL },
|
||||
{ "System.Email.UPSName", ST_FLAG_RW, 0, "System.Email.UPSName", 0, 0, NULL },
|
||||
{ "System.Email.Message", ST_FLAG_RW, 0, "System.Email.Message", 0, 0, NULL },
|
||||
{ "System.Email.Localization", ST_FLAG_RW, 0, "System.Email.Localization", 0, 0, NULL },
|
||||
{ "System.Email.EventName", ST_FLAG_RW, 0, "System.Email.EventName", 0, 0, NULL },
|
||||
{ "System.Email[0].Recipient", ST_FLAG_RW, 0, "System.Email[0].Recipient", 0, 0, NULL },
|
||||
{ "System.Email[0].Selected", ST_FLAG_RW, 0, "System.Email[0].Selected", 0, 0, NULL },
|
||||
{ "System.Email[0].Enotify", ST_FLAG_RW, 0, "System.Email[0].Enotify", 0, 0, NULL },
|
||||
{ "System.Email[0].Measures.Log", ST_FLAG_RW, 0, "System.Email[0].Measures.Log", 0, 0, NULL },
|
||||
{ "System.Email[0].Events.Log", ST_FLAG_RW, 0, "System.Email[0].Events.Log", 0, 0, NULL },
|
||||
{ "System.Email[0].SystemEvents.Log", ST_FLAG_RW, 0, "System.Email[0].SystemEvents.Log", 0, 0, NULL },
|
||||
{ "System.Email[0].Environment.Log", ST_FLAG_RW, 0, "System.Email[0].Environment.Log", 0, 0, NULL },
|
||||
{ "System.Email[0].Report.Periodicity", ST_FLAG_RW, 0, "System.Email[0].Report.Periodicity", 0, 0, NULL },
|
||||
{ "System.Email[0].Report.Hour", ST_FLAG_RW, 0, "System.Email[0].Report.Hour", 0, 0, NULL },
|
||||
{ "System.Email[0].Report.Next", ST_FLAG_RW, 0, "System.Email[0].Report.Next", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Discharging", ST_FLAG_RW, 0, "System.Email[0].EventList.Discharging", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.ACPresent", ST_FLAG_RW, 0, "System.Email[0].EventList.ACPresent", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.RunTimeToShutdown", ST_FLAG_RW, 0, "System.Email[0].EventList.RunTimeToShutdown", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.BelowRemainingCapacityLimit", ST_FLAG_RW, 0, "System.Email[0].EventList.BelowRemainingCapacityLimit", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.NeedReplacement.1", ST_FLAG_RW, 0, "System.Email[0].EventList.NeedReplacement.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.NeedReplacement.0", ST_FLAG_RW, 0, "System.Email[0].EventList.NeedReplacement.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Overload.1", ST_FLAG_RW, 0, "System.Email[0].EventList.Overload.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Overload.0", ST_FLAG_RW, 0, "System.Email[0].EventList.Overload.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.InternalFailure.1", ST_FLAG_RW, 0, "System.Email[0].EventList.InternalFailure.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.InternalFailure.0", ST_FLAG_RW, 0, "System.Email[0].EventList.InternalFailure.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.CommunicationLost.1", ST_FLAG_RW, 0, "System.Email[0].EventList.CommunicationLost.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.CommunicationLost.0", ST_FLAG_RW, 0, "System.Email[0].EventList.CommunicationLost.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Charger.InternalFailure", ST_FLAG_RW, 0, "System.Email[0].EventList.Charger.InternalFailure", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Input[2].Used.1", ST_FLAG_RW, 0, "System.Email[0].EventList.Input[2].Used.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Input[2].Used.0", ST_FLAG_RW, 0, "System.Email[0].EventList.Input[2].Used.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.PowerModule.RedundancyLost.1", ST_FLAG_RW, 0, "System.Email[0].EventList.PowerModule.RedundancyLost.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.PowerModule.RedundancyLost.0", ST_FLAG_RW, 0, "System.Email[0].EventList.PowerModule.RedundancyLost.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.PowerModule.ProtectionLost.1", ST_FLAG_RW, 0, "System.Email[0].EventList.PowerModule.ProtectionLost.1", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.PowerModule.ProtectionLost.0", ST_FLAG_RW, 0, "System.Email[0].EventList.PowerModule.ProtectionLost.0", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.FirmwareUpgrade", ST_FLAG_RW, 0, "System.Email[0].EventList.FirmwareUpgrade", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Environment.CommunicationLost", ST_FLAG_RW, 0, "System.Email[0].EventList.Environment.CommunicationLost", 0, 0, NULL },
|
||||
{ "System.Email[0].EventList.Environment.Notify", ST_FLAG_RW, 0, "System.Email[0].EventList.Environment.Notify", 0, 0, NULL },
|
||||
{ "System.Email[1].Recipient", ST_FLAG_RW, 0, "System.Email[1].Recipient", 0, 0, NULL },
|
||||
{ "System.Email[1].Selected", ST_FLAG_RW, 0, "System.Email[1].Selected", 0, 0, NULL },
|
||||
{ "System.Email[1].Enotify", ST_FLAG_RW, 0, "System.Email[1].Enotify", 0, 0, NULL },
|
||||
{ "System.Email[1].Measures.Log", ST_FLAG_RW, 0, "System.Email[1].Measures.Log", 0, 0, NULL },
|
||||
{ "System.Email[1].Events.Log", ST_FLAG_RW, 0, "System.Email[1].Events.Log", 0, 0, NULL },
|
||||
{ "System.Email[1].SystemEvents.Log", ST_FLAG_RW, 0, "System.Email[1].SystemEvents.Log", 0, 0, NULL },
|
||||
{ "System.Email[1].Environment.Log", ST_FLAG_RW, 0, "System.Email[1].Environment.Log", 0, 0, NULL },
|
||||
{ "System.Email[1].Report.Periodicity", ST_FLAG_RW, 0, "System.Email[1].Report.Periodicity", 0, 0, NULL },
|
||||
{ "System.Email[1].Report.Hour", ST_FLAG_RW, 0, "System.Email[1].Report.Hour", 0, 0, NULL },
|
||||
{ "System.Email[1].Report.Next", ST_FLAG_RW, 0, "System.Email[1].Report.Next", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Discharging", ST_FLAG_RW, 0, "System.Email[1].EventList.Discharging", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.ACPresent", ST_FLAG_RW, 0, "System.Email[1].EventList.ACPresent", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.RunTimeToShutdown", ST_FLAG_RW, 0, "System.Email[1].EventList.RunTimeToShutdown", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.BelowRemainingCapacityLimit", ST_FLAG_RW, 0, "System.Email[1].EventList.BelowRemainingCapacityLimit", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.NeedReplacement.1", ST_FLAG_RW, 0, "System.Email[1].EventList.NeedReplacement.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.NeedReplacement.0", ST_FLAG_RW, 0, "System.Email[1].EventList.NeedReplacement.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Overload.1", ST_FLAG_RW, 0, "System.Email[1].EventList.Overload.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Overload.0", ST_FLAG_RW, 0, "System.Email[1].EventList.Overload.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.InternalFailure.1", ST_FLAG_RW, 0, "System.Email[1].EventList.InternalFailure.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.InternalFailure.0", ST_FLAG_RW, 0, "System.Email[1].EventList.InternalFailure.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.CommunicationLost.1", ST_FLAG_RW, 0, "System.Email[1].EventList.CommunicationLost.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.CommunicationLost.0", ST_FLAG_RW, 0, "System.Email[1].EventList.CommunicationLost.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Charger.InternalFailure", ST_FLAG_RW, 0, "System.Email[1].EventList.Charger.InternalFailure", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Input[2].Used.1", ST_FLAG_RW, 0, "System.Email[1].EventList.Input[2].Used.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Input[2].Used.0", ST_FLAG_RW, 0, "System.Email[1].EventList.Input[2].Used.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.PowerModule.RedundancyLost.1", ST_FLAG_RW, 0, "System.Email[1].EventList.PowerModule.RedundancyLost.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.PowerModule.RedundancyLost.0", ST_FLAG_RW, 0, "System.Email[1].EventList.PowerModule.RedundancyLost.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.PowerModule.ProtectionLost.1", ST_FLAG_RW, 0, "System.Email[1].EventList.PowerModule.ProtectionLost.1", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.PowerModule.ProtectionLost.0", ST_FLAG_RW, 0, "System.Email[1].EventList.PowerModule.ProtectionLost.0", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.FirmwareUpgrade", ST_FLAG_RW, 0, "System.Email[1].EventList.FirmwareUpgrade", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Environment.CommunicationLost", ST_FLAG_RW, 0, "System.Email[1].EventList.Environment.CommunicationLost", 0, 0, NULL },
|
||||
{ "System.Email[1].EventList.Environment.Notify", ST_FLAG_RW, 0, "System.Email[1].EventList.Environment.Notify", 0, 0, NULL },
|
||||
{ "System.Email[2].Recipient", ST_FLAG_RW, 0, "System.Email[2].Recipient", 0, 0, NULL },
|
||||
{ "System.Email[2].Selected", ST_FLAG_RW, 0, "System.Email[2].Selected", 0, 0, NULL },
|
||||
{ "System.Email[2].Enotify", ST_FLAG_RW, 0, "System.Email[2].Enotify", 0, 0, NULL },
|
||||
{ "System.Email[2].Measures.Log", ST_FLAG_RW, 0, "System.Email[2].Measures.Log", 0, 0, NULL },
|
||||
{ "System.Email[2].Events.Log", ST_FLAG_RW, 0, "System.Email[2].Events.Log", 0, 0, NULL },
|
||||
{ "System.Email[2].SystemEvents.Log", ST_FLAG_RW, 0, "System.Email[2].SystemEvents.Log", 0, 0, NULL },
|
||||
{ "System.Email[2].Environment.Log", ST_FLAG_RW, 0, "System.Email[2].Environment.Log", 0, 0, NULL },
|
||||
{ "System.Email[2].Report.Periodicity", ST_FLAG_RW, 0, "System.Email[2].Report.Periodicity", 0, 0, NULL },
|
||||
{ "System.Email[2].Report.Hour", ST_FLAG_RW, 0, "System.Email[2].Report.Hour", 0, 0, NULL },
|
||||
{ "System.Email[2].Report.Next", ST_FLAG_RW, 0, "System.Email[2].Report.Next", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Discharging", ST_FLAG_RW, 0, "System.Email[2].EventList.Discharging", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.ACPresent", ST_FLAG_RW, 0, "System.Email[2].EventList.ACPresent", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.RunTimeToShutdown", ST_FLAG_RW, 0, "System.Email[2].EventList.RunTimeToShutdown", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.BelowRemainingCapacityLimit", ST_FLAG_RW, 0, "System.Email[2].EventList.BelowRemainingCapacityLimit", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.NeedReplacement.1", ST_FLAG_RW, 0, "System.Email[2].EventList.NeedReplacement.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.NeedReplacement.0", ST_FLAG_RW, 0, "System.Email[2].EventList.NeedReplacement.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Overload.1", ST_FLAG_RW, 0, "System.Email[2].EventList.Overload.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Overload.0", ST_FLAG_RW, 0, "System.Email[2].EventList.Overload.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.InternalFailure.1", ST_FLAG_RW, 0, "System.Email[2].EventList.InternalFailure.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.InternalFailure.0", ST_FLAG_RW, 0, "System.Email[2].EventList.InternalFailure.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.CommunicationLost.1", ST_FLAG_RW, 0, "System.Email[2].EventList.CommunicationLost.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.CommunicationLost.0", ST_FLAG_RW, 0, "System.Email[2].EventList.CommunicationLost.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Charger.InternalFailure", ST_FLAG_RW, 0, "System.Email[2].EventList.Charger.InternalFailure", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Input[2].Used.1", ST_FLAG_RW, 0, "System.Email[2].EventList.Input[2].Used.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Input[2].Used.0", ST_FLAG_RW, 0, "System.Email[2].EventList.Input[2].Used.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.PowerModule.RedundancyLost.1", ST_FLAG_RW, 0, "System.Email[2].EventList.PowerModule.RedundancyLost.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.PowerModule.RedundancyLost.0", ST_FLAG_RW, 0, "System.Email[2].EventList.PowerModule.RedundancyLost.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.PowerModule.ProtectionLost.1", ST_FLAG_RW, 0, "System.Email[2].EventList.PowerModule.ProtectionLost.1", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.PowerModule.ProtectionLost.0", ST_FLAG_RW, 0, "System.Email[2].EventList.PowerModule.ProtectionLost.0", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.FirmwareUpgrade", ST_FLAG_RW, 0, "System.Email[2].EventList.FirmwareUpgrade", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Environment.CommunicationLost", ST_FLAG_RW, 0, "System.Email[2].EventList.Environment.CommunicationLost", 0, 0, NULL },
|
||||
{ "System.Email[2].EventList.Environment.Notify", ST_FLAG_RW, 0, "System.Email[2].EventList.Environment.Notify", 0, 0, NULL },
|
||||
{ "System.Email[3].Recipient", ST_FLAG_RW, 0, "System.Email[3].Recipient", 0, 0, NULL },
|
||||
{ "System.Email[3].Selected", ST_FLAG_RW, 0, "System.Email[3].Selected", 0, 0, NULL },
|
||||
{ "System.Email[3].Enotify", ST_FLAG_RW, 0, "System.Email[3].Enotify", 0, 0, NULL },
|
||||
{ "System.Email[3].Measures.Log", ST_FLAG_RW, 0, "System.Email[3].Measures.Log", 0, 0, NULL },
|
||||
{ "System.Email[3].Events.Log", ST_FLAG_RW, 0, "System.Email[3].Events.Log", 0, 0, NULL },
|
||||
{ "System.Email[3].SystemEvents.Log", ST_FLAG_RW, 0, "System.Email[3].SystemEvents.Log", 0, 0, NULL },
|
||||
{ "System.Email[3].Environment.Log", ST_FLAG_RW, 0, "System.Email[3].Environment.Log", 0, 0, NULL },
|
||||
{ "System.Email[3].Report.Periodicity", ST_FLAG_RW, 0, "System.Email[3].Report.Periodicity", 0, 0, NULL },
|
||||
{ "System.Email[3].Report.Hour", ST_FLAG_RW, 0, "System.Email[3].Report.Hour", 0, 0, NULL },
|
||||
{ "System.Email[3].Report.Next", ST_FLAG_RW, 0, "System.Email[3].Report.Next", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Discharging", ST_FLAG_RW, 0, "System.Email[3].EventList.Discharging", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.ACPresent", ST_FLAG_RW, 0, "System.Email[3].EventList.ACPresent", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.RunTimeToShutdown", ST_FLAG_RW, 0, "System.Email[3].EventList.RunTimeToShutdown", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.BelowRemainingCapacityLimit", ST_FLAG_RW, 0, "System.Email[3].EventList.BelowRemainingCapacityLimit", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.NeedReplacement.1", ST_FLAG_RW, 0, "System.Email[3].EventList.NeedReplacement.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.NeedReplacement.0", ST_FLAG_RW, 0, "System.Email[3].EventList.NeedReplacement.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Overload.1", ST_FLAG_RW, 0, "System.Email[3].EventList.Overload.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Overload.0", ST_FLAG_RW, 0, "System.Email[3].EventList.Overload.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.InternalFailure.1", ST_FLAG_RW, 0, "System.Email[3].EventList.InternalFailure.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.InternalFailure.0", ST_FLAG_RW, 0, "System.Email[3].EventList.InternalFailure.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.CommunicationLost.1", ST_FLAG_RW, 0, "System.Email[3].EventList.CommunicationLost.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.CommunicationLost.0", ST_FLAG_RW, 0, "System.Email[3].EventList.CommunicationLost.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Charger.InternalFailure", ST_FLAG_RW, 0, "System.Email[3].EventList.Charger.InternalFailure", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Input[2].Used.1", ST_FLAG_RW, 0, "System.Email[3].EventList.Input[2].Used.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Input[2].Used.0", ST_FLAG_RW, 0, "System.Email[3].EventList.Input[2].Used.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.PowerModule.RedundancyLost.1", ST_FLAG_RW, 0, "System.Email[3].EventList.PowerModule.RedundancyLost.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.PowerModule.RedundancyLost.0", ST_FLAG_RW, 0, "System.Email[3].EventList.PowerModule.RedundancyLost.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.PowerModule.ProtectionLost.1", ST_FLAG_RW, 0, "System.Email[3].EventList.PowerModule.ProtectionLost.1", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.PowerModule.ProtectionLost.0", ST_FLAG_RW, 0, "System.Email[3].EventList.PowerModule.ProtectionLost.0", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.FirmwareUpgrade", ST_FLAG_RW, 0, "System.Email[3].EventList.FirmwareUpgrade", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Environment.CommunicationLost", ST_FLAG_RW, 0, "System.Email[3].EventList.Environment.CommunicationLost", 0, 0, NULL },
|
||||
{ "System.Email[3].EventList.Environment.Notify", ST_FLAG_RW, 0, "System.Email[3].EventList.Environment.Notify", 0, 0, NULL },
|
||||
{ "System.Schedule[0].Off", ST_FLAG_RW, 0, "System.Schedule[0].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[0].On", ST_FLAG_RW, 0, "System.Schedule[0].On", 0, 0, NULL },
|
||||
{ "System.Schedule[1].Off", ST_FLAG_RW, 0, "System.Schedule[1].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[1].On", ST_FLAG_RW, 0, "System.Schedule[1].On", 0, 0, NULL },
|
||||
{ "System.Schedule[2].Off", ST_FLAG_RW, 0, "System.Schedule[2].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[2].On", ST_FLAG_RW, 0, "System.Schedule[2].On", 0, 0, NULL },
|
||||
{ "System.Schedule[3].Off", ST_FLAG_RW, 0, "System.Schedule[3].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[3].On", ST_FLAG_RW, 0, "System.Schedule[3].On", 0, 0, NULL },
|
||||
{ "System.Schedule[4].Off", ST_FLAG_RW, 0, "System.Schedule[4].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[4].On", ST_FLAG_RW, 0, "System.Schedule[4].On", 0, 0, NULL },
|
||||
{ "System.Schedule[5].Off", ST_FLAG_RW, 0, "System.Schedule[5].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[5].On", ST_FLAG_RW, 0, "System.Schedule[5].On", 0, 0, NULL },
|
||||
{ "System.Schedule[6].Off", ST_FLAG_RW, 0, "System.Schedule[6].Off", 0, 0, NULL },
|
||||
{ "System.Schedule[6].On", ST_FLAG_RW, 0, "System.Schedule[6].On", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[0].Name", ST_FLAG_RW, 0, "System.NetworkManagementSystem[0].Name", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[0].HostName", ST_FLAG_RW, 0, "System.NetworkManagementSystem[0].HostName", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[0].TrapCommunity", ST_FLAG_RW, 0, "System.NetworkManagementSystem[0].TrapCommunity", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[0].TrapSnmpVersion", ST_FLAG_RW, 0, "System.NetworkManagementSystem[0].TrapSnmpVersion", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[0].TrapSelectedMibs", ST_FLAG_RW, 0, "System.NetworkManagementSystem[0].TrapSelectedMibs", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[1].Name", ST_FLAG_RW, 0, "System.NetworkManagementSystem[1].Name", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[1].HostName", ST_FLAG_RW, 0, "System.NetworkManagementSystem[1].HostName", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[1].TrapCommunity", ST_FLAG_RW, 0, "System.NetworkManagementSystem[1].TrapCommunity", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[1].TrapSnmpVersion", ST_FLAG_RW, 0, "System.NetworkManagementSystem[1].TrapSnmpVersion", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[1].TrapSelectedMibs", ST_FLAG_RW, 0, "System.NetworkManagementSystem[1].TrapSelectedMibs", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[2].Name", ST_FLAG_RW, 0, "System.NetworkManagementSystem[2].Name", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[2].HostName", ST_FLAG_RW, 0, "System.NetworkManagementSystem[2].HostName", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[2].TrapCommunity", ST_FLAG_RW, 0, "System.NetworkManagementSystem[2].TrapCommunity", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[2].TrapSnmpVersion", ST_FLAG_RW, 0, "System.NetworkManagementSystem[2].TrapSnmpVersion", 0, 0, NULL },
|
||||
{ "System.NetworkManagementSystem[2].TrapSelectedMibs", ST_FLAG_RW, 0, "System.NetworkManagementSystem[2].TrapSelectedMibs", 0, 0, NULL },
|
||||
{ "System.ClientCfg.ShutdownTimer.Select", ST_FLAG_RW, 0, "System.ClientCfg.ShutdownTimer.Select", 0, 0, NULL },
|
||||
{ "System.ClientCfg.ShutdownTimer", ST_FLAG_RW, 0, "System.ClientCfg.ShutdownTimer", 0, 0, NULL },
|
||||
{ "System.ClientCfg.ShutdownDuration", ST_FLAG_RW, 0, "System.ClientCfg.ShutdownDuration", 0, 0, NULL },
|
||||
{ "System.ClientCfg.BroadcastAdmins", ST_FLAG_RW, 0, "System.ClientCfg.BroadcastAdmins", 0, 0, NULL },
|
||||
{ "System.ClientCfg.BroadcastUsers", ST_FLAG_RW, 0, "System.ClientCfg.BroadcastUsers", 0, 0, NULL },
|
||||
#endif /* not interresting for NUT */
|
||||
{ "Environment.iName", ST_FLAG_RW, 0, "Environment.iName", 0, 0, NULL },
|
||||
{ "Environment.Temperature.Unit", ST_FLAG_RW, 0, "Environment.Temperature.Unit", 0, 0, NULL },
|
||||
{ "Environment.Temperature.HighThreshold", ST_FLAG_RW, 0, "Environment.Temperature.HighThreshold", 0, 0, NULL },
|
||||
{ "Environment.Temperature.LowThreshold", ST_FLAG_RW, 0, "Environment.Temperature.LowThreshold", 0, 0, NULL },
|
||||
{ "Environment.Temperature.Hysteresis", ST_FLAG_RW, 0, "Environment.Temperature.Hysteresis", 0, 0, NULL },
|
||||
{ "Environment.Temperature.Offset", ST_FLAG_RW, 0, "Environment.Temperature.Offset", 0, 0, NULL },
|
||||
{ "Environment.Temperature.HighNotify", ST_FLAG_RW, 0, "Environment.Temperature.HighNotify", 0, 0, NULL },
|
||||
{ "Environment.Temperature.LowNotify", ST_FLAG_RW, 0, "Environment.Temperature.LowNotify", 0, 0, NULL },
|
||||
{ "Environment.Temperature.HighShutdown", ST_FLAG_RW, 0, "Environment.Temperature.HighShutdown", 0, 0, NULL },
|
||||
{ "Environment.Temperature.LowShutdown", ST_FLAG_RW, 0, "Environment.Temperature.LowShutdown", 0, 0, NULL },
|
||||
{ "Environment.Humidity.HighThreshold", ST_FLAG_RW, 0, "Environment.Humidity.HighThreshold", 0, 0, NULL },
|
||||
{ "Environment.Humidity.LowThreshold", ST_FLAG_RW, 0, "Environment.Humidity.LowThreshold", 0, 0, NULL },
|
||||
{ "Environment.Humidity.Hysteresis", ST_FLAG_RW, 0, "Environment.Humidity.Hysteresis", 0, 0, NULL },
|
||||
{ "Environment.Humidity.Offset", ST_FLAG_RW, 0, "Environment.Humidity.Offset", 0, 0, NULL },
|
||||
{ "Environment.Humidity.HighNotify", ST_FLAG_RW, 0, "Environment.Humidity.HighNotify", 0, 0, NULL },
|
||||
{ "Environment.Humidity.LowNotify", ST_FLAG_RW, 0, "Environment.Humidity.LowNotify", 0, 0, NULL },
|
||||
{ "Environment.Humidity.HighShutdown", ST_FLAG_RW, 0, "Environment.Humidity.HighShutdown", 0, 0, NULL },
|
||||
{ "Environment.Humidity.LowShutdown", ST_FLAG_RW, 0, "Environment.Humidity.LowShutdown", 0, 0, NULL },
|
||||
{ "Environment.Input[1].iName", ST_FLAG_RW, 0, "Environment.Input[1].iName", 0, 0, NULL },
|
||||
{ "Environment.Input[1].State[0].Description", ST_FLAG_RW, 0, "Environment.Input[1].State[0].Description", 0, 0, NULL },
|
||||
{ "Environment.Input[1].State[0].Notify", ST_FLAG_RW, 0, "Environment.Input[1].State[0].Notify", 0, 0, NULL },
|
||||
{ "Environment.Input[1].State[0].Shutdown", ST_FLAG_RW, 0, "Environment.Input[1].State[0].Shutdown", 0, 0, NULL },
|
||||
{ "Environment.Input[1].State[1].Description", ST_FLAG_RW, 0, "Environment.Input[1].State[1].Description", 0, 0, NULL },
|
||||
{ "Environment.Input[1].State[1].Notify", ST_FLAG_RW, 0, "Environment.Input[1].State[1].Notify", 0, 0, NULL },
|
||||
{ "Environment.Input[1].State[1].Shutdown", ST_FLAG_RW, 0, "Environment.Input[1].State[1].Shutdown", 0, 0, NULL },
|
||||
{ "Environment.Input[2].iName", ST_FLAG_RW, 0, "Environment.Input[2].iName", 0, 0, NULL },
|
||||
{ "Environment.Input[2].State[0].Description", ST_FLAG_RW, 0, "Environment.Input[2].State[0].Description", 0, 0, NULL },
|
||||
{ "Environment.Input[2].State[0].Notify", ST_FLAG_RW, 0, "Environment.Input[2].State[0].Notify", 0, 0, NULL },
|
||||
{ "Environment.Input[2].State[0].Shutdown", ST_FLAG_RW, 0, "Environment.Input[2].State[0].Shutdown", 0, 0, NULL },
|
||||
{ "Environment.Input[2].State[1].Description", ST_FLAG_RW, 0, "Environment.Input[2].State[1].Description", 0, 0, NULL },
|
||||
{ "Environment.Input[2].State[1].Notify", ST_FLAG_RW, 0, "Environment.Input[2].State[1].Notify", 0, 0, NULL },
|
||||
{ "Environment.Input[2].State[1].Shutdown", ST_FLAG_RW, 0, "Environment.Input[2].State[1].Shutdown", 0, 0, NULL },
|
||||
{ "System.TimeSync", ST_FLAG_RW, 0, "System.TimeSync", 0, 0, NULL },
|
||||
{ "System.TimeNtp", ST_FLAG_RW, 0, "System.TimeNtp", 0, 0, NULL },
|
||||
{ "System.TimeZone", ST_FLAG_RW, 0, "System.TimeZone", 0, 0, NULL },
|
||||
{ "System.TimeDaylight", ST_FLAG_RW, 0, "System.TimeDaylight", 0, 0, NULL },
|
||||
|
||||
/* Special case: boolean values that are mapped to ups.status and ups.alarm */
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", 0, 0, online_info },
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", 0, 0, discharging_info },
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.Charging", 0, 0, charging_info },
|
||||
/* NMC bug: keep discharging test AFTER charging test */
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", 0, 0, discharging_info },
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", 0, 0, lowbatt_info },
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.Overload", 0, 0, overload_info },
|
||||
{ NULL, 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", 0, 0, replacebatt_info },
|
||||
|
@ -573,7 +887,7 @@ static xml_info_t mge_xml2nut[] = {
|
|||
{ "battery.charge.restart", 0, 0, "UPS.PowerSummary.RestartLevel", 0, 0, NULL },
|
||||
{ "battery.capacity", 0, 0, "UPS.BatterySystem.Battery.DesignCapacity", 0, 0, mge_battery_capacity }, /* conversion needed from As to Ah */
|
||||
{ "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", 0, 0, NULL },
|
||||
{ "battery.runtime.low", 0, 0, "System.RunTimeToEmptyLimit", 0, 0, NULL },
|
||||
{ "battery.runtime.low", ST_FLAG_RW, 0, "System.RunTimeToEmptyLimit", 0, 0, NULL },
|
||||
{ "battery.temperature", 0, 0, "UPS.BatterySystem.Battery.Temperature", 0, 0, NULL },
|
||||
{ "battery.type", ST_FLAG_STATIC, 0, "UPS.PowerSummary.iDeviceChemistry", 0, 0, NULL },
|
||||
{ "battery.type", ST_FLAG_STATIC, 0, "UPS.PowerSummary.iDeviceChemistery", 0, 0, NULL }, /* [sic] */
|
||||
|
@ -598,9 +912,12 @@ static xml_info_t mge_xml2nut[] = {
|
|||
{ "ups.firmware", ST_FLAG_STATIC, 0, "UPS.PowerSummary.iVersion", 0, 0, NULL },
|
||||
{ "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", 0, 0, NULL },
|
||||
{ "ups.load.high", 0, 0, "UPS.Flow[4].ConfigPercentLoad", 0, 0, NULL },
|
||||
{ "ups.delay.shutdown", 0, 0, "System.ShutdownDuration", 0, 0, NULL },
|
||||
{ "ups.timer.start", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", 0, 0, NULL},
|
||||
{ "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", 0, 0, mge_timer_shutdown },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW, 0, "System.ShutdownDuration", 0, 0, NULL },
|
||||
{ "ups.timer.start", ST_FLAG_RW, 0, "UPS.PowerSummary.DelayBeforeStartup", 0, 0, NULL},
|
||||
{ "ups.timer.shutdown", ST_FLAG_RW, 0, "UPS.PowerSummary.DelayBeforeShutdown", 0, 0, mge_timer_shutdown },
|
||||
/* Catch shutdown imminent criteria, keep it after
|
||||
UPS.PowerSummary.DelayBeforeShutdown managment */
|
||||
{ NULL, 0, 0, "System.RunTimeToShutdown", 0, 0, mge_shutdown_imminent },
|
||||
{ "ups.timer.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", 0, 0, NULL },
|
||||
{ "ups.test.result", 0, 0, "UPS.BatterySystem.Battery.Test", 0, 0, mge_test_result_info },
|
||||
{ "ups.test.interval", 0, 0, "UPS.BatterySystem.Battery.TestPeriod", 0, 0, NULL },
|
||||
|
@ -722,7 +1039,7 @@ static xml_info_t mge_xml2nut[] = {
|
|||
{ "outlet.1.timer.shutdown", 0, 0, "UPS.OutletSystem.Outlet[2].DelayBeforeShutdown", 0, 0, NULL },
|
||||
{ "outlet.1.delay.start", 0, 0, "UPS.OutletSystem.Outlet[2].StartupTimer", 0, 0, NULL },
|
||||
/* { "outlet.1.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet[2].ShutdownTimer", 0, 0, NULL }, */
|
||||
{ "outlet.1.delay.shutdown", 0, 0, "System.Outlet[2].ShutdownDuration", 0, 0, NULL },
|
||||
{ "outlet.1.delay.shutdown", ST_FLAG_RW, 0, "System.Outlet[2].ShutdownDuration", 0, 0, NULL },
|
||||
|
||||
{ "outlet.2.id", 0, 0, "UPS.OutletSystem.Outlet[3].OutletID", 0, 0, NULL },
|
||||
{ "outlet.2.desc", 0, 0, "UPS.OutletSystem.Outlet[3].iName", 0, 0, NULL },
|
||||
|
@ -733,7 +1050,7 @@ static xml_info_t mge_xml2nut[] = {
|
|||
{ "outlet.2.timer.shutdown", 0, 0, "UPS.OutletSystem.Outlet[3].DelayBeforeShutdown", 0, 0, NULL },
|
||||
{ "outlet.2.delay.start", 0, 0, "UPS.OutletSystem.Outlet[3].StartupTimer", 0, 0, NULL },
|
||||
/* { "outlet.2.delay.shutdown", 0, 0, "UPS.OutletSystem.Outlet[3].ShutdownTimer", 0, 0, NULL }, */
|
||||
{ "outlet.2.delay.shutdown", 0, 0, "System.Outlet[3].ShutdownDuration", 0, 0, NULL },
|
||||
{ "outlet.2.delay.shutdown", ST_FLAG_RW, 0, "System.Outlet[3].ShutdownDuration", 0, 0, NULL },
|
||||
|
||||
/* For newer ePDU Monitored */
|
||||
{ "outlet.1.desc", 0, 0, "PDU.OutletSystem.Outlet[1].iName", 0, 0, NULL },
|
||||
|
@ -1118,3 +1435,83 @@ subdriver_t mge_xml_subdriver = {
|
|||
mge_xml_cdata_cb,
|
||||
mge_xml_endelm_cb,
|
||||
};
|
||||
|
||||
const char *vname_nut2mge_xml(const char *name) {
|
||||
assert(NULL != name);
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
for (; i < sizeof(mge_xml2nut) / sizeof(xml_info_t); ++i) {
|
||||
xml_info_t *info = mge_xml2nut + i;
|
||||
|
||||
if (NULL != info->nutname)
|
||||
if (0 == strcasecmp(name, info->nutname))
|
||||
return info->xmlname;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *vname_mge_xml2nut(const char *name) {
|
||||
assert(NULL != name);
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
for (; i < sizeof(mge_xml2nut) / sizeof(xml_info_t); ++i) {
|
||||
xml_info_t *info = mge_xml2nut + i;
|
||||
|
||||
if (NULL != info->xmlname)
|
||||
if (0 == strcasecmp(name, info->xmlname))
|
||||
return info->nutname;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *vvalue_mge_xml2nut(const char *name, const char *value, size_t len) {
|
||||
assert(NULL != name);
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
for (; i < sizeof(mge_xml2nut) / sizeof(xml_info_t); ++i) {
|
||||
xml_info_t *info = mge_xml2nut + i;
|
||||
|
||||
if (NULL != info->nutname)
|
||||
if (0 == strcasecmp(name, info->nutname)) {
|
||||
/* Copy value */
|
||||
char *vcpy = (char *)malloc((len + 1) * sizeof(char));
|
||||
|
||||
if (NULL == vcpy)
|
||||
return vcpy;
|
||||
|
||||
memcpy(vcpy, value, len * sizeof(char));
|
||||
vcpy[len] = '\0';
|
||||
|
||||
/* Convert */
|
||||
if (NULL != info->convert) {
|
||||
char *vconv = info->convert(vcpy);
|
||||
|
||||
free(vcpy);
|
||||
|
||||
return vconv;
|
||||
}
|
||||
else
|
||||
return vcpy;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void vname_register_rw(void) {
|
||||
size_t i = 0;
|
||||
|
||||
for (; i < sizeof(mge_xml2nut) / sizeof(xml_info_t); ++i) {
|
||||
xml_info_t *info = mge_xml2nut + i;
|
||||
|
||||
if (NULL != info->nutname && info->nutflags & ST_FLAG_RW) {
|
||||
dstate_setinfo(info->nutname, "");
|
||||
dstate_setflags(info->nutname, ST_FLAG_RW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,4 +25,41 @@
|
|||
|
||||
extern subdriver_t mge_xml_subdriver;
|
||||
|
||||
/**
|
||||
* \brief Convert NUT variable name to MGE XML
|
||||
*
|
||||
* \param name NUT variable name
|
||||
*
|
||||
* \return MGE XML variable name
|
||||
*/
|
||||
const char *vname_nut2mge_xml(const char *name);
|
||||
|
||||
/**
|
||||
* \brief Convert MGE XML variable name to NUT
|
||||
*
|
||||
* \param name MGE XML variable name
|
||||
*
|
||||
* \return NUT variable name
|
||||
*/
|
||||
const char * vname_mge_xml2nut(const char *name);
|
||||
|
||||
/**
|
||||
* \brief Convert MGE XML variable value to NUT value
|
||||
*
|
||||
* The function produces a newly created C-string that should
|
||||
* be destroyed using \c free.
|
||||
*
|
||||
* \param name NUT variable name
|
||||
* \param value MGE XML variable value
|
||||
* \param len MGE XML variable value length (in characters)
|
||||
*
|
||||
* \return NUT variable value
|
||||
*/
|
||||
char *vvalue_mge_xml2nut(const char *name, const char *value, size_t len);
|
||||
|
||||
/**
|
||||
* \brief Register set of R/W variables
|
||||
*/
|
||||
void vname_register_rw(void);
|
||||
|
||||
#endif /* MGE_XML_H */
|
||||
|
|
1118
drivers/netxml-ups.c
1118
drivers/netxml-ups.c
File diff suppressed because it is too large
Load diff
|
@ -27,7 +27,7 @@
|
|||
#include "nut-ipmi.h"
|
||||
|
||||
#define DRIVER_NAME "IPMI PSU driver"
|
||||
#define DRIVER_VERSION "0.07"
|
||||
#define DRIVER_VERSION "0.30"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
|
@ -183,17 +183,20 @@ void upsdrv_makevartable(void)
|
|||
"Type of the device to match ('psu' for \"Power Supply\")");
|
||||
|
||||
addvar(VAR_VALUE, "serial", "Serial number to match a specific device");
|
||||
addvar(VAR_VALUE, "fruid", "FRU identifier to match a specific device");
|
||||
addvar(VAR_VALUE, "sensorid", "Sensor identifier to match a specific device"); */
|
||||
addvar(VAR_VALUE, "fruid", "FRU identifier to match a specific device"); */
|
||||
}
|
||||
|
||||
void upsdrv_initups(void)
|
||||
{
|
||||
upsdebugx(1, "upsdrv_initups...");
|
||||
|
||||
/* port can be expressed using:
|
||||
* "id?" for device (FRU) ID 0x?
|
||||
* "psu?" for PSU number ?
|
||||
/* port can be expressed in various forms:
|
||||
* - inband:
|
||||
* "id?" for device (FRU) ID 0x?
|
||||
* "psu?" for PSU number ?
|
||||
* - out of band
|
||||
* "id?@host"
|
||||
* "host" => requires serial or ...
|
||||
*/
|
||||
if (!strncmp( device_path, "id", 2))
|
||||
{
|
||||
|
|
|
@ -42,10 +42,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "timehead.h"
|
||||
#include "common.h"
|
||||
#include <freeipmi/freeipmi.h>
|
||||
#include <ipmi_monitoring.h>
|
||||
#if HAVE_FREEIPMI_MONITORING
|
||||
#include <ipmi_monitoring_bitmasks.h>
|
||||
#include "common.h"
|
||||
#endif
|
||||
#include "nut-ipmi.h"
|
||||
#include "dstate.h"
|
||||
|
||||
|
@ -57,18 +59,46 @@
|
|||
|
||||
/* FreeIPMI contexts and configuration*/
|
||||
ipmi_ctx_t ipmi_ctx = NULL;
|
||||
ipmi_fru_parse_ctx_t fru_parse_ctx = NULL;
|
||||
ipmi_monitoring_ctx_t mon_ctx = NULL;
|
||||
struct ipmi_monitoring_ipmi_config ipmi_config;
|
||||
|
||||
/* SDR management API has changed with 1.1.X and later */
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
ipmi_sdr_ctx_t sdr_ctx = NULL;
|
||||
ipmi_fru_ctx_t fru_ctx = NULL;
|
||||
#define SDR_PARSE_CTX sdr_ctx
|
||||
#else
|
||||
ipmi_sdr_cache_ctx_t sdr_cache_ctx = NULL;
|
||||
ipmi_sdr_cache_ctx_t sdr_ctx = NULL;
|
||||
ipmi_sdr_parse_ctx_t sdr_parse_ctx = NULL;
|
||||
#ifndef IPMI_SDR_MAX_RECORD_LENGTH
|
||||
#define IPMI_SDR_MAX_RECORD_LENGTH IPMI_SDR_CACHE_MAX_SDR_RECORD_LENGTH
|
||||
#endif
|
||||
#define SDR_PARSE_CTX sdr_parse_ctx
|
||||
ipmi_fru_parse_ctx_t fru_ctx = NULL;
|
||||
/* Functions remapping */
|
||||
#define ipmi_sdr_ctx_create ipmi_sdr_cache_ctx_create
|
||||
#define ipmi_sdr_ctx_destroy ipmi_sdr_cache_ctx_destroy
|
||||
#define ipmi_sdr_ctx_errnum ipmi_sdr_cache_ctx_errnum
|
||||
#define ipmi_sdr_ctx_errormsg ipmi_sdr_cache_ctx_errormsg
|
||||
#define ipmi_fru_ctx_create ipmi_fru_parse_ctx_create
|
||||
#define ipmi_fru_ctx_destroy ipmi_fru_parse_ctx_destroy
|
||||
#define ipmi_fru_ctx_set_flags ipmi_fru_parse_ctx_set_flags
|
||||
#define ipmi_fru_ctx_strerror ipmi_fru_parse_ctx_strerror
|
||||
#define ipmi_fru_ctx_errnum ipmi_fru_parse_ctx_errnum
|
||||
#define ipmi_fru_open_device_id ipmi_fru_parse_open_device_id
|
||||
#define ipmi_fru_close_device_id ipmi_fru_parse_close_device_id
|
||||
#define ipmi_fru_ctx_errormsg ipmi_fru_parse_ctx_errormsg
|
||||
#define ipmi_fru_read_data_area ipmi_fru_parse_read_data_area
|
||||
#define ipmi_fru_next ipmi_fru_parse_next
|
||||
#define ipmi_fru_type_length_field_to_string ipmi_fru_parse_type_length_field_to_string
|
||||
#define ipmi_fru_multirecord_power_supply_information ipmi_fru_parse_multirecord_power_supply_information
|
||||
#define ipmi_fru_board_info_area ipmi_fru_parse_board_info_area
|
||||
#define ipmi_fru_field_t ipmi_fru_parse_field_t
|
||||
/* Constants */
|
||||
#define IPMI_SDR_MAX_RECORD_LENGTH IPMI_SDR_CACHE_MAX_SDR_RECORD_LENGTH
|
||||
#define IPMI_SDR_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST IPMI_SDR_CACHE_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST
|
||||
#define IPMI_FRU_AREA_SIZE_MAX IPMI_FRU_PARSE_AREA_SIZE_MAX
|
||||
#define IPMI_FRU_FLAGS_SKIP_CHECKSUM_CHECKS IPMI_FRU_PARSE_FLAGS_SKIP_CHECKSUM_CHECKS
|
||||
#define IPMI_FRU_AREA_TYPE_BOARD_INFO_AREA IPMI_FRU_PARSE_AREA_TYPE_BOARD_INFO_AREA
|
||||
#define IPMI_FRU_AREA_TYPE_MULTIRECORD_POWER_SUPPLY_INFORMATION IPMI_FRU_PARSE_AREA_TYPE_MULTIRECORD_POWER_SUPPLY_INFORMATION
|
||||
#define IPMI_FRU_AREA_STRING_MAX IPMI_FRU_PARSE_AREA_STRING_MAX
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
/* FIXME: freeipmi auto selects a cache based on the hostname you are
|
||||
|
@ -78,7 +108,7 @@ struct ipmi_monitoring_ipmi_config ipmi_config;
|
|||
|
||||
/* Support functions */
|
||||
static const char* libfreeipmi_getfield (uint8_t language_code,
|
||||
ipmi_fru_parse_field_t *field);
|
||||
ipmi_fru_field_t *field);
|
||||
|
||||
static void libfreeipmi_cleanup();
|
||||
|
||||
|
@ -97,7 +127,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev);
|
|||
int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev)
|
||||
{
|
||||
int ret = -1;
|
||||
uint8_t areabuf[IPMI_FRU_PARSE_AREA_SIZE_MAX+1];
|
||||
uint8_t areabuf[IPMI_FRU_AREA_SIZE_MAX+1];
|
||||
unsigned int area_type = 0;
|
||||
unsigned int area_length = 0;
|
||||
|
||||
|
@ -134,26 +164,26 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev)
|
|||
upsdebugx(1, "FreeIPMI initialized...");
|
||||
|
||||
/* Parse FRU information */
|
||||
if (!(fru_parse_ctx = ipmi_fru_parse_ctx_create (ipmi_ctx)))
|
||||
if (!(fru_ctx = ipmi_fru_ctx_create (ipmi_ctx)))
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_fru_parse_ctx_create()");
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_fru_ctx_create()");
|
||||
}
|
||||
|
||||
/* lots of motherboards calculate checksums incorrectly */
|
||||
if (ipmi_fru_parse_ctx_set_flags (fru_parse_ctx, IPMI_FRU_PARSE_FLAGS_SKIP_CHECKSUM_CHECKS) < 0)
|
||||
if (ipmi_fru_ctx_set_flags (fru_ctx, IPMI_FRU_FLAGS_SKIP_CHECKSUM_CHECKS) < 0)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_parse_ctx_set_flags: %s\n",
|
||||
ipmi_fru_parse_ctx_strerror (ipmi_fru_parse_ctx_errnum (fru_parse_ctx)));
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_ctx_set_flags: %s\n",
|
||||
ipmi_fru_ctx_strerror (ipmi_fru_ctx_errnum (fru_ctx)));
|
||||
}
|
||||
|
||||
/* Now open the requested (local) PSU */
|
||||
if (ipmi_fru_parse_open_device_id (fru_parse_ctx, ipmi_id) < 0)
|
||||
if (ipmi_fru_open_device_id (fru_ctx, ipmi_id) < 0)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_parse_open_device_id: %s\n",
|
||||
ipmi_fru_parse_ctx_errormsg (fru_parse_ctx));
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_open_device_id: %s\n",
|
||||
ipmi_fru_ctx_errormsg (fru_ctx));
|
||||
}
|
||||
|
||||
/* Set IPMI identifier */
|
||||
|
@ -164,19 +194,19 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev)
|
|||
/* clear fields */
|
||||
area_type = 0;
|
||||
area_length = 0;
|
||||
memset (areabuf, '\0', IPMI_FRU_PARSE_AREA_SIZE_MAX + 1);
|
||||
memset (areabuf, '\0', IPMI_FRU_AREA_SIZE_MAX + 1);
|
||||
|
||||
/* parse FRU buffer */
|
||||
if (ipmi_fru_parse_read_data_area (fru_parse_ctx,
|
||||
if (ipmi_fru_read_data_area (fru_ctx,
|
||||
&area_type,
|
||||
&area_length,
|
||||
areabuf,
|
||||
IPMI_FRU_PARSE_AREA_SIZE_MAX) < 0)
|
||||
IPMI_FRU_AREA_SIZE_MAX) < 0)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE,
|
||||
"ipmi_fru_parse_open_device_id: %s\n",
|
||||
ipmi_fru_parse_ctx_errormsg (fru_parse_ctx));
|
||||
"ipmi_fru_read_data_area: %s\n",
|
||||
ipmi_fru_ctx_errormsg (fru_ctx));
|
||||
}
|
||||
|
||||
if (area_length)
|
||||
|
@ -184,7 +214,7 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev)
|
|||
switch (area_type)
|
||||
{
|
||||
/* get generic board information */
|
||||
case IPMI_FRU_PARSE_AREA_TYPE_BOARD_INFO_AREA:
|
||||
case IPMI_FRU_AREA_TYPE_BOARD_INFO_AREA:
|
||||
|
||||
if(libfreeipmi_get_board_info (areabuf, area_length,
|
||||
ipmi_dev) < 0)
|
||||
|
@ -193,7 +223,7 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev)
|
|||
}
|
||||
break;
|
||||
/* get specific PSU information */
|
||||
case IPMI_FRU_PARSE_AREA_TYPE_MULTIRECORD_POWER_SUPPLY_INFORMATION:
|
||||
case IPMI_FRU_AREA_TYPE_MULTIRECORD_POWER_SUPPLY_INFORMATION:
|
||||
|
||||
if(libfreeipmi_get_psu_info (areabuf, area_length, ipmi_dev) < 0)
|
||||
{
|
||||
|
@ -205,13 +235,13 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev)
|
|||
break;
|
||||
}
|
||||
}
|
||||
} while ((ret = ipmi_fru_parse_next (fru_parse_ctx)) == 1);
|
||||
} while ((ret = ipmi_fru_next (fru_ctx)) == 1);
|
||||
|
||||
/* check for errors */
|
||||
if (ret < 0) {
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_fru_parse_next: %s",
|
||||
ipmi_fru_parse_ctx_errormsg (fru_parse_ctx));
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_fru_next: %s",
|
||||
ipmi_fru_ctx_errormsg (fru_ctx));
|
||||
}
|
||||
else {
|
||||
/* Get all related sensors information */
|
||||
|
@ -232,25 +262,25 @@ void nut_ipmi_close(void)
|
|||
}
|
||||
|
||||
static const char* libfreeipmi_getfield (uint8_t language_code,
|
||||
ipmi_fru_parse_field_t *field)
|
||||
ipmi_fru_field_t *field)
|
||||
{
|
||||
static char strbuf[IPMI_FRU_PARSE_AREA_STRING_MAX + 1];
|
||||
unsigned int strbuflen = IPMI_FRU_PARSE_AREA_STRING_MAX;
|
||||
static char strbuf[IPMI_FRU_AREA_STRING_MAX + 1];
|
||||
unsigned int strbuflen = IPMI_FRU_AREA_STRING_MAX;
|
||||
|
||||
if (!field->type_length_field_length)
|
||||
return NULL;
|
||||
|
||||
memset (strbuf, '\0', IPMI_FRU_PARSE_AREA_STRING_MAX + 1);
|
||||
memset (strbuf, '\0', IPMI_FRU_AREA_STRING_MAX + 1);
|
||||
|
||||
if (ipmi_fru_parse_type_length_field_to_string (fru_parse_ctx,
|
||||
if (ipmi_fru_type_length_field_to_string (fru_ctx,
|
||||
field->type_length_field,
|
||||
field->type_length_field_length,
|
||||
language_code,
|
||||
strbuf,
|
||||
&strbuflen) < 0)
|
||||
{
|
||||
upsdebugx (2, "ipmi_fru_parse_type_length_field_to_string: %s",
|
||||
ipmi_fru_parse_ctx_errormsg (fru_parse_ctx));
|
||||
upsdebugx (2, "ipmi_fru_type_length_field_to_string: %s",
|
||||
ipmi_fru_ctx_errormsg (fru_ctx));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -279,24 +309,20 @@ static float libfreeipmi_get_voltage (uint8_t voltage_code)
|
|||
static void libfreeipmi_cleanup()
|
||||
{
|
||||
/* cleanup */
|
||||
if (fru_parse_ctx) {
|
||||
ipmi_fru_parse_close_device_id (fru_parse_ctx);
|
||||
ipmi_fru_parse_ctx_destroy (fru_parse_ctx);
|
||||
if (fru_ctx) {
|
||||
ipmi_fru_close_device_id (fru_ctx);
|
||||
ipmi_fru_ctx_destroy (fru_ctx);
|
||||
}
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (sdr_ctx) {
|
||||
ipmi_sdr_ctx_destroy (sdr_ctx);
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (sdr_cache_ctx) {
|
||||
ipmi_sdr_cache_ctx_destroy (sdr_cache_ctx);
|
||||
}
|
||||
|
||||
#ifndef HAVE_FREEIPMI_11X_12X
|
||||
if (sdr_parse_ctx) {
|
||||
ipmi_sdr_parse_ctx_destroy (sdr_parse_ctx);
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
#endif
|
||||
|
||||
if (ipmi_ctx) {
|
||||
ipmi_ctx_close (ipmi_ctx);
|
||||
|
@ -342,7 +368,7 @@ static int libfreeipmi_get_psu_info (const void *areabuf,
|
|||
|
||||
upsdebugx(1, "entering libfreeipmi_get_psu_info()");
|
||||
|
||||
if (ipmi_fru_parse_multirecord_power_supply_information (fru_parse_ctx,
|
||||
if (ipmi_fru_multirecord_power_supply_information (fru_ctx,
|
||||
areabuf,
|
||||
area_length,
|
||||
&overall_capacity,
|
||||
|
@ -368,8 +394,8 @@ static int libfreeipmi_get_psu_info (const void *areabuf,
|
|||
&total_combined_wattage,
|
||||
&predictive_fail_tachometer_lower_threshold) < 0)
|
||||
{
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_parse_multirecord_power_supply_information: %s",
|
||||
ipmi_fru_parse_ctx_errormsg (fru_parse_ctx));
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_multirecord_power_supply_information: %s",
|
||||
ipmi_fru_ctx_errormsg (fru_ctx));
|
||||
}
|
||||
|
||||
ipmi_dev->overall_capacity = overall_capacity;
|
||||
|
@ -383,6 +409,8 @@ static int libfreeipmi_get_psu_info (const void *areabuf,
|
|||
|
||||
ipmi_dev->voltage = libfreeipmi_get_voltage(voltage_1);
|
||||
|
||||
upsdebugx(1, "libfreeipmi_get_psu_info() retrieved successfully");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -392,12 +420,12 @@ static int libfreeipmi_get_board_info (const void *areabuf,
|
|||
{
|
||||
uint8_t language_code;
|
||||
uint32_t mfg_date_time;
|
||||
ipmi_fru_parse_field_t board_manufacturer;
|
||||
ipmi_fru_parse_field_t board_product_name;
|
||||
ipmi_fru_parse_field_t board_serial_number;
|
||||
ipmi_fru_parse_field_t board_part_number;
|
||||
ipmi_fru_parse_field_t board_fru_file_id;
|
||||
ipmi_fru_parse_field_t board_custom_fields[IPMI_FRU_CUSTOM_FIELDS];
|
||||
ipmi_fru_field_t board_manufacturer;
|
||||
ipmi_fru_field_t board_product_name;
|
||||
ipmi_fru_field_t board_serial_number;
|
||||
ipmi_fru_field_t board_part_number;
|
||||
ipmi_fru_field_t board_fru_file_id;
|
||||
ipmi_fru_field_t board_custom_fields[IPMI_FRU_CUSTOM_FIELDS];
|
||||
const char *string = NULL;
|
||||
time_t timetmp;
|
||||
struct tm mfg_date_time_tm;
|
||||
|
@ -406,15 +434,15 @@ static int libfreeipmi_get_board_info (const void *areabuf,
|
|||
upsdebugx(1, "entering libfreeipmi_get_board_info()");
|
||||
|
||||
/* clear fields */
|
||||
memset (&board_manufacturer, '\0', sizeof (ipmi_fru_parse_field_t));
|
||||
memset (&board_product_name, '\0', sizeof (ipmi_fru_parse_field_t));
|
||||
memset (&board_serial_number, '\0', sizeof (ipmi_fru_parse_field_t));
|
||||
memset (&board_fru_file_id, '\0', sizeof (ipmi_fru_parse_field_t));
|
||||
memset (&board_manufacturer, '\0', sizeof (ipmi_fru_field_t));
|
||||
memset (&board_product_name, '\0', sizeof (ipmi_fru_field_t));
|
||||
memset (&board_serial_number, '\0', sizeof (ipmi_fru_field_t));
|
||||
memset (&board_fru_file_id, '\0', sizeof (ipmi_fru_field_t));
|
||||
memset (&board_custom_fields[0], '\0',
|
||||
sizeof (ipmi_fru_parse_field_t) * IPMI_FRU_CUSTOM_FIELDS);
|
||||
sizeof (ipmi_fru_field_t) * IPMI_FRU_CUSTOM_FIELDS);
|
||||
|
||||
/* parse FRU buffer */
|
||||
if (ipmi_fru_parse_board_info_area (fru_parse_ctx,
|
||||
if (ipmi_fru_board_info_area (fru_ctx,
|
||||
areabuf,
|
||||
area_length,
|
||||
&language_code,
|
||||
|
@ -428,8 +456,8 @@ static int libfreeipmi_get_board_info (const void *areabuf,
|
|||
IPMI_FRU_CUSTOM_FIELDS) < 0)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_parse_board_info_area: %s",
|
||||
ipmi_fru_parse_ctx_errormsg (fru_parse_ctx));
|
||||
fatalx(EXIT_FAILURE, "ipmi_fru_board_info_area: %s",
|
||||
ipmi_fru_ctx_errormsg (fru_ctx));
|
||||
}
|
||||
|
||||
|
||||
|
@ -498,13 +526,20 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
ipmi_dev->sensors_count = 0;
|
||||
memset(ipmi_dev->sensors_id_list, 0, sizeof(ipmi_dev->sensors_id_list));
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (!(sdr_ctx = ipmi_sdr_ctx_create ()))
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_ctx_create()");
|
||||
}
|
||||
|
||||
#ifndef HAVE_FREEIPMI_11X_12X
|
||||
if (!(sdr_parse_ctx = ipmi_sdr_parse_ctx_create ()))
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_parse_ctx_create()");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ipmi_sdr_cache_open (sdr_ctx, ipmi_ctx, CACHE_LOCATION) < 0)
|
||||
{
|
||||
if (ipmi_sdr_ctx_errnum (sdr_ctx) != IPMI_SDR_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST)
|
||||
|
@ -514,97 +549,41 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
}
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (!(sdr_cache_ctx = ipmi_sdr_cache_ctx_create ()))
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_ctx_create()");
|
||||
}
|
||||
|
||||
if (!(sdr_parse_ctx = ipmi_sdr_parse_ctx_create ()))
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_parse_ctx_create()");
|
||||
}
|
||||
|
||||
if (ipmi_sdr_cache_open (sdr_cache_ctx, ipmi_ctx, CACHE_LOCATION) < 0)
|
||||
{
|
||||
if (ipmi_sdr_cache_ctx_errnum (sdr_cache_ctx) != IPMI_SDR_CACHE_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_open: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (ipmi_sdr_ctx_errnum (sdr_ctx) == IPMI_SDR_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST)
|
||||
{
|
||||
if (ipmi_sdr_cache_create (sdr_ctx,
|
||||
ipmi_ctx, CACHE_LOCATION,
|
||||
IPMI_SDR_CACHE_CREATE_FLAGS_DEFAULT,
|
||||
#ifndef HAVE_FREEIPMI_11X_12X
|
||||
IPMI_SDR_CACHE_VALIDATION_FLAGS_DEFAULT,
|
||||
#endif
|
||||
NULL, NULL) < 0)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_create: %s",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
}
|
||||
if (ipmi_sdr_cache_open (sdr_ctx,
|
||||
ipmi_ctx, CACHE_LOCATION) < 0)
|
||||
if (ipmi_sdr_cache_open (sdr_ctx, ipmi_ctx, CACHE_LOCATION) < 0)
|
||||
{
|
||||
if (ipmi_sdr_ctx_errnum (sdr_ctx) != IPMI_SDR_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_open: %s",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_open: %s",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
}
|
||||
}
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (ipmi_sdr_cache_ctx_errnum (sdr_cache_ctx) == IPMI_SDR_CACHE_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST)
|
||||
{
|
||||
if (ipmi_sdr_cache_create (sdr_cache_ctx,
|
||||
ipmi_ctx, CACHE_LOCATION,
|
||||
IPMI_SDR_CACHE_CREATE_FLAGS_DEFAULT,
|
||||
IPMI_SDR_CACHE_VALIDATION_FLAGS_DEFAULT,
|
||||
NULL, NULL) < 0)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_create: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
}
|
||||
if (ipmi_sdr_cache_open (sdr_cache_ctx,
|
||||
ipmi_ctx, CACHE_LOCATION) < 0)
|
||||
{
|
||||
if (ipmi_sdr_cache_ctx_errnum (sdr_cache_ctx) != IPMI_SDR_CACHE_ERR_CACHE_READ_CACHE_DOES_NOT_EXIST)
|
||||
{
|
||||
libfreeipmi_cleanup();
|
||||
fatal_with_errno(EXIT_FAILURE, "ipmi_sdr_cache_open: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (ipmi_sdr_cache_record_count (sdr_ctx, &record_count) < 0) {
|
||||
if (ipmi_sdr_cache_record_count (sdr_ctx, &record_count) < 0) {
|
||||
fprintf (stderr,
|
||||
"ipmi_sdr_cache_record_count: %s",
|
||||
"ipmi_sdr_cache_record_count: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else
|
||||
if (ipmi_sdr_cache_record_count (sdr_cache_ctx, &record_count) < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"ipmi_sdr_cache_record_count: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
upsdebugx(3, "Found %i records in SDR cache", record_count);
|
||||
|
||||
for (i = 0; i < record_count; i++, ipmi_sdr_cache_next (sdr_ctx))
|
||||
{
|
||||
memset (sdr_record, '\0', IPMI_SDR_MAX_RECORD_LENGTH);
|
||||
|
@ -613,50 +592,29 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
sdr_record,
|
||||
IPMI_SDR_MAX_RECORD_LENGTH)) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_cache_record_read: %s",
|
||||
fprintf (stderr, "ipmi_sdr_cache_record_read: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
if (ipmi_sdr_parse_record_id_and_type (sdr_ctx,
|
||||
if (ipmi_sdr_parse_record_id_and_type (SDR_PARSE_CTX,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
NULL,
|
||||
&record_type) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_record_id_and_type: %s",
|
||||
fprintf (stderr, "ipmi_sdr_parse_record_id_and_type: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < record_count; i++, ipmi_sdr_cache_next (sdr_cache_ctx))
|
||||
{
|
||||
memset (sdr_record, '\0', IPMI_SDR_MAX_RECORD_LENGTH);
|
||||
|
||||
if ((sdr_record_len = ipmi_sdr_cache_record_read (sdr_cache_ctx,
|
||||
sdr_record,
|
||||
IPMI_SDR_MAX_RECORD_LENGTH)) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_cache_record_read: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
if (ipmi_sdr_parse_record_id_and_type (sdr_parse_ctx,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
NULL,
|
||||
&record_type) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_record_id_and_type: %s",
|
||||
ipmi_sdr_parse_ctx_errormsg (sdr_parse_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
upsdebugx (5, "Checking record %i (/%i)", i, record_count);
|
||||
|
||||
if (record_type != IPMI_SDR_FORMAT_FRU_DEVICE_LOCATOR_RECORD)
|
||||
if (record_type != IPMI_SDR_FORMAT_FRU_DEVICE_LOCATOR_RECORD) {
|
||||
upsdebugx(1, "=======> not device locator (%i)!!", record_type);
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (ipmi_sdr_parse_fru_device_locator_parameters (sdr_ctx,
|
||||
if (ipmi_sdr_parse_fru_device_locator_parameters (SDR_PARSE_CTX,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
NULL,
|
||||
|
@ -666,86 +624,49 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
&logical_physical_fru_device,
|
||||
NULL) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_fru_device_locator_parameters: %s",
|
||||
fprintf (stderr, "ipmi_sdr_parse_fru_device_locator_parameters: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (ipmi_sdr_parse_fru_device_locator_parameters (sdr_parse_ctx,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
NULL,
|
||||
&logical_fru_device_device_slave_address,
|
||||
NULL,
|
||||
NULL,
|
||||
&logical_physical_fru_device,
|
||||
NULL) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_fru_device_locator_parameters: %s",
|
||||
ipmi_sdr_parse_ctx_errormsg (sdr_parse_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
upsdebugx(2, "Checking device %i/%i", logical_physical_fru_device,
|
||||
logical_fru_device_device_slave_address);
|
||||
|
||||
if (logical_physical_fru_device
|
||||
&& logical_fru_device_device_slave_address == ipmi_dev->ipmi_id)
|
||||
{
|
||||
found_device_id++;
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (ipmi_sdr_parse_fru_entity_id_and_instance (sdr_ctx,
|
||||
if (ipmi_sdr_parse_fru_entity_id_and_instance (SDR_PARSE_CTX,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
&entity_id,
|
||||
&entity_instance) < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"ipmi_sdr_parse_fru_entity_id_and_instance: %s",
|
||||
"ipmi_sdr_parse_fru_entity_id_and_instance: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (ipmi_sdr_parse_fru_entity_id_and_instance (sdr_parse_ctx,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
&entity_id,
|
||||
&entity_instance) < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"ipmi_sdr_parse_fru_entity_id_and_instance: %s",
|
||||
ipmi_sdr_parse_ctx_errormsg (sdr_parse_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_device_id)
|
||||
{
|
||||
fprintf (stderr, "Couldn't find device id %d", ipmi_dev->ipmi_id);
|
||||
fprintf (stderr, "Couldn't find device id %d\n", ipmi_dev->ipmi_id);
|
||||
goto cleanup;
|
||||
}
|
||||
else
|
||||
upsdebugx(1, "Found device id %d", ipmi_dev->ipmi_id);
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (ipmi_sdr_cache_first (sdr_ctx) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_cache_first: %s",
|
||||
fprintf (stderr, "ipmi_sdr_cache_first: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (ipmi_sdr_cache_first (sdr_cache_ctx) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_cache_first: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
for (i = 0; i < record_count; i++, ipmi_sdr_cache_next (sdr_ctx))
|
||||
{
|
||||
/* uint8_t sdr_record[IPMI_SDR_CACHE_MAX_SDR_RECORD_LENGTH];
|
||||
|
@ -757,49 +678,21 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
sdr_record,
|
||||
IPMI_SDR_MAX_RECORD_LENGTH)) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_cache_record_read: %s",
|
||||
fprintf (stderr, "ipmi_sdr_cache_record_read: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (ipmi_sdr_parse_record_id_and_type (sdr_ctx,
|
||||
if (ipmi_sdr_parse_record_id_and_type (SDR_PARSE_CTX,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
&record_id,
|
||||
&record_type) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_record_id_and_type: %s",
|
||||
fprintf (stderr, "ipmi_sdr_parse_record_id_and_type: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
for (i = 0; i < record_count; i++, ipmi_sdr_cache_next (sdr_cache_ctx))
|
||||
{
|
||||
/* uint8_t sdr_record[IPMI_SDR_CACHE_MAX_SDR_RECORD_LENGTH];
|
||||
uint8_t record_type, tmp_entity_id, tmp_entity_instance;
|
||||
int sdr_record_len; */
|
||||
|
||||
memset (sdr_record, '\0', IPMI_SDR_MAX_RECORD_LENGTH);
|
||||
if ((sdr_record_len = ipmi_sdr_cache_record_read (sdr_cache_ctx,
|
||||
sdr_record,
|
||||
IPMI_SDR_MAX_RECORD_LENGTH)) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_cache_record_read: %s",
|
||||
ipmi_sdr_cache_ctx_errormsg (sdr_cache_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (ipmi_sdr_parse_record_id_and_type (sdr_parse_ctx,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
&record_id,
|
||||
&record_type) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_record_id_and_type: %s",
|
||||
ipmi_sdr_parse_ctx_errormsg (sdr_parse_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
upsdebugx (5, "Checking record %i (/%i)", record_id, record_count);
|
||||
|
||||
|
@ -809,31 +702,17 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (ipmi_sdr_parse_entity_id_instance_type (sdr_ctx,
|
||||
if (ipmi_sdr_parse_entity_id_instance_type (SDR_PARSE_CTX,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
&tmp_entity_id,
|
||||
&tmp_entity_instance,
|
||||
NULL) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_entity_instance_type: %s",
|
||||
fprintf (stderr, "ipmi_sdr_parse_entity_instance_type: %s\n",
|
||||
ipmi_sdr_ctx_errormsg (sdr_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (ipmi_sdr_parse_entity_id_instance_type (sdr_parse_ctx,
|
||||
sdr_record,
|
||||
sdr_record_len,
|
||||
&tmp_entity_id,
|
||||
&tmp_entity_instance,
|
||||
NULL) < 0)
|
||||
{
|
||||
fprintf (stderr, "ipmi_sdr_parse_entity_instance_type: %s",
|
||||
ipmi_sdr_parse_ctx_errormsg (sdr_parse_ctx));
|
||||
goto cleanup;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_11X_12X */
|
||||
|
||||
if (tmp_entity_id == entity_id
|
||||
&& tmp_entity_instance == entity_instance)
|
||||
|
@ -850,15 +729,11 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev)
|
|||
|
||||
cleanup:
|
||||
/* Cleanup */
|
||||
#ifdef HAVE_FREEIPMI_11X_12X
|
||||
if (sdr_ctx) {
|
||||
ipmi_sdr_ctx_destroy (sdr_ctx);
|
||||
}
|
||||
#else /* HAVE_FREEIPMI_11X_12X */
|
||||
if (sdr_cache_ctx) {
|
||||
ipmi_sdr_cache_ctx_destroy (sdr_cache_ctx);
|
||||
}
|
||||
|
||||
#ifndef HAVE_FREEIPMI_11X_12X
|
||||
if (sdr_parse_ctx) {
|
||||
ipmi_sdr_parse_ctx_destroy (sdr_parse_ctx);
|
||||
}
|
||||
|
|
2439
drivers/nutdrv_qx.c
Normal file
2439
drivers/nutdrv_qx.c
Normal file
File diff suppressed because it is too large
Load diff
172
drivers/nutdrv_qx.h
Normal file
172
drivers/nutdrv_qx.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
/* nutdrv_qx.h - Driver for USB and serial UPS units with Q* protocols
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
* Based on usbhid-ups.h - Copyright (C)
|
||||
* 2003-2009 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
|
||||
* 2005-2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
* 2007-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 NUTDRV_QX_H
|
||||
#define NUTDRV_QX_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "config.h"
|
||||
|
||||
/* For testing purposes */
|
||||
/*#define TESTING*/
|
||||
|
||||
/* Driver's parameters */
|
||||
#define QX_VAR_ONDELAY "ondelay"
|
||||
#define QX_VAR_OFFDELAY "offdelay"
|
||||
#define QX_VAR_POLLFREQ "pollfreq"
|
||||
|
||||
/* Parameters default values */
|
||||
#define DEFAULT_ONDELAY "180" /* Delay between return of utility power and powering up of load, in seconds */
|
||||
#define DEFAULT_OFFDELAY "30" /* Delay before power off, in seconds */
|
||||
#define DEFAULT_POLLFREQ 30 /* Polling interval between full updates, in seconds; the driver will do quick polls in the meantime */
|
||||
|
||||
typedef enum { FALSE, TRUE } bool_t;
|
||||
|
||||
/* Structure for rw vars */
|
||||
typedef struct {
|
||||
char value[SMALLBUF]; /* Value for enum/range, or length for ST_FLAG_STRING */
|
||||
int (*preprocess)(char *value, size_t len); /* Optional function to preprocess range/enum value.
|
||||
* This function will be given value and its size_t and must return either 0 if value is supported or -1 if not supported. */
|
||||
} info_rw_t;
|
||||
|
||||
/* Structure containing information about how to get/set data from/to the UPS and convert these to/from NUT standard */
|
||||
typedef struct item_t {
|
||||
const char *info_type; /* NUT variable name
|
||||
* If QX_FLAG_NONUT is set, name to print to the logs
|
||||
* If both QX_FLAG_NONUT and QX_FLAG_SETVAR are set, name of the var to retrieve from ups.conf */
|
||||
const int info_flags; /* NUT flags (ST_FLAG_* values to set in dstate_addinfo) */
|
||||
info_rw_t *info_rw; /* An array of info_rw_t to handle r/w variables:
|
||||
* If ST_FLAG_STRING is set: length of the string (dstate_setaux)
|
||||
* If QX_FLAG_ENUM is set: enumerated values (dstate_addenum)
|
||||
* If QX_FLAG_RANGE is set: range boundaries (dstate_addrange)
|
||||
* If QX_FLAG_SETVAR is set the value given by the user will be checked against these infos. */
|
||||
const char *command; /* Command sent to the UPS to get answer/to execute an instant command/to set a variable */
|
||||
|
||||
char answer[SMALLBUF]; /* Answer from the UPS, filled at runtime */
|
||||
const int answer_len; /* Expected min length of the answer. Set it to 0 if there’s no minimum length to look after. */
|
||||
const char leading; /* Expected leading character of the answer (optional) */
|
||||
|
||||
char value[SMALLBUF]; /* Value from the answer, filled at runtime (i.e. answer between from and to) */
|
||||
const int from; /* Position of the starting character of the info (i.e. 'value') we're after in the answer */
|
||||
const int to; /* Position of the ending character of the info (i.e. 'value') we're after in the answer: use 0 if all the remaining of the line is needed */
|
||||
|
||||
const char *dfl; /* Format to store value from the UPS in NUT variables. Not used by the driver for QX_FLAG_{CMD,SETVAR} items.
|
||||
* If there's no preprocess function, set it either to %s for strings or to a floating point specifier (e.g. %.1f) for numbers.
|
||||
* Otherwise:
|
||||
* If QX_FLAG_ABSENT: default value
|
||||
* If QX_FLAG_CMD: default command value */
|
||||
|
||||
unsigned long qxflags; /* Driver's own flags */
|
||||
|
||||
int (*preprocess)(struct item_t *item, char *value, size_t valuelen); /* Function to preprocess the data from/to the UPS
|
||||
* This function is given the currently processed item (item), a char array (value) and its size_t (valuelen).
|
||||
* Return -1 in case of errors, else 0.
|
||||
* If QX_FLAG_SETVAR/QX_FLAG_CMD -> process command before it is sent: value must be filled with the command to be sent to the UPS.
|
||||
* Otherwise -> process value we got from answer before it gets stored in a NUT variable: value must be filled with the processed value already compliant to NUT standards. */
|
||||
} item_t;
|
||||
|
||||
/* Driver's own flags */
|
||||
#define QX_FLAG_STATIC 2 /* Retrieve info only once. */
|
||||
#define QX_FLAG_SEMI_STATIC 4 /* Retrieve info smartly, i.e. only when a command/setvar is executed and we expect that data could have been changed. */
|
||||
#define QX_FLAG_ABSENT 8 /* Data is absent in the device, use default value. */
|
||||
#define QX_FLAG_QUICK_POLL 16 /* Mandatory vars, polled also in QX_WALKMODE_QUICK_UPDATE.
|
||||
* If there’s a problem with a var not flagged as QX_FLAG_QUICK_POLL in QX_WALKMODE_INIT, the driver will automagically set QX_FLAG_SKIP on it and then it’ll skip that item in QX_WALKMODE_{QUICK,FULL}_UPDATE.
|
||||
* Otherwise, if the item has the flag QX_FLAG_QUICK_POLL set, in case of errors in QX_WALKMODE_INIT the driver will set datastale. */
|
||||
#define QX_FLAG_CMD 32 /* Instant command. */
|
||||
#define QX_FLAG_SETVAR 64 /* The var is settable and the actual item stores info on how to set it. */
|
||||
#define QX_FLAG_TRIM 128 /* This var's value need to be trimmed of leading/trailing spaces/hashes. */
|
||||
#define QX_FLAG_ENUM 256 /* Enum values exist and are stored in info_rw. */
|
||||
#define QX_FLAG_RANGE 512 /* Ranges for this var available and are stored in info_rw. */
|
||||
#define QX_FLAG_NONUT 1024 /* This var doesn't have a corresponding var in NUT. */
|
||||
#define QX_FLAG_SKIP 2048 /* Skip this var: this item won’t be processed. */
|
||||
|
||||
#define MAXTRIES 3 /* Max number of retries */
|
||||
|
||||
/* Testing struct */
|
||||
typedef struct {
|
||||
const char *cmd; /* Command to match */
|
||||
const char *answer; /* Answer for that command */
|
||||
} testing_t;
|
||||
|
||||
/* Subdriver interface */
|
||||
typedef struct {
|
||||
const char *name; /* Name of this subdriver, i.e. name (must be equal to the protocol name) + space + version */
|
||||
int (*claim)(void); /* Function that allows the subdriver to "claim" a device: return 1 if device is covered by this subdriver, else 0 */
|
||||
item_t *qx2nut; /* Main table of vars and instcmds */
|
||||
void (*initups)(void); /* Subdriver specific upsdrv_initups. Called at the end of nutdrv_qx's own upsdrv_initups */
|
||||
void (*initinfo)(void); /* Subdriver specific upsdrv_initinfo. Called at the end of nutdrv_qx's own upsdrv_initinfo */
|
||||
void (*makevartable)(void); /* Subdriver specific ups.conf flags/vars */
|
||||
const char *accepted; /* String to match if the driver is expecting a reply from the UPS on instcmd/setvar.
|
||||
* This comparison is done after the answer we got back from the UPS has been processed to get the value we are searching:
|
||||
* - you don’t have to include the trailing carriage return (\r)
|
||||
* - you can decide at which index of the answer the value should start or end setting the appropriate from and to in the item_t */
|
||||
const char *rejected; /* String to match if the driver is expecting a reply from the UPS in case of error.
|
||||
* This comparison is done on the answer we got back from the UPS before it has been processed:
|
||||
* - include also the trailing carriage return (\r) and whatever character is expected */
|
||||
#ifdef TESTING
|
||||
testing_t *testing; /* Testing table: commands and the replies used for testing the subdriver */
|
||||
#endif /* TESTING */
|
||||
} subdriver_t;
|
||||
|
||||
/* The following functions are exported for the benefit of subdrivers */
|
||||
/* Execute an instant command. Return STAT_INSTCMD_INVALID if the command is invalid, STAT_INSTCMD_FAILED if it failed, STAT_INSTCMD_HANDLED on success. */
|
||||
int instcmd(const char *cmdname, const char *extradata);
|
||||
/* Set r/w variable to a value after it has been checked against its info_rw structure. Return STAT_SET_HANDLED on success, otherwise STAT_SET_UNKNOWN. */
|
||||
int setvar(const char *varname, const char *val);
|
||||
/* Find an item of item_t type in qx2nut data structure by its info_type, optionally filtered by its qxflags, and return it if found, otherwise return NULL.
|
||||
* - 'flag': flags that have to be set in the item, i.e. if one of the flags is absent in the item it won't be returned
|
||||
* - 'noflag': flags that have to be absent in the item, i.e. if at least one of the flags is set in the item it won't be returned */
|
||||
item_t *find_nut_info(const char *varname, const unsigned long flag, const unsigned long noflag);
|
||||
/* Send 'command' or, if it is NULL, send the command stored in the item to the UPS and process the reply. Return -1 on errors, 0 on success. */
|
||||
int qx_process(item_t *item, const char *command);
|
||||
/* Process the value we got back from the UPS (set status bits and set the value of other parameters), calling its preprocess function, if any. Return -1 on failure, 0 for a status update and 1 in all other cases. */
|
||||
int ups_infoval_set(item_t *item);
|
||||
/* Return the currently processed status so that it can be checked with one of the status_bit_t passed to the STATUS() macro. */
|
||||
int qx_status(void);
|
||||
/* Edit the current status: it takes one of the NUT status (all but OB are supported, simply set it as not OL), eventually preceded with an exclamation mark to clear it from the status (e.g. !OL). */
|
||||
void update_status(const char *nutvalue);
|
||||
|
||||
/* Data for processing status values */
|
||||
#define STATUS(x) ((unsigned)1<<x)
|
||||
|
||||
typedef enum {
|
||||
OL = 0, /* On line */
|
||||
LB, /* Low battery */
|
||||
RB, /* Replace battery */
|
||||
CHRG, /* Charging */
|
||||
DISCHRG, /* Discharging */
|
||||
BYPASS, /* On bypass */
|
||||
CAL, /* Calibration */
|
||||
OFF, /* UPS is off */
|
||||
OVER, /* Overload */
|
||||
TRIM, /* SmartTrim */
|
||||
BOOST, /* SmartBoost */
|
||||
FSD, /* Shutdown imminent */
|
||||
} status_bit_t;
|
||||
|
||||
#endif /* NUTDRV_QX_H */
|
355
drivers/nutdrv_qx_blazer-common.c
Normal file
355
drivers/nutdrv_qx_blazer-common.c
Normal file
|
@ -0,0 +1,355 @@
|
|||
/* nutdrv_qx_blazer-common.c - Common functions/settings for nutdrv_qx_{mecer,megatec,megatec-old,mustek,zinto}.{c,h}
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "nutdrv_qx.h"
|
||||
#include "nutdrv_qx_blazer-common.h"
|
||||
|
||||
/* == Ranges == */
|
||||
|
||||
/* Range for ups.delay.start */
|
||||
info_rw_t blazer_r_ondelay[] = {
|
||||
{ "0", 0 },
|
||||
{ "599940", 0 },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
/* Range for ups.delay.shutdown */
|
||||
info_rw_t blazer_r_offdelay[] = {
|
||||
{ "12", 0 },
|
||||
{ "600", 0 },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
/* == Support functions == */
|
||||
|
||||
/* This function allows the subdriver to "claim" a device: return 1 if the device is supported by this subdriver, else 0. */
|
||||
int blazer_claim(void) {
|
||||
|
||||
/* To tell whether the UPS is supported or not, we'll check both status (Q1/QS/D) and vendor (I/FW?) - provided that we were not told not to do it with the ups.conf flag 'novendor'. */
|
||||
|
||||
item_t *item = find_nut_info("input.voltage", 0, 0);
|
||||
|
||||
/* Don't know what happened */
|
||||
if (!item)
|
||||
return 0;
|
||||
|
||||
/* No reply/Unable to get value */
|
||||
if (qx_process(item, NULL))
|
||||
return 0;
|
||||
|
||||
/* Unable to process value */
|
||||
if (ups_infoval_set(item) != 1)
|
||||
return 0;
|
||||
|
||||
if (testvar("novendor"))
|
||||
return 1;
|
||||
|
||||
/* Vendor */
|
||||
item = find_nut_info("ups.firmware", 0, 0);
|
||||
|
||||
/* Don't know what happened */
|
||||
if (!item) {
|
||||
dstate_delinfo("input.voltage");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* No reply/Unable to get value */
|
||||
if (qx_process(item, NULL)) {
|
||||
dstate_delinfo("input.voltage");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unable to process value */
|
||||
if (ups_infoval_set(item) != 1) {
|
||||
dstate_delinfo("input.voltage");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/* Subdriver-specific flags/vars */
|
||||
void blazer_makevartable(void)
|
||||
{
|
||||
addvar(VAR_FLAG, "norating", "Skip reading rating information from UPS");
|
||||
addvar(VAR_FLAG, "novendor", "Skip reading vendor information from UPS");
|
||||
}
|
||||
|
||||
/* Subdriver-specific initups */
|
||||
void blazer_initups(item_t *qx2nut)
|
||||
{
|
||||
int nr, nv;
|
||||
item_t *item;
|
||||
|
||||
nr = testvar("norating");
|
||||
nv = testvar("novendor");
|
||||
|
||||
if (!nr && !nv)
|
||||
return;
|
||||
|
||||
for (item = qx2nut; item->info_type != NULL; item++) {
|
||||
|
||||
if (!item->command)
|
||||
continue;
|
||||
|
||||
/* norating */
|
||||
if (nr && !strcasecmp(item->command, "F\r")) {
|
||||
upsdebugx(2, "%s: skipping %s", __func__, item->info_type);
|
||||
item->qxflags |= QX_FLAG_SKIP;
|
||||
}
|
||||
|
||||
/* novendor */
|
||||
if (nv && (!strcasecmp(item->command, "I\r") || !strcasecmp(item->command, "FW?\r"))) {
|
||||
upsdebugx(2, "%s: skipping %s", __func__, item->info_type);
|
||||
item->qxflags |= QX_FLAG_SKIP;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* == Preprocess functions == */
|
||||
|
||||
/* Preprocess setvars */
|
||||
int blazer_process_setvar(item_t *item, char *value, size_t valuelen)
|
||||
{
|
||||
if (!strlen(value)) {
|
||||
upsdebugx(2, "%s: value not given for %s", __func__, item->info_type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcasecmp(item->info_type, "ups.delay.start")) {
|
||||
|
||||
int ondelay = strtol(value, NULL, 10);
|
||||
|
||||
/* Truncate to minute */
|
||||
ondelay -= (ondelay % 60);
|
||||
|
||||
snprintf(value, valuelen, "%d", ondelay);
|
||||
|
||||
} else if (!strcasecmp(item->info_type, "ups.delay.shutdown")) {
|
||||
|
||||
int offdelay = strtol(value, NULL, 10);
|
||||
|
||||
/* Truncate to nearest settable value */
|
||||
if (offdelay < 60) {
|
||||
offdelay -= (offdelay % 6);
|
||||
} else {
|
||||
offdelay -= (offdelay % 60);
|
||||
}
|
||||
|
||||
snprintf(value, valuelen, "%d", offdelay);
|
||||
|
||||
} else {
|
||||
|
||||
/* Don't know what happened */
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Preprocess instant commands */
|
||||
int blazer_process_command(item_t *item, char *value, size_t valuelen)
|
||||
{
|
||||
if (!strcasecmp(item->info_type, "shutdown.return")) {
|
||||
|
||||
/* Sn: Shutdown after n minutes and then turn on when mains is back
|
||||
* SnRm: Shutdown after n minutes and then turn on after m minutes
|
||||
* Accepted values for n: .2 -> .9 , 01 -> 10
|
||||
* Accepted values for m: 0001 -> 9999
|
||||
* Note: "S01R0001" and "S01R0002" may not work on early (GE) firmware versions.
|
||||
* The failure mode is that the UPS turns off and never returns.
|
||||
* The fix is to push the return value up by 2, i.e. S01R0003, and it will return online properly.
|
||||
* (thus the default of ondelay=3 mins) */
|
||||
|
||||
int offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10),
|
||||
ondelay = strtol(dstate_getinfo("ups.delay.start"), NULL, 10) / 60;
|
||||
char buf[SMALLBUF] = "";
|
||||
|
||||
if (ondelay == 0) {
|
||||
|
||||
if (offdelay < 60) {
|
||||
snprintf(buf, sizeof(buf), ".%d", offdelay / 6);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%02d", offdelay / 60);
|
||||
}
|
||||
|
||||
} else if (offdelay < 60) {
|
||||
|
||||
snprintf(buf, sizeof(buf), ".%dR%04d", offdelay / 6, ondelay);
|
||||
|
||||
} else {
|
||||
|
||||
snprintf(buf, sizeof(buf), "%02dR%04d", offdelay / 60, ondelay);
|
||||
|
||||
}
|
||||
|
||||
snprintf(value, valuelen, item->command, buf);
|
||||
|
||||
} else if (!strcasecmp(item->info_type, "shutdown.stayoff")) {
|
||||
|
||||
/* SnR0000
|
||||
* Shutdown after n minutes and stay off
|
||||
* Accepted values for n: .2 -> .9 , 01 -> 10 */
|
||||
|
||||
int offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10);
|
||||
char buf[SMALLBUF] = "";
|
||||
|
||||
if (offdelay < 60) {
|
||||
snprintf(buf, sizeof(buf), ".%d", offdelay / 6);
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%02d", offdelay / 60);
|
||||
}
|
||||
|
||||
snprintf(value, valuelen, item->command, buf);
|
||||
|
||||
} else if (!strcasecmp(item->info_type, "test.battery.start")) {
|
||||
|
||||
int delay = strlen(value) > 0 ? strtol(value, NULL, 10) : 600;
|
||||
|
||||
if ((delay < 60) || (delay > 5940)) {
|
||||
upslogx(LOG_ERR, "%s: battery test time '%d' out of range [60..5940] seconds", item->info_type, delay);
|
||||
return -1;
|
||||
}
|
||||
|
||||
delay = delay / 60;
|
||||
|
||||
snprintf(value, valuelen, item->command, delay);
|
||||
|
||||
} else {
|
||||
|
||||
/* Don't know what happened */
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Process status bits */
|
||||
int blazer_process_status_bits(item_t *item, char *value, size_t valuelen)
|
||||
{
|
||||
char *val = "";
|
||||
|
||||
if (strspn(item->value, "01") != 1) {
|
||||
upsdebugx(3, "%s: unexpected value %s@%d->%s", __func__, item->value, item->from, item->value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (item->from)
|
||||
{
|
||||
case 38: /* Utility Fail (Immediate) */
|
||||
|
||||
if (item->value[0] == '1')
|
||||
val = "!OL";
|
||||
else
|
||||
val = "OL";
|
||||
break;
|
||||
|
||||
case 39: /* Battery Low */
|
||||
|
||||
if (item->value[0] == '1')
|
||||
val = "LB";
|
||||
else
|
||||
val = "!LB";
|
||||
break;
|
||||
|
||||
case 40: /* Bypass/Boost or Buck Active */
|
||||
|
||||
if (item->value[0] == '1') {
|
||||
|
||||
double vi, vo;
|
||||
|
||||
vi = strtod(dstate_getinfo("input.voltage"), NULL);
|
||||
vo = strtod(dstate_getinfo("output.voltage"), NULL);
|
||||
|
||||
if (vo < 0.5 * vi) {
|
||||
upsdebugx(2, "%s: output voltage too low", __func__);
|
||||
return -1;
|
||||
} else if (vo < 0.95 * vi) {
|
||||
val = "TRIM";
|
||||
} else if (vo < 1.05 * vi) {
|
||||
val = "BYPASS";
|
||||
} else if (vo < 1.5 * vi) {
|
||||
val = "BOOST";
|
||||
} else {
|
||||
upsdebugx(2, "%s: output voltage too high", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 41: /* UPS Failed - ups.alarm */
|
||||
|
||||
if (item->value[0] == '1')
|
||||
val = "UPS selftest failed!";
|
||||
break;
|
||||
|
||||
case 42: /* UPS Type - ups.type */
|
||||
|
||||
if (item->value[0] == '1')
|
||||
val = "offline / line interactive";
|
||||
else
|
||||
val = "online";
|
||||
break;
|
||||
|
||||
case 43: /* Test in Progress */
|
||||
|
||||
if (item->value[0] == '1')
|
||||
val = "CAL";
|
||||
else
|
||||
val = "!CAL";
|
||||
break;
|
||||
|
||||
case 44: /* Shutdown Active */
|
||||
|
||||
if (item->value[0] == '1') {
|
||||
if (!strcasecmp(item->info_type, "ups.status"))
|
||||
val = "FSD";
|
||||
else /* ups.alarm */
|
||||
val = "Shutdown imminent!";
|
||||
} else if (!strcasecmp(item->info_type, "ups.status")) {
|
||||
val = "!FSD";
|
||||
}
|
||||
break;
|
||||
|
||||
case 45: /* Beeper status - ups.beeper.status */
|
||||
|
||||
if (item->value[0] == '1')
|
||||
val = "enabled";
|
||||
else
|
||||
val = "disabled";
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Don't know what happened */
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(value, valuelen, "%s", val);
|
||||
|
||||
return 0;
|
||||
}
|
41
drivers/nutdrv_qx_blazer-common.h
Normal file
41
drivers/nutdrv_qx_blazer-common.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* nutdrv_qx_blazer-common.h - Common functions/settings for nutdrv_qx_{mecer,megatec,megatec-old,mustek,zinto}.{c,h}
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_BLAZER_COMMON_H
|
||||
#define NUTDRV_QX_BLAZER_COMMON_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
/* Support functions */
|
||||
void blazer_makevartable(void);
|
||||
void blazer_initups(item_t *qx2nut);
|
||||
int blazer_claim(void);
|
||||
|
||||
/* Preprocess functions */
|
||||
int blazer_process_command(item_t *item, char *value, size_t valuelen);
|
||||
int blazer_process_setvar(item_t *item, char *value, size_t valuelen);
|
||||
int blazer_process_status_bits(item_t *item, char *value, size_t valuelen);
|
||||
|
||||
/* Ranges */
|
||||
extern info_rw_t blazer_r_ondelay[];
|
||||
extern info_rw_t blazer_r_offdelay[];
|
||||
|
||||
#endif /* NUTDRV_QX_BLAZER_COMMON_H */
|
143
drivers/nutdrv_qx_mecer.c
Normal file
143
drivers/nutdrv_qx_mecer.c
Normal file
|
@ -0,0 +1,143 @@
|
|||
/* nutdrv_qx_mecer.c - Subdriver for Mecer UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "nutdrv_qx.h"
|
||||
#include "nutdrv_qx_blazer-common.h"
|
||||
|
||||
#include "nutdrv_qx_mecer.h"
|
||||
|
||||
#define MECER_VERSION "Mecer 0.01"
|
||||
|
||||
/* qx2nut lookup table */
|
||||
static item_t mecer_qx2nut[] = {
|
||||
|
||||
/*
|
||||
* > [Q1\r]
|
||||
* < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
|
||||
* 01234567890123456789012345678901234567890123456
|
||||
* 0 1 2 3 4
|
||||
*/
|
||||
|
||||
{ "input.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL },
|
||||
{ "input.voltage.fault", 0, NULL, "Q1\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL },
|
||||
{ "output.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL },
|
||||
{ "ups.load", 0, NULL, "Q1\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL },
|
||||
{ "input.frequency", 0, NULL, "Q1\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL },
|
||||
{ "battery.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL },
|
||||
{ "ups.temperature", 0, NULL, "Q1\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL },
|
||||
/* Status bits */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Utility Fail (Immediate) */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Battery Low */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */
|
||||
{ "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 41, 41, NULL, 0, blazer_process_status_bits }, /* UPS Failed */
|
||||
{ "ups.type", 0, NULL, "Q1\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, blazer_process_status_bits }, /* UPS Type */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Test in Progress */
|
||||
{ "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, 0, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.beeper.status", 0, NULL, "Q1\r", "", 47, '(', "", 45, 45, "%s", 0, blazer_process_status_bits }, /* Beeper status */
|
||||
|
||||
/*
|
||||
* > [F\r]
|
||||
* < [#220.0 000 024.0 50.0\r]
|
||||
* 0123456789012345678901
|
||||
* 0 1 2
|
||||
*/
|
||||
|
||||
{ "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
|
||||
/*
|
||||
* > [I\r]
|
||||
* < [#------------- ------ VT12046Q \r]
|
||||
* 012345678901234567890123456789012345678
|
||||
* 0 1 2 3
|
||||
*/
|
||||
|
||||
{ "device.mfr", 0, NULL, "I\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "device.model", 0, NULL, "I\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "ups.firmware", 0, NULL, "I\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
|
||||
/* Instant commands
|
||||
* The UPS will reply '(ACK\r' in case of success, '(NAK\r' if the command is rejected or invalid */
|
||||
|
||||
{ "beeper.toggle", 0, NULL, "Q\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.off", 0, NULL, "S00R0000\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.on", 0, NULL, "C\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "shutdown.return", 0, NULL, "S%s\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stop", 0, NULL, "C\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start", 0, NULL, "T%02d\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "test.battery.start.deep", 0, NULL, "TL\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start.quick", 0, NULL, "T\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.stop", 0, NULL, "CT\r", "", 5, '(', "", 1, 3, NULL, QX_FLAG_CMD, NULL },
|
||||
|
||||
/* Server-side settable vars */
|
||||
{ "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
|
||||
/* End of structure. */
|
||||
{ NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/* Testing table */
|
||||
#ifdef TESTING
|
||||
static testing_t mecer_testing[] = {
|
||||
{ "Q1\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r" },
|
||||
{ "F\r", "#230.0 000 024.0 50.0\r" },
|
||||
{ "I\r", "#NOT_A_LIVE_UPS TESTING TESTING \r" },
|
||||
{ "Q\r", "(ACK\r" },
|
||||
{ "S03\r", "(NAK\r" },
|
||||
{ "C\r", "(NAK\r" },
|
||||
{ "S02R0005\r", "(ACK\r" },
|
||||
{ "S.5R0000\r", "(ACK\r" },
|
||||
{ "T04\r", "(NAK\r" },
|
||||
{ "TL\r", "(ACK\r" },
|
||||
{ "T\r", "(NAK\r" },
|
||||
{ "CT\r", "(ACK\r" },
|
||||
{ NULL }
|
||||
};
|
||||
#endif /* TESTING */
|
||||
|
||||
/* Subdriver-specific initups */
|
||||
static void mecer_initups(void)
|
||||
{
|
||||
|
||||
blazer_initups(mecer_qx2nut);
|
||||
|
||||
}
|
||||
|
||||
/* Subdriver interface */
|
||||
subdriver_t mecer_subdriver = {
|
||||
MECER_VERSION,
|
||||
blazer_claim,
|
||||
mecer_qx2nut,
|
||||
mecer_initups,
|
||||
NULL,
|
||||
blazer_makevartable,
|
||||
"ACK",
|
||||
"(NAK\r",
|
||||
#ifdef TESTING
|
||||
mecer_testing,
|
||||
#endif /* TESTING */
|
||||
};
|
29
drivers/nutdrv_qx_mecer.h
Normal file
29
drivers/nutdrv_qx_mecer.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* nutdrv_qx_mecer.h - Subdriver for Mecer UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_MECER_H
|
||||
#define NUTDRV_QX_MECER_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
extern subdriver_t mecer_subdriver;
|
||||
|
||||
#endif /* NUTDRV_QX_MECER_H */
|
141
drivers/nutdrv_qx_megatec-old.c
Normal file
141
drivers/nutdrv_qx_megatec-old.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* nutdrv_qx_megatec-old.c - Subdriver for Megatec/old protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "nutdrv_qx.h"
|
||||
#include "nutdrv_qx_blazer-common.h"
|
||||
|
||||
#include "nutdrv_qx_megatec-old.h"
|
||||
|
||||
#define MEGATEC_OLD_VERSION "Megatec/old 0.01"
|
||||
|
||||
/* qx2nut lookup table */
|
||||
static item_t megatec_old_qx2nut[] = {
|
||||
|
||||
/*
|
||||
* > [D\r]
|
||||
* < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
|
||||
* 01234567890123456789012345678901234567890123456
|
||||
* 0 1 2 3 4
|
||||
*/
|
||||
|
||||
{ "input.voltage", 0, NULL, "D\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL },
|
||||
{ "input.voltage.fault", 0, NULL, "D\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL },
|
||||
{ "output.voltage", 0, NULL, "D\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL },
|
||||
{ "ups.load", 0, NULL, "D\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL },
|
||||
{ "input.frequency", 0, NULL, "D\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL },
|
||||
{ "battery.voltage", 0, NULL, "D\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL },
|
||||
{ "ups.temperature", 0, NULL, "D\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL },
|
||||
/* Status bits */
|
||||
{ "ups.status", 0, NULL, "D\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Utility Fail (Immediate) */
|
||||
{ "ups.status", 0, NULL, "D\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Battery Low */
|
||||
{ "ups.status", 0, NULL, "D\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */
|
||||
{ "ups.alarm", 0, NULL, "D\r", "", 47, '(', "", 41, 41, NULL, 0, blazer_process_status_bits }, /* UPS Failed */
|
||||
{ "ups.type", 0, NULL, "D\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, blazer_process_status_bits }, /* UPS Type */
|
||||
{ "ups.status", 0, NULL, "D\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Test in Progress */
|
||||
{ "ups.alarm", 0, NULL, "D\r", "", 47, '(', "", 44, 44, NULL, 0, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.status", 0, NULL, "D\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.beeper.status", 0, NULL, "D\r", "", 47, '(', "", 45, 45, "%s", 0, blazer_process_status_bits }, /* Beeper status */
|
||||
|
||||
/*
|
||||
* > [F\r]
|
||||
* < [#220.0 000 024.0 50.0\r]
|
||||
* 0123456789012345678901
|
||||
* 0 1 2
|
||||
*/
|
||||
|
||||
{ "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
|
||||
/*
|
||||
* > [I\r]
|
||||
* < [#------------- ------ VT12046Q \r]
|
||||
* 012345678901234567890123456789012345678
|
||||
* 0 1 2 3
|
||||
*/
|
||||
|
||||
{ "device.mfr", 0, NULL, "I\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "device.model", 0, NULL, "I\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "ups.firmware", 0, NULL, "I\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
|
||||
/* Instant commands */
|
||||
{ "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.off", 0, NULL, "S00R0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
|
||||
/* Server-side settable vars */
|
||||
{ "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
|
||||
/* End of structure. */
|
||||
{ NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/* Testing table */
|
||||
#ifdef TESTING
|
||||
static testing_t megatec_old_testing[] = {
|
||||
{ "D\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r" },
|
||||
{ "F\r", "#230.0 000 024.0 50.0\r" },
|
||||
{ "I\r", "#NOT_A_LIVE_UPS TESTING TESTING \r" },
|
||||
{ "Q\r", "" },
|
||||
{ "S03\r", "" },
|
||||
{ "C\r", "" },
|
||||
{ "S02R0005\r", "" },
|
||||
{ "S.5R0000\r", "" },
|
||||
{ "T04\r", "" },
|
||||
{ "TL\r", "" },
|
||||
{ "T\r", "" },
|
||||
{ "CT\r", "" },
|
||||
{ NULL }
|
||||
};
|
||||
#endif /* TESTING */
|
||||
|
||||
/* Subdriver-specific initups */
|
||||
static void megatec_old_initups(void)
|
||||
{
|
||||
|
||||
blazer_initups(megatec_old_qx2nut);
|
||||
|
||||
}
|
||||
|
||||
/* Subdriver interface */
|
||||
subdriver_t megatec_old_subdriver = {
|
||||
MEGATEC_OLD_VERSION,
|
||||
blazer_claim,
|
||||
megatec_old_qx2nut,
|
||||
megatec_old_initups,
|
||||
NULL,
|
||||
blazer_makevartable,
|
||||
"ACK",
|
||||
NULL,
|
||||
#ifdef TESTING
|
||||
megatec_old_testing,
|
||||
#endif /* TESTING */
|
||||
};
|
29
drivers/nutdrv_qx_megatec-old.h
Normal file
29
drivers/nutdrv_qx_megatec-old.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* nutdrv_qx_megatec-old.h - Subdriver for Megatec/old protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_MEGATEC_OLD_H
|
||||
#define NUTDRV_QX_MEGATEC_OLD_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
extern subdriver_t megatec_old_subdriver;
|
||||
|
||||
#endif /* NUTDRV_QX_MEGATECH_OLD_H */
|
141
drivers/nutdrv_qx_megatec.c
Normal file
141
drivers/nutdrv_qx_megatec.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* nutdrv_qx_megatec.c - Subdriver for Megatec protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "nutdrv_qx.h"
|
||||
#include "nutdrv_qx_blazer-common.h"
|
||||
|
||||
#include "nutdrv_qx_megatec.h"
|
||||
|
||||
#define MEGATEC_VERSION "Megatec 0.01"
|
||||
|
||||
/* qx2nut lookup table */
|
||||
static item_t megatec_qx2nut[] = {
|
||||
|
||||
/*
|
||||
* > [Q1\r]
|
||||
* < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
|
||||
* 01234567890123456789012345678901234567890123456
|
||||
* 0 1 2 3 4
|
||||
*/
|
||||
|
||||
{ "input.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL },
|
||||
{ "input.voltage.fault", 0, NULL, "Q1\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL },
|
||||
{ "output.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL },
|
||||
{ "ups.load", 0, NULL, "Q1\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL },
|
||||
{ "input.frequency", 0, NULL, "Q1\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL },
|
||||
{ "battery.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL },
|
||||
{ "ups.temperature", 0, NULL, "Q1\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL },
|
||||
/* Status bits */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Utility Fail (Immediate) */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Battery Low */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */
|
||||
{ "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 41, 41, NULL, 0, blazer_process_status_bits }, /* UPS Failed */
|
||||
{ "ups.type", 0, NULL, "Q1\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, blazer_process_status_bits }, /* UPS Type */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Test in Progress */
|
||||
{ "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, 0, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.beeper.status", 0, NULL, "Q1\r", "", 47, '(', "", 45, 45, "%s", 0, blazer_process_status_bits }, /* Beeper status */
|
||||
|
||||
/*
|
||||
* > [F\r]
|
||||
* < [#220.0 000 024.0 50.0\r]
|
||||
* 0123456789012345678901
|
||||
* 0 1 2
|
||||
*/
|
||||
|
||||
{ "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
|
||||
/*
|
||||
* > [I\r]
|
||||
* < [#------------- ------ VT12046Q \r]
|
||||
* 012345678901234567890123456789012345678
|
||||
* 0 1 2 3
|
||||
*/
|
||||
|
||||
{ "device.mfr", 0, NULL, "I\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "device.model", 0, NULL, "I\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "ups.firmware", 0, NULL, "I\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
|
||||
/* Instant commands */
|
||||
{ "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.off", 0, NULL, "S00R0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
|
||||
/* Server-side settable vars */
|
||||
{ "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
|
||||
/* End of structure. */
|
||||
{ NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/* Testing table */
|
||||
#ifdef TESTING
|
||||
static testing_t megatec_testing[] = {
|
||||
{ "Q1\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r" },
|
||||
{ "F\r", "#230.0 000 024.0 50.0\r" },
|
||||
{ "I\r", "#NOT_A_LIVE_UPS TESTING TESTING \r" },
|
||||
{ "Q\r", "" },
|
||||
{ "S03\r", "" },
|
||||
{ "C\r", "" },
|
||||
{ "S02R0005\r", "" },
|
||||
{ "S.5R0000\r", "" },
|
||||
{ "T04\r", "" },
|
||||
{ "TL\r", "" },
|
||||
{ "T\r", "" },
|
||||
{ "CT\r", "" },
|
||||
{ NULL }
|
||||
};
|
||||
#endif /* TESTING */
|
||||
|
||||
/* Subdriver-specific initups */
|
||||
static void megatec_initups(void)
|
||||
{
|
||||
|
||||
blazer_initups(megatec_qx2nut);
|
||||
|
||||
}
|
||||
|
||||
/* Subdriver interface */
|
||||
subdriver_t megatec_subdriver = {
|
||||
MEGATEC_VERSION,
|
||||
blazer_claim,
|
||||
megatec_qx2nut,
|
||||
megatec_initups,
|
||||
NULL,
|
||||
blazer_makevartable,
|
||||
"ACK",
|
||||
NULL,
|
||||
#ifdef TESTING
|
||||
megatec_testing,
|
||||
#endif /* TESTING */
|
||||
};
|
29
drivers/nutdrv_qx_megatec.h
Normal file
29
drivers/nutdrv_qx_megatec.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* nutdrv_qx_megatec.h - Subdriver for Megatec protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_MEGATEC_H
|
||||
#define NUTDRV_QX_MEGATEC_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
extern subdriver_t megatec_subdriver;
|
||||
|
||||
#endif /* NUTDRV_QX_MEGATECH_H */
|
141
drivers/nutdrv_qx_mustek.c
Normal file
141
drivers/nutdrv_qx_mustek.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* nutdrv_qx_mustek.c - Subdriver for Mustek protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "nutdrv_qx.h"
|
||||
#include "nutdrv_qx_blazer-common.h"
|
||||
|
||||
#include "nutdrv_qx_mustek.h"
|
||||
|
||||
#define MUSTEK_VERSION "Mustek 0.01"
|
||||
|
||||
/* qx2nut lookup table */
|
||||
static item_t mustek_qx2nut[] = {
|
||||
|
||||
/*
|
||||
* > [QS\r]
|
||||
* < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
|
||||
* 01234567890123456789012345678901234567890123456
|
||||
* 0 1 2 3 4
|
||||
*/
|
||||
|
||||
{ "input.voltage", 0, NULL, "QS\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL },
|
||||
{ "input.voltage.fault", 0, NULL, "QS\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL },
|
||||
{ "output.voltage", 0, NULL, "QS\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL },
|
||||
{ "ups.load", 0, NULL, "QS\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL },
|
||||
{ "input.frequency", 0, NULL, "QS\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL },
|
||||
{ "battery.voltage", 0, NULL, "QS\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL },
|
||||
{ "ups.temperature", 0, NULL, "QS\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL },
|
||||
/* Status bits */
|
||||
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Utility Fail (Immediate) */
|
||||
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Battery Low */
|
||||
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */
|
||||
{ "ups.alarm", 0, NULL, "QS\r", "", 47, '(', "", 41, 41, NULL, 0, blazer_process_status_bits }, /* UPS Failed */
|
||||
{ "ups.type", 0, NULL, "QS\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, blazer_process_status_bits }, /* UPS Type */
|
||||
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Test in Progress */
|
||||
{ "ups.alarm", 0, NULL, "QS\r", "", 47, '(', "", 44, 44, NULL, 0, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.status", 0, NULL, "QS\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.beeper.status", 0, NULL, "QS\r", "", 47, '(', "", 45, 45, "%s", 0, blazer_process_status_bits }, /* Beeper status */
|
||||
|
||||
/*
|
||||
* > [F\r]
|
||||
* < [#220.0 000 024.0 50.0\r]
|
||||
* 0123456789012345678901
|
||||
* 0 1 2
|
||||
*/
|
||||
|
||||
{ "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
|
||||
/*
|
||||
* > [I\r]
|
||||
* < [#------------- ------ VT12046Q \r]
|
||||
* 012345678901234567890123456789012345678
|
||||
* 0 1 2 3
|
||||
*/
|
||||
|
||||
{ "device.mfr", 0, NULL, "I\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "device.model", 0, NULL, "I\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "ups.firmware", 0, NULL, "I\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
|
||||
/* Instant commands */
|
||||
{ "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.off", 0, NULL, "S00R0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
|
||||
/* Server-side settable vars */
|
||||
{ "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
|
||||
/* End of structure. */
|
||||
{ NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/* Testing table */
|
||||
#ifdef TESTING
|
||||
static testing_t mustek_testing[] = {
|
||||
{ "QS\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r" },
|
||||
{ "F\r", "#230.0 000 024.0 50.0\r" },
|
||||
{ "I\r", "#NOT_A_LIVE_UPS TESTING TESTING \r" },
|
||||
{ "Q\r", "" },
|
||||
{ "S03\r", "" },
|
||||
{ "C\r", "" },
|
||||
{ "S02R0005\r", "" },
|
||||
{ "S.5R0000\r", "" },
|
||||
{ "T04\r", "" },
|
||||
{ "TL\r", "" },
|
||||
{ "T\r", "" },
|
||||
{ "CT\r", "" },
|
||||
{ NULL }
|
||||
};
|
||||
#endif /* TESTING */
|
||||
|
||||
/* Subdriver-specific initups */
|
||||
static void mustek_initups(void)
|
||||
{
|
||||
|
||||
blazer_initups(mustek_qx2nut);
|
||||
|
||||
}
|
||||
|
||||
/* Subdriver interface */
|
||||
subdriver_t mustek_subdriver = {
|
||||
MUSTEK_VERSION,
|
||||
blazer_claim,
|
||||
mustek_qx2nut,
|
||||
mustek_initups,
|
||||
NULL,
|
||||
blazer_makevartable,
|
||||
"ACK",
|
||||
NULL,
|
||||
#ifdef TESTING
|
||||
mustek_testing,
|
||||
#endif /* TESTING */
|
||||
};
|
29
drivers/nutdrv_qx_mustek.h
Normal file
29
drivers/nutdrv_qx_mustek.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* nutdrv_qx_mustek.h - Subdriver for Mustek protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_MUSTEK_H
|
||||
#define NUTDRV_QX_MUSTEK_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
extern subdriver_t mustek_subdriver;
|
||||
|
||||
#endif /* NUTDRV_QX_MUSTEK_H */
|
4209
drivers/nutdrv_qx_voltronic.c
Normal file
4209
drivers/nutdrv_qx_voltronic.c
Normal file
File diff suppressed because it is too large
Load diff
29
drivers/nutdrv_qx_voltronic.h
Normal file
29
drivers/nutdrv_qx_voltronic.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* nutdrv_qx_voltronic.h - Subdriver for Voltronic Power UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_VOLTRONIC_H
|
||||
#define NUTDRV_QX_VOLTRONIC_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
extern subdriver_t voltronic_subdriver;
|
||||
|
||||
#endif /* NUTDRV_QX_VOLTRONIC_H */
|
141
drivers/nutdrv_qx_zinto.c
Normal file
141
drivers/nutdrv_qx_zinto.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* nutdrv_qx_zinto.c - Subdriver for Zinto protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "nutdrv_qx.h"
|
||||
#include "nutdrv_qx_blazer-common.h"
|
||||
|
||||
#include "nutdrv_qx_zinto.h"
|
||||
|
||||
#define ZINTO_VERSION "Zinto 0.01"
|
||||
|
||||
/* qx2nut lookup table */
|
||||
static item_t zinto_qx2nut[] = {
|
||||
|
||||
/*
|
||||
* > [Q1\r]
|
||||
* < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r]
|
||||
* 01234567890123456789012345678901234567890123456
|
||||
* 0 1 2 3 4
|
||||
*/
|
||||
|
||||
{ "input.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL },
|
||||
{ "input.voltage.fault", 0, NULL, "Q1\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL },
|
||||
{ "output.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL },
|
||||
{ "ups.load", 0, NULL, "Q1\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL },
|
||||
{ "input.frequency", 0, NULL, "Q1\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL },
|
||||
{ "battery.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL },
|
||||
{ "ups.temperature", 0, NULL, "Q1\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL },
|
||||
/* Status bits */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Utility Fail (Immediate) */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Battery Low */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */
|
||||
{ "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 41, 41, NULL, 0, blazer_process_status_bits }, /* UPS Failed */
|
||||
{ "ups.type", 0, NULL, "Q1\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, blazer_process_status_bits }, /* UPS Type */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Test in Progress */
|
||||
{ "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, 0, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, blazer_process_status_bits }, /* Shutdown Active */
|
||||
{ "ups.beeper.status", 0, NULL, "Q1\r", "", 47, '(', "", 45, 45, "%s", 0, blazer_process_status_bits }, /* Beeper status */
|
||||
|
||||
/*
|
||||
* > [F\r]
|
||||
* < [#220.0 000 024.0 50.0\r]
|
||||
* 0123456789012345678901
|
||||
* 0 1 2
|
||||
*/
|
||||
|
||||
{ "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL },
|
||||
{ "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL },
|
||||
|
||||
/*
|
||||
* > [FW?\r]
|
||||
* < [#------------- ------ VT12046Q \r]
|
||||
* 012345678901234567890123456789012345678
|
||||
* 0 1 2 3
|
||||
*/
|
||||
|
||||
{ "device.mfr", 0, NULL, "FW?\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "device.model", 0, NULL, "FW?\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
{ "ups.firmware", 0, NULL, "FW?\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL },
|
||||
|
||||
/* Instant commands */
|
||||
{ "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.off", 0, NULL, "S00R0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, blazer_process_command },
|
||||
{ "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
{ "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL },
|
||||
|
||||
/* Server-side settable vars */
|
||||
{ "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, blazer_process_setvar },
|
||||
|
||||
/* End of structure. */
|
||||
{ NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/* Testing table */
|
||||
#ifdef TESTING
|
||||
static testing_t zinto_testing[] = {
|
||||
{ "Q1\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r" },
|
||||
{ "F\r", "#230.0 000 024.0 50.0\r" },
|
||||
{ "FW?\r", "#NOT_A_LIVE_UPS TESTING TESTING \r" },
|
||||
{ "Q\r", "" },
|
||||
{ "S03\r", "" },
|
||||
{ "C\r", "" },
|
||||
{ "S02R0005\r", "" },
|
||||
{ "S.5R0000\r", "" },
|
||||
{ "T04\r", "" },
|
||||
{ "TL\r", "" },
|
||||
{ "T\r", "" },
|
||||
{ "CT\r", "" },
|
||||
{ NULL }
|
||||
};
|
||||
#endif /* TESTING */
|
||||
|
||||
/* Subdriver-specific initups */
|
||||
static void zinto_initups(void)
|
||||
{
|
||||
|
||||
blazer_initups(zinto_qx2nut);
|
||||
|
||||
}
|
||||
|
||||
/* Subdriver interface */
|
||||
subdriver_t zinto_subdriver = {
|
||||
ZINTO_VERSION,
|
||||
blazer_claim,
|
||||
zinto_qx2nut,
|
||||
zinto_initups,
|
||||
NULL,
|
||||
blazer_makevartable,
|
||||
"ACK",
|
||||
NULL,
|
||||
#ifdef TESTING
|
||||
zinto_testing,
|
||||
#endif /* TESTING */
|
||||
};
|
29
drivers/nutdrv_qx_zinto.h
Normal file
29
drivers/nutdrv_qx_zinto.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* nutdrv_qx_zinto.h - Subdriver for Zinto protocol based UPSes
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2013 Daniele Pezzini <hyouko@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NUTDRV_QX_ZINTO_H
|
||||
#define NUTDRV_QX_ZINTO_H
|
||||
|
||||
#include "nutdrv_qx.h"
|
||||
|
||||
extern subdriver_t zinto_subdriver;
|
||||
|
||||
#endif /* NUTDRV_QX_ZINTO_H */
|
360
drivers/openups-hid.c
Normal file
360
drivers/openups-hid.c
Normal file
|
@ -0,0 +1,360 @@
|
|||
/* openups-hid.c - subdriver to monitor Minibox openUPS USB/HID devices with NUT
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2003 - 2012 Arnaud Quette <ArnaudQuette@Eaton.com>
|
||||
* 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
* 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
* 2012 Nicu Pavel <npavel@mini-box.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "usbhid-ups.h"
|
||||
#include "openups-hid.h"
|
||||
#include "main.h" /* for getval() */
|
||||
#include "usb-common.h"
|
||||
|
||||
#define OPENUPS_HID_VERSION "openUPS HID 0.1"
|
||||
|
||||
/* Minibox */
|
||||
#define OPENUPS_VENDORID 0x04d8
|
||||
|
||||
static char openups_scratch_buf[20];
|
||||
|
||||
/* USB IDs device table */
|
||||
static usb_device_id_t openups_usb_device_table[] = {
|
||||
/* openUPS Intelligent UPS (minimum required firmware 1.4) */
|
||||
{USB_DEVICE(OPENUPS_VENDORID, 0xd004), NULL},
|
||||
|
||||
/* Terminating entry */
|
||||
{-1, -1, NULL}
|
||||
};
|
||||
|
||||
/* Thermistor table used for temperature lookups
|
||||
* taken from the windows monitoring application
|
||||
*/
|
||||
static unsigned int therm_tbl[] =
|
||||
{
|
||||
(unsigned int)0x31,
|
||||
(unsigned int)0x40,
|
||||
(unsigned int)0x53,
|
||||
(unsigned int)0x68,
|
||||
(unsigned int)0x82,
|
||||
(unsigned int)0xA0,
|
||||
(unsigned int)0xC3,
|
||||
(unsigned int)0xE9,
|
||||
(unsigned int)0x113,
|
||||
(unsigned int)0x13F,
|
||||
(unsigned int)0x16E,
|
||||
(unsigned int)0x19F,
|
||||
(unsigned int)0x1CF,
|
||||
(unsigned int)0x200,
|
||||
(unsigned int)0x22F,
|
||||
(unsigned int)0x25C,
|
||||
(unsigned int)0x286,
|
||||
(unsigned int)0x2AE,
|
||||
(unsigned int)0x2D3,
|
||||
(unsigned int)0x2F4,
|
||||
(unsigned int)0x312,
|
||||
(unsigned int)0x32D,
|
||||
(unsigned int)0x345,
|
||||
(unsigned int)0x35A,
|
||||
(unsigned int)0x36D,
|
||||
(unsigned int)0x37E,
|
||||
(unsigned int)0x38C,
|
||||
(unsigned int)0x399,
|
||||
(unsigned int)0x3A5,
|
||||
(unsigned int)0x3AF,
|
||||
(unsigned int)0x3B7,
|
||||
(unsigned int)0x3BF,
|
||||
(unsigned int)0x3C6,
|
||||
(unsigned int)0x3CC
|
||||
};
|
||||
|
||||
static unsigned int therm_tbl_size = sizeof(therm_tbl)/sizeof(therm_tbl[0]);
|
||||
|
||||
static const char *openups_charging_fun(double value);
|
||||
static const char *openups_discharging_fun(double value);
|
||||
static const char *openups_online_fun(double value);
|
||||
static const char *openups_nobattery_fun(double value);
|
||||
static const char *openups_off_fun(double value);
|
||||
|
||||
static const char *openups_scale_vin_fun(double value);
|
||||
static const char *openups_scale_vout_fun(double value);
|
||||
/* static const char *openups_scale_vbat_fun(double value); */
|
||||
static const char *openups_scale_ccharge_fun(double value);
|
||||
static const char *openups_scale_cdischarge_fun(double value);
|
||||
static const char *openups_temperature_fun(double value);
|
||||
|
||||
static info_lkp_t openups_charging_info[] = {
|
||||
{0, NULL, openups_charging_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_discharging_info[] = {
|
||||
{0, NULL, openups_discharging_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_online_info[] = {
|
||||
{0, NULL, openups_online_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_nobattery_info[] = {
|
||||
{0, NULL, openups_nobattery_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_off_info[] = {
|
||||
{0, NULL, openups_off_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_vin_info[] = {
|
||||
{0, NULL, openups_scale_vin_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_vout_info[] = {
|
||||
{0, NULL, openups_scale_vout_fun}
|
||||
};
|
||||
|
||||
/* static info_lkp_t openups_vbat_info[] = {
|
||||
{0, NULL, openups_scale_vbat_fun}
|
||||
};*/
|
||||
|
||||
static info_lkp_t openups_ccharge_info[] = {
|
||||
{0, NULL, openups_scale_ccharge_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_cdischarge_info[] = {
|
||||
{0, NULL, openups_scale_cdischarge_fun}
|
||||
};
|
||||
|
||||
static info_lkp_t openups_temperature_info[] = {
|
||||
{0, NULL, openups_temperature_fun}
|
||||
};
|
||||
|
||||
static const char *openups_charging_fun(double value)
|
||||
{
|
||||
return value ? "chrg" : "!chrg";
|
||||
}
|
||||
|
||||
static const char *openups_discharging_fun(double value)
|
||||
{
|
||||
return value ? "dischrg" : "!dischrg";
|
||||
}
|
||||
|
||||
static const char *openups_online_fun(double value)
|
||||
{
|
||||
return value ? "online" : "!online";
|
||||
}
|
||||
|
||||
static const char *openups_nobattery_fun(double value)
|
||||
{
|
||||
return value ? "nobattery" : "!nobattery";
|
||||
}
|
||||
|
||||
static const char *openups_off_fun(double value)
|
||||
{
|
||||
return value ? "!off" : "off";
|
||||
}
|
||||
|
||||
static const char *openups_scale_vin_fun(double value)
|
||||
{
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vin_scale);
|
||||
return openups_scratch_buf;
|
||||
}
|
||||
|
||||
static const char *openups_scale_vout_fun(double value)
|
||||
{
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vout_scale);
|
||||
return openups_scratch_buf;
|
||||
}
|
||||
|
||||
/* static const char *openups_scale_vbat_fun(double value)
|
||||
{
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vbat_scale);
|
||||
return openups_scratch_buf;
|
||||
}*/
|
||||
|
||||
static const char *openups_scale_ccharge_fun(double value)
|
||||
{
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.3f", value * ccharge_scale);
|
||||
return openups_scratch_buf;
|
||||
}
|
||||
|
||||
static const char *openups_scale_cdischarge_fun(double value)
|
||||
{
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.3f", value * cdischarge_scale);
|
||||
return openups_scratch_buf;
|
||||
}
|
||||
|
||||
static const char *openups_temperature_fun(double value)
|
||||
{
|
||||
int i;
|
||||
int pos = -1;
|
||||
unsigned int thermistor = value * 100;
|
||||
|
||||
if (thermistor <= therm_tbl[0]) {
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", -40);
|
||||
} else {
|
||||
if (thermistor >= therm_tbl[therm_tbl_size - 1]) {
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", 125);
|
||||
} else {
|
||||
for (i = therm_tbl_size - 1; i >= 0; i--) {
|
||||
if (thermistor >= therm_tbl[i]) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (thermistor == therm_tbl[pos]) {
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", pos * 5 - 40);
|
||||
} else {
|
||||
int t1 = pos * 5 - 40;
|
||||
int t2 = (pos + 1) * 5 - 40;
|
||||
|
||||
unsigned int d1 = therm_tbl[pos];
|
||||
unsigned int d2 = therm_tbl[pos + 1];
|
||||
|
||||
float temp = (float) (thermistor - d1) * (t2 - t1) / (d2 - d1) + t1;
|
||||
snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return openups_scratch_buf;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* Vendor-specific usage table */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
/* OPENUPS usage table */
|
||||
static usage_lkp_t openups_usage_lkp[] = {
|
||||
{"Cell1", 0x00000001}, /* Battery cell 1 on J6 pin 1 */
|
||||
{"Cell2", 0x00000002}, /* Battery cell 2 on J6 pin 2 */
|
||||
{"Cell3", 0x00000003}, /* Battery cell 3 on J6 pin 3 */
|
||||
{"Cell4", 0x00000004}, /* Battery cell 4 on J6 pin 4 */
|
||||
{"Cell5", 0x00000005}, /* Battery cell 5 on J6 pin 5 */
|
||||
{"Cell6", 0x00000006}, /* Battery cell 6 on J4 pin 1 */
|
||||
/* Usage table for windows monitoring app only updates when
|
||||
* certain request codes are written to USB endpoint */
|
||||
/*{ "OpenUPSExtra", 0xff000001 }, */
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static usage_tables_t openups_utab[] = {
|
||||
openups_usage_lkp,
|
||||
hid_usage_lkp,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* HID2NUT lookup table */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
static hid_info_t openups_hid2nut[] = {
|
||||
{"ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", 0, stringid_conversion},
|
||||
|
||||
/* Battery */
|
||||
{"battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion},
|
||||
{"battery.mfr.date", 0, 0, "UPS.PowerSummary.iOEMInformation", NULL, "%s", 0, stringid_conversion},
|
||||
{"battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.2f", HU_FLAG_QUICK_POLL, NULL},
|
||||
/* { "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info }, */
|
||||
{"battery.current", 0, 0, "UPS.PowerSummary.Current", NULL, "%.3f", HU_FLAG_QUICK_POLL, NULL},
|
||||
{"battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL},
|
||||
{"battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
|
||||
{"battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
|
||||
{"battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL},
|
||||
{"battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
|
||||
{"battery.temperature", 0, 0, "UPS.PowerSummary.Temperature", NULL, NULL, HU_FLAG_QUICK_POLL, openups_temperature_info},
|
||||
/* {"battery.cell1.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell1", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
{"battery.cell2.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell2", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
{"battery.cell3.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell3", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
{"battery.cell4.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell4", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
{"battery.cell5.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell5", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
{"battery.cell6.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell6", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
|
||||
*/
|
||||
/* Output */
|
||||
{"output.voltage", 0, 0, "UPS.PowerSummary.Output.Voltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vout_info},
|
||||
{"output.current", 0, 0, "UPS.PowerSummary.Output.Current", NULL, NULL, HU_FLAG_QUICK_POLL, openups_cdischarge_info},
|
||||
|
||||
/* Input */
|
||||
{"input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vin_info},
|
||||
{"input.current", 0, 0, "UPS.PowerSummary.Input.Current", NULL, NULL, HU_FLAG_QUICK_POLL, openups_ccharge_info},
|
||||
|
||||
/* Status */
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, HU_FLAG_QUICK_POLL, openups_off_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, HU_FLAG_QUICK_POLL, commfault_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, HU_FLAG_QUICK_POLL, overheat_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, HU_FLAG_QUICK_POLL, timelimitexpired_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, openups_charging_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, openups_discharging_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, openups_online_info},
|
||||
{"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, HU_FLAG_QUICK_POLL, openups_nobattery_info},
|
||||
|
||||
/* end of structure. */
|
||||
{NULL, 0, 0, NULL, NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static const char *openups_format_model(HIDDevice_t * hd)
|
||||
{
|
||||
return hd->Product;
|
||||
}
|
||||
|
||||
static const char *openups_format_mfr(HIDDevice_t * hd)
|
||||
{
|
||||
return hd->Vendor ? hd->Vendor : "openUPS";
|
||||
}
|
||||
|
||||
static const char *openups_format_serial(HIDDevice_t * hd)
|
||||
{
|
||||
return hd->Serial;
|
||||
}
|
||||
|
||||
/* this function allows the subdriver to "claim" a device: return 1 if
|
||||
* the device is supported by this subdriver, else 0. */
|
||||
static int openups_claim(HIDDevice_t * hd)
|
||||
{
|
||||
int status = is_usb_device_supported(openups_usb_device_table, hd);
|
||||
|
||||
switch (status) {
|
||||
case POSSIBLY_SUPPORTED:
|
||||
/* by default, reject, unless the productid option is given */
|
||||
if (getval("productid")) {
|
||||
return 1;
|
||||
}
|
||||
possibly_supported("openUPS", hd);
|
||||
return 0;
|
||||
|
||||
case SUPPORTED:
|
||||
return 1;
|
||||
|
||||
case NOT_SUPPORTED:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
subdriver_t openups_subdriver = {
|
||||
OPENUPS_HID_VERSION,
|
||||
openups_claim,
|
||||
openups_utab,
|
||||
openups_hid2nut,
|
||||
openups_format_model,
|
||||
openups_format_mfr,
|
||||
openups_format_serial,
|
||||
};
|
38
drivers/openups-hid.h
Normal file
38
drivers/openups-hid.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* openups-hid.h - subdriver to monitor Minibox openUPS USB/HID devices with NUT
|
||||
*
|
||||
* Copyright (C)
|
||||
* 2003 - 2009 Arnaud Quette <ArnaudQuette@Eaton.com>
|
||||
* 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
|
||||
* 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
* 2012 Nicu Pavel <npavel@mini-box.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef OPENUPS_HID_H
|
||||
#define OPENUPS_HID_H
|
||||
|
||||
#include "usbhid-ups.h"
|
||||
|
||||
/* constants for converting HID read values to real values */
|
||||
static const float vin_scale = 0.03545 * 100;
|
||||
static const float vout_scale = 0.02571 * 100;
|
||||
static const float vbat_scale = 0.00857 * 100;
|
||||
static const float ccharge_scale = 0.8274 / 10;
|
||||
static const float cdischarge_scale = 16.113 / 10;
|
||||
|
||||
extern subdriver_t openups_subdriver;
|
||||
|
||||
#endif /* OPENUPS_HID_H */
|
|
@ -25,7 +25,7 @@
|
|||
#include "powercom-hid.h"
|
||||
#include "usb-common.h"
|
||||
|
||||
#define POWERCOM_HID_VERSION "PowerCOM HID 0.3"
|
||||
#define POWERCOM_HID_VERSION "PowerCOM HID 0.4"
|
||||
/* FIXME: experimental flag to be put in upsdrv_info */
|
||||
|
||||
/* PowerCOM */
|
||||
|
@ -94,6 +94,7 @@ static double powercom_shutdown_nuf(const char *value)
|
|||
uint16_t val, command;
|
||||
|
||||
val = atoi(value ? value : s);
|
||||
val = val ? val : 1; /* 0 sets the maximum delay */
|
||||
command = ((val % 60) << 8) + (val / 60);
|
||||
command |= 0x4000; /* AC RESTART NORMAL ENABLE */
|
||||
upsdebugx(3, "%s: value = %s, command = %04X", __func__, value, command);
|
||||
|
@ -111,6 +112,7 @@ static double powercom_stayoff_nuf(const char *value)
|
|||
uint16_t val, command;
|
||||
|
||||
val = atoi(value ? value : s);
|
||||
val = val ? val : 1; /* 0 sets the maximum delay */
|
||||
command = ((val % 60) << 8) + (val / 60);
|
||||
command |= 0x8000; /* AC RESTART NORMAL DISABLE */
|
||||
upsdebugx(3, "%s: value = %s, command = %04X", __func__, value, command);
|
||||
|
@ -137,6 +139,8 @@ static usage_lkp_t powercom_usage_lkp[] = {
|
|||
{ "POWERCOM1", 0x0084002f },
|
||||
{ "POWERCOM2", 0xff860060 },
|
||||
{ "POWERCOM3", 0xff860080 },
|
||||
{ "PCMDelayBeforeStartup", 0x00ff0056 },
|
||||
{ "PCMDelayBeforeShutdown", 0x00ff0057 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -235,6 +239,8 @@ static hid_info_t powercom_hid2nut[] = {
|
|||
*/
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerSummary.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL },
|
||||
{ "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, powercom_shutdown_info },
|
||||
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.PowerSummary.PCMDelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL },
|
||||
{ "ups.timer.shutdown", 0, 0, "UPS.PowerSummary.PCMDelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, powercom_shutdown_info },
|
||||
|
||||
{ "input.voltage", 0, 0, "UPS.Input.Voltage", NULL, "%.1f", 0, NULL },
|
||||
{ "input.voltage.nominal", 0, 0, "UPS.Input.ConfigVoltage", NULL, "%.0f", HU_FLAG_STATIC, NULL },
|
||||
|
@ -251,10 +257,16 @@ static hid_info_t powercom_hid2nut[] = {
|
|||
|
||||
/* instcmds */
|
||||
{ "beeper.toggle", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL },
|
||||
{ "beeper.enable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL },
|
||||
{ "beeper.disable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "0", HU_TYPE_CMD, NULL },
|
||||
{ "test.battery.start.quick", 0, 0, "UPS.Battery.Test", NULL, "1", HU_TYPE_CMD, NULL },
|
||||
{ "load.on.delay", 0, 0, "UPS.PowerSummary.DelayBeforeStartup", NULL, NULL, HU_TYPE_CMD, powercom_startup_info },
|
||||
{ "shutdown.return", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, NULL, HU_TYPE_CMD, powercom_shutdown_info },
|
||||
{ "shutdown.stayoff", 0, 0, "UPS.PowerSummary.DelayBeforeShutdown", NULL, NULL, HU_TYPE_CMD, powercom_stayoff_info },
|
||||
{ "load.on", 0, 0, "UPS.PowerSummary.PCMDelayBeforeStartup", NULL, "0", HU_TYPE_CMD, powercom_startup_info },
|
||||
{ "load.off", 0, 0, "UPS.PowerSummary.PCMDelayBeforeShutdown", NULL, "0", HU_TYPE_CMD, powercom_stayoff_info },
|
||||
{ "shutdown.return", 0, 0, "UPS.PowerSummary.PCMDelayBeforeShutdown", NULL, NULL, HU_TYPE_CMD, powercom_shutdown_info },
|
||||
{ "shutdown.stayoff", 0, 0, "UPS.PowerSummary.PCMDelayBeforeShutdown", NULL, NULL, HU_TYPE_CMD, powercom_stayoff_info },
|
||||
|
||||
/* end of structure. */
|
||||
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
|
||||
|
@ -276,7 +288,7 @@ static const char *powercom_format_serial(HIDDevice_t *hd) {
|
|||
* the device is supported by this subdriver, else 0. */
|
||||
static int powercom_claim(HIDDevice_t *hd)
|
||||
{
|
||||
int status = is_usb_device_supported(powercom_usb_device_table, hd->VendorID, hd->ProductID);
|
||||
int status = is_usb_device_supported(powercom_usb_device_table, hd);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
* This model is based on PowerCom (www.powercom.com) models.
|
||||
* -Socomec Sicon Egys 420
|
||||
*
|
||||
* $Id: powercom.c 2990 2011-05-19 18:34:09Z aquette $
|
||||
*
|
||||
* Copyrights:
|
||||
* (C) 2002 Simon Rozman <simon@rozman.net>
|
||||
* (C) 1999 Peter Bieringer <pb@bieringer.de>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/*
|
||||
* powercom.h - defines for the newpowercom.c driver
|
||||
*
|
||||
* $Id: powercom.h 2984 2011-05-13 13:18:34Z aquette $
|
||||
*
|
||||
* Copyrights:
|
||||
* (C) 2002 Simon Rozman <simon@rozman.net>
|
||||
* (C) 1999 Peter Bieringer <pb@bieringer.de>
|
||||
|
|
|
@ -188,9 +188,9 @@ static int reconnect_ups(void)
|
|||
{
|
||||
pm_err_t rv;
|
||||
|
||||
upsdebugx(4, "==================================================");
|
||||
upsdebugx(4, "= connexion lost with Powerman, try to reconnect =");
|
||||
upsdebugx(4, "==================================================");
|
||||
upsdebugx(4, "===================================================");
|
||||
upsdebugx(4, "= connection lost with Powerman, try to reconnect =");
|
||||
upsdebugx(4, "===================================================");
|
||||
|
||||
/* clear the situation */
|
||||
pm_disconnect(pm);
|
||||
|
@ -199,7 +199,7 @@ static int reconnect_ups(void)
|
|||
if ((rv = pm_connect(device_path, NULL, &pm, 0)) != PM_ESUCCESS)
|
||||
return 0;
|
||||
else {
|
||||
upsdebugx(4, "connexion restored with Powerman");
|
||||
upsdebugx(4, "connection restored with Powerman");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* Copyright (C)
|
||||
* 2007 Doug Reynolds <mav@wastegate.net>
|
||||
* 2007-2008 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
* 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*
|
||||
* 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
|
||||
|
@ -33,13 +34,21 @@
|
|||
#include "powerp-txt.h"
|
||||
|
||||
typedef struct {
|
||||
float i_volt;
|
||||
float o_volt;
|
||||
int o_load;
|
||||
int b_chrg;
|
||||
int u_temp;
|
||||
float i_freq;
|
||||
unsigned char flags[2];
|
||||
float i_volt;
|
||||
float o_volt;
|
||||
int o_load;
|
||||
int b_chrg;
|
||||
int u_temp;
|
||||
float i_freq;
|
||||
unsigned char flags[2];
|
||||
unsigned char has_b_volt;
|
||||
float b_volt;
|
||||
unsigned char has_o_freq;
|
||||
float o_freq;
|
||||
unsigned char has_runtime;
|
||||
int runtime;
|
||||
int c_unknwn;
|
||||
float q_unknwn;
|
||||
} status_t;
|
||||
|
||||
static int ondelay = 1; /* minutes */
|
||||
|
@ -402,6 +411,40 @@ static int powpan_status(status_t *status)
|
|||
&status->b_chrg, &status->u_temp, &status->i_freq,
|
||||
status->flags);
|
||||
|
||||
if (ret >= 7) {
|
||||
status->has_b_volt = 0;
|
||||
status->has_o_freq = 0;
|
||||
status->has_runtime = 0;
|
||||
}
|
||||
else {
|
||||
ret = ser_get_buf_len(upsfd, powpan_answer+35, 23, SER_WAIT_SEC, SER_WAIT_USEC);
|
||||
|
||||
if (ret < 0) {
|
||||
upsdebug_with_errno(3, "read");
|
||||
upsdebug_hex(4, " \\_", powpan_answer+35, 23);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
upsdebugx(3, "read: timeout");
|
||||
upsdebug_hex(4, " \\_", powpan_answer+35, 23);
|
||||
return -1;
|
||||
}
|
||||
|
||||
upsdebug_hex(3, "read", powpan_answer, ret);
|
||||
|
||||
ret = sscanf(powpan_answer, "#I%fO%fL%dB%dV%fT%dF%fH%fR%dC%dQ%fS%2c\r",
|
||||
&status->i_volt, &status->o_volt, &status->o_load,
|
||||
&status->b_chrg, &status->b_volt, &status->u_temp,
|
||||
&status->i_freq, &status->o_freq, &status->runtime,
|
||||
&status->c_unknwn, &status->q_unknwn, status->flags);
|
||||
status->has_b_volt = 1;
|
||||
status->has_o_freq = 1;
|
||||
status->has_runtime = 1;
|
||||
dstate_setinfo("battery.voltage.nominal", "%g", 72.0);
|
||||
dstate_setinfo("output.voltage.nominal", "%g", 120.0);
|
||||
}
|
||||
|
||||
if (ret < 7) {
|
||||
upsdebugx(4, "Parsing status string failed");
|
||||
return -1;
|
||||
|
@ -424,6 +467,15 @@ static int powpan_updateinfo(void)
|
|||
dstate_setinfo("input.frequency", "%.1f", status.i_freq);
|
||||
dstate_setinfo("ups.temperature", "%d", status.u_temp);
|
||||
dstate_setinfo("battery.charge", "%d", status.b_chrg);
|
||||
if (status.has_b_volt) {
|
||||
dstate_setinfo("battery.voltage", "%.1f", status.b_volt);
|
||||
}
|
||||
if (status.has_o_freq) {
|
||||
dstate_setinfo("output.frequency", "%.1f", status.o_freq);
|
||||
}
|
||||
if (status.has_runtime) {
|
||||
dstate_setinfo("battery.runtime", "%d", status.runtime*60);
|
||||
}
|
||||
|
||||
status_init();
|
||||
|
||||
|
|
|
@ -36,14 +36,15 @@ static subdriver_t *subdriver[] = {
|
|||
};
|
||||
|
||||
#define DRIVER_NAME "CyberPower text/binary protocol UPS driver"
|
||||
#define DRIVER_VERSION "0.25"
|
||||
#define DRIVER_VERSION "0.26"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
DRIVER_NAME,
|
||||
DRIVER_VERSION,
|
||||
"Doug Reynolds <mav@wastegate.net>\n" \
|
||||
"Arjen de Korte <adkorte-guest@alioth.debian.org>",
|
||||
"Arjen de Korte <adkorte-guest@alioth.debian.org>\n" \
|
||||
"Timothy Pearson <kb9vqf@pearsoncomputing.net>",
|
||||
DRV_EXPERIMENTAL,
|
||||
{ NULL }
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "powerware-mib.h"
|
||||
|
||||
#define PW_MIB_VERSION "0.6.1"
|
||||
#define PW_MIB_VERSION "0.6.2"
|
||||
|
||||
/* TODO: more sysOID and MIBs support:
|
||||
*
|
||||
|
@ -84,7 +84,7 @@
|
|||
#define PW_OID_CONF_POWER "1.3.6.1.4.1.534.1.10.3.0" /* XUPS-MIB::xupsConfigOutputWatts.0 */
|
||||
#define PW_OID_CONF_FREQ "1.3.6.1.4.1.534.1.10.4.0" /* XUPS-MIB::xupsConfigOutputFreq.0 */
|
||||
|
||||
#define PW_OID_ALARMS "1.3.6.1.4.1.534.1.7.1" /* XUPS-MIB::xupsAlarms */
|
||||
#define PW_OID_ALARMS "1.3.6.1.4.1.534.1.7.1.0" /* XUPS-MIB::xupsAlarms */
|
||||
#define PW_OID_ALARM_OB "1.3.6.1.4.1.534.1.7.3" /* XUPS-MIB::xupsOnBattery */
|
||||
#define PW_OID_ALARM_LB "1.3.6.1.4.1.534.1.7.4" /* XUPS-MIB::xupsLowBattery */
|
||||
|
||||
|
@ -320,8 +320,18 @@ static snmp_info_t pw_mib[] = {
|
|||
{ "load.on", 0, 1, PW_OID_CONT_ONDELAY, "",
|
||||
SU_TYPE_CMD | SU_FLAG_OK, NULL },
|
||||
|
||||
{ "ups.alarms", 0, 1.0, PW_OID_ALARMS, "",
|
||||
0, NULL },
|
||||
|
||||
/* end of structure. */
|
||||
{ NULL, 0, 0, NULL, NULL, 0, NULL }
|
||||
} ;
|
||||
|
||||
mib2nut_info_t powerware = { "pw", PW_MIB_VERSION, "", PW_OID_MODEL_NAME, pw_mib, POWERWARE_SYSOID };
|
||||
static alarms_info_t pw_alarms[] = {
|
||||
{ PW_OID_ALARM_LB, "LB" },
|
||||
/* end of structure. */
|
||||
{ NULL, NULL }
|
||||
} ;
|
||||
|
||||
|
||||
mib2nut_info_t powerware = { "pw", PW_MIB_VERSION, "", PW_OID_MODEL_NAME, pw_mib, POWERWARE_SYSOID , pw_alarms };
|
||||
|
|
|
@ -65,7 +65,7 @@ static unsigned int comm_failures = 0;
|
|||
|
||||
static int device_match_func(USBDevice_t *device, void *privdata)
|
||||
{
|
||||
switch (is_usb_device_supported(richcomm_usb_id, device->VendorID, device->ProductID))
|
||||
switch (is_usb_device_supported(richcomm_usb_id, device))
|
||||
{
|
||||
case SUPPORTED:
|
||||
return 1;
|
||||
|
|
1016
drivers/riello.c
Normal file
1016
drivers/riello.c
Normal file
File diff suppressed because it is too large
Load diff
179
drivers/riello.h
Normal file
179
drivers/riello.h
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* riello.h: defines/macros for Riello protocol based UPSes
|
||||
*
|
||||
* Documents describing the protocol implemented by this driver can be
|
||||
* found online at:
|
||||
*
|
||||
* http://www.networkupstools.org/ups-protocols/riello/PSGPSER-0104.pdf
|
||||
* http://www.networkupstools.org/ups-protocols/riello/PSSENTR-0100.pdf
|
||||
*
|
||||
* Copyright (C) 2012 - Elio Parisi <e.parisi@riello-ups.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Reference of the derivative work: blazer driver
|
||||
*/
|
||||
|
||||
#ifndef dev_dataH
|
||||
#define dev_dataH
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CTRL_RETRIES 50
|
||||
#define CTRL_TIMEOUT 100
|
||||
|
||||
#define USB_ENDPOINT_IN 0x80
|
||||
#define USB_ENDPOINT_OUT 0x00
|
||||
|
||||
#define MAX_READ_WRITE (16 * 1024)
|
||||
|
||||
#define USB_WRITE_DELAY 200
|
||||
|
||||
#define MAXTRIES 3
|
||||
#define COUNTLOST 10
|
||||
|
||||
#define DEV_RIELLOSENTRY 14
|
||||
#define DEV_RIELLOGPSER 21
|
||||
|
||||
#define LENGTH_GI 68
|
||||
#define LENGTH_GN 34
|
||||
#define LENGTH_RS_MM 42
|
||||
#define LENGTH_RS_TM 48
|
||||
#define LENGTH_RS_TT 64
|
||||
#define LENGTH_RE 70
|
||||
#define LENGTH_RC 56
|
||||
#define LENGTH_DEF 12
|
||||
|
||||
#define SENTR_EXT176 176
|
||||
#define SENTR_ALSO240 240
|
||||
#define SENTR_ONLY192 192
|
||||
|
||||
#define BUFFER_SIZE 220
|
||||
|
||||
typedef struct {
|
||||
uint16_t SWversion;
|
||||
uint16_t Model;
|
||||
uint16_t Uinp1;
|
||||
uint16_t Uinp2;
|
||||
uint16_t Uinp3;
|
||||
uint16_t Iinp1;
|
||||
uint16_t Iinp2;
|
||||
uint16_t Iinp3;
|
||||
uint16_t Finp;
|
||||
|
||||
uint16_t Uout1;
|
||||
uint16_t Uout2;
|
||||
uint16_t Uout3;
|
||||
uint16_t Iout1;
|
||||
uint16_t Iout2;
|
||||
uint16_t Iout3;
|
||||
uint16_t Pout1;
|
||||
uint16_t Pout2;
|
||||
uint16_t Pout3;
|
||||
uint16_t Ipout1;
|
||||
uint16_t Ipout2;
|
||||
uint16_t Ipout3;
|
||||
uint16_t Fout;
|
||||
|
||||
uint16_t BatTime;
|
||||
uint16_t BatCap;
|
||||
uint16_t Ubat;
|
||||
uint16_t Ibat;
|
||||
|
||||
uint16_t Tsystem;
|
||||
uint16_t NomBatCap;
|
||||
|
||||
uint16_t Ubypass1;
|
||||
uint16_t Ubypass2;
|
||||
uint16_t Ubypass3;
|
||||
uint16_t Fbypass;
|
||||
uint16_t LockUPS;
|
||||
|
||||
uint8_t AlarmCode[4];
|
||||
char AlarmCodeT[12];
|
||||
uint8_t StatusCode[12];
|
||||
char StatusCodeT[42];
|
||||
|
||||
char Identification[18];
|
||||
char ModelStr[18];
|
||||
char Version[14];
|
||||
|
||||
uint16_t NomPowerKVA;
|
||||
uint16_t NomPowerKW;
|
||||
uint16_t NomUbat;
|
||||
uint16_t NumBat;
|
||||
|
||||
uint16_t UbatPerc;
|
||||
|
||||
uint16_t NominalUout;
|
||||
|
||||
uint16_t Boost;
|
||||
uint16_t Buck;
|
||||
|
||||
uint8_t Identif_bytes[12];
|
||||
uint16_t NomFout;
|
||||
|
||||
uint32_t Pout1VA;
|
||||
uint32_t Pout2VA;
|
||||
uint32_t Pout3VA;
|
||||
uint32_t Pout1W;
|
||||
uint32_t Pout2W;
|
||||
uint32_t Pout3W;
|
||||
} TRielloData;
|
||||
|
||||
/* CRC and Checksum functions */
|
||||
uint16_t riello_calc_CRC(uint8_t type, uint8_t *buff, uint16_t size, uint8_t checksum);
|
||||
void riello_create_crc(uint8_t type, uint8_t *buff, uint16_t size, uint8_t checksum);
|
||||
uint8_t riello_test_crc(uint8_t type, uint8_t *buff, uint16_t size, uint8_t chacksum);
|
||||
uint8_t riello_test_bit(uint8_t *basic_address, uint8_t bit);
|
||||
|
||||
/* send GPSER command functions */
|
||||
uint8_t riello_prepare_gi(uint8_t* buffer);
|
||||
uint8_t riello_prepare_gn(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
uint8_t riello_prepare_rs(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
uint8_t riello_prepare_re(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
uint8_t riello_prepare_rc(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
uint8_t riello_prepare_cs(uint8_t* buffer, uint8_t gpser_error_control, uint16_t delay);
|
||||
uint8_t riello_prepare_cr(uint8_t* buffer, uint8_t gpser_error_control, uint16_t delay);
|
||||
uint8_t riello_prepare_cd(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
uint8_t riello_prepare_tp(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
uint8_t riello_prepare_tb(uint8_t* buffer, uint8_t gpser_error_control);
|
||||
|
||||
/* send SENTR command functions */
|
||||
uint8_t riello_prepare_shutsentr(uint8_t* buffer, uint16_t delay);
|
||||
uint8_t riello_prepare_cancelsentr(uint8_t* buffer);
|
||||
uint8_t riello_prepare_setrebsentr(uint8_t* buffer, uint16_t delay);
|
||||
uint8_t riello_prepare_rebsentr(uint8_t* buffer, uint16_t delay);
|
||||
uint8_t riello_prepare_tbsentr(uint8_t* buffer);
|
||||
|
||||
/* parse GPSER ups responses */
|
||||
void riello_parse_gi(uint8_t* buffer, TRielloData* data);
|
||||
void riello_parse_gn(uint8_t* buffer, TRielloData* data);
|
||||
void riello_parse_rs(uint8_t* buffer, TRielloData* data, uint8_t numread);
|
||||
void riello_parse_re(uint8_t* buffer, TRielloData* data);
|
||||
void riello_parse_rc(uint8_t* buffer, TRielloData* data);
|
||||
|
||||
/* parse SENTR ups responses */
|
||||
void riello_parse_sentr(uint8_t* buffer, TRielloData* data);
|
||||
|
||||
/* communication functions */
|
||||
void riello_init_serial();
|
||||
uint8_t riello_header(uint8_t type, uint8_t a, uint8_t* length);
|
||||
uint8_t riello_tail(uint8_t type, uint8_t length);
|
||||
uint8_t riello_test_nak(uint8_t type, uint8_t* buffer);
|
||||
void riello_parse_serialport(uint8_t typedev, uint8_t* buffer, uint8_t checksum);
|
||||
void riello_comm_setup(const char *port);
|
||||
|
||||
#endif
|
1055
drivers/riello_ser.c
Normal file
1055
drivers/riello_ser.c
Normal file
File diff suppressed because it is too large
Load diff
1064
drivers/riello_usb.c
Normal file
1064
drivers/riello_usb.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -123,26 +123,42 @@ static void lock_set(int fd, const char *port)
|
|||
#endif
|
||||
}
|
||||
|
||||
int ser_open(const char *port)
|
||||
/* Non fatal version of ser_open */
|
||||
int ser_open_nf(const char *port)
|
||||
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(port, O_RDWR | O_NOCTTY | O_EXCL | O_NONBLOCK);
|
||||
|
||||
if (fd < 0)
|
||||
ser_open_error(port);
|
||||
if (fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
lock_set(fd, port);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int ser_set_speed(int fd, const char *port, speed_t speed)
|
||||
int ser_open(const char *port)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = ser_open_nf(port);
|
||||
if(res == -1) {
|
||||
ser_open_error(port);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int ser_set_speed_nf(int fd, const char *port, speed_t speed)
|
||||
{
|
||||
struct termios tio;
|
||||
|
||||
if (tcgetattr(fd, &tio) != 0)
|
||||
fatal_with_errno(EXIT_FAILURE, "tcgetattr(%s)", port);
|
||||
if (tcgetattr(fd, &tio) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tio.c_cflag = CS8 | CLOCAL | CREAD;
|
||||
tio.c_iflag = IGNPAR;
|
||||
|
@ -164,6 +180,18 @@ int ser_set_speed(int fd, const char *port, speed_t speed)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ser_set_speed(int fd, const char *port, speed_t speed)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = ser_set_speed_nf(fd,port,speed);
|
||||
if(res == -1) {
|
||||
fatal_with_errno(EXIT_FAILURE, "tcgetattr(%s)", port);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ser_set_control(int fd, int line, int state)
|
||||
{
|
||||
if (state) {
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
#define SER_ERR_LIMIT 10 /* start limiting after 10 in a row */
|
||||
#define SER_ERR_RATE 100 /* then only print every 100th error */
|
||||
|
||||
int ser_open_nf(const char *port);
|
||||
int ser_open(const char *port);
|
||||
|
||||
int ser_set_speed_nf(int fd, const char *port, speed_t speed);
|
||||
int ser_set_speed(int fd, const char *port, speed_t speed);
|
||||
|
||||
/* set the state of modem control lines */
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/* NUT SNMP common functions */
|
||||
#include "main.h"
|
||||
#include "snmp-ups.h"
|
||||
|
@ -45,6 +47,7 @@
|
|||
#include "compaq-mib.h"
|
||||
#include "bestpower-mib.h"
|
||||
#include "cyberpower-mib.h"
|
||||
#include "delta_ups-mib.h"
|
||||
#include "ietf-mib.h"
|
||||
|
||||
/* Address API change */
|
||||
|
@ -67,6 +70,7 @@ static mib2nut_info_t *mib2nut[] = {
|
|||
&compaq,
|
||||
&bestpower,
|
||||
&cyberpower,
|
||||
&delta_ups,
|
||||
/*
|
||||
* Prepend vendor specific MIB mappings before IETF, so that
|
||||
* if a device supports both IETF and vendor specific MIB,
|
||||
|
@ -87,13 +91,14 @@ int input_phases, output_phases, bypass_phases;
|
|||
mib2nut_info_t *mib2nut_info;
|
||||
/* FIXME: to be trashed */
|
||||
snmp_info_t *snmp_info;
|
||||
alarms_info_t *alarms_info;
|
||||
const char *mibname;
|
||||
const char *mibvers;
|
||||
|
||||
static void disable_transfer_oids(void);
|
||||
|
||||
#define DRIVER_NAME "Generic SNMP UPS driver"
|
||||
#define DRIVER_VERSION "0.68"
|
||||
#define DRIVER_VERSION "0.70"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
|
@ -469,77 +474,139 @@ void nut_snmp_cleanup(void)
|
|||
SOCK_CLEANUP; /* wrapper not needed on Unix! */
|
||||
}
|
||||
|
||||
struct snmp_pdu *nut_snmp_get(const char *OID)
|
||||
/* Free a struct snmp_pdu * returned by nut_snmp_walk */
|
||||
void nut_snmp_free(struct snmp_pdu ** array_to_free)
|
||||
{
|
||||
struct snmp_pdu ** current_element;
|
||||
|
||||
current_element = array_to_free;
|
||||
|
||||
while (*current_element != NULL) {
|
||||
snmp_free_pdu(*current_element);
|
||||
current_element++;
|
||||
}
|
||||
|
||||
free( array_to_free );
|
||||
}
|
||||
|
||||
/* Return a NULL terminated array of snmp_pdu * */
|
||||
struct snmp_pdu **nut_snmp_walk(const char *OID, int max_iteration)
|
||||
{
|
||||
int status;
|
||||
struct snmp_pdu *pdu, *response = NULL;
|
||||
oid name[MAX_OID_LEN];
|
||||
size_t name_len = MAX_OID_LEN;
|
||||
oid * current_name;
|
||||
size_t current_name_len;
|
||||
static unsigned int numerr = 0;
|
||||
int nb_iteration = 0;
|
||||
struct snmp_pdu ** ret_array = NULL;
|
||||
int type = SNMP_MSG_GET;
|
||||
|
||||
upsdebugx(3, "nut_snmp_get(%s)", OID);
|
||||
upsdebugx(3, "nut_snmp_walk(%s)", OID);
|
||||
|
||||
/* create and send request. */
|
||||
if (!snmp_parse_oid(OID, name, &name_len)) {
|
||||
upsdebugx(2, "[%s] nut_snmp_get: %s: %s",
|
||||
upsdebugx(2, "[%s] nut_snmp_walk: %s: %s",
|
||||
upsname?upsname:device_name, OID, snmp_api_errstring(snmp_errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdu = snmp_pdu_create(SNMP_MSG_GET);
|
||||
current_name = name;
|
||||
current_name_len = name_len;
|
||||
|
||||
if (pdu == NULL)
|
||||
fatalx(EXIT_FAILURE, "Not enough memory");
|
||||
|
||||
snmp_add_null_var(pdu, name, name_len);
|
||||
|
||||
status = snmp_synch_response(g_snmp_sess_p, pdu, &response);
|
||||
|
||||
if (!response)
|
||||
return NULL;
|
||||
|
||||
if (!((status == STAT_SUCCESS) && (response->errstat == SNMP_ERR_NOERROR)))
|
||||
{
|
||||
if (mibname == NULL) {
|
||||
/* We are probing for proper mib - ignore errors */
|
||||
snmp_free_pdu(response);
|
||||
return NULL;
|
||||
while( nb_iteration < max_iteration ) {
|
||||
/* Going to a shorter OID means we are outside our sub-tree */
|
||||
if( current_name_len < name_len ) {
|
||||
break;
|
||||
}
|
||||
|
||||
numerr++;
|
||||
pdu = snmp_pdu_create(type);
|
||||
|
||||
if ((numerr == SU_ERR_LIMIT) || ((numerr % SU_ERR_RATE) == 0))
|
||||
upslogx(LOG_WARNING, "[%s] Warning: excessive poll "
|
||||
"failures, limiting error reporting",
|
||||
upsname?upsname:device_name);
|
||||
if (pdu == NULL) {
|
||||
fatalx(EXIT_FAILURE, "Not enough memory");
|
||||
}
|
||||
|
||||
if ((numerr < SU_ERR_LIMIT) || ((numerr % SU_ERR_RATE) == 0))
|
||||
nut_snmp_perror(g_snmp_sess_p, status, response,
|
||||
"nut_snmp_get: %s", OID);
|
||||
snmp_add_null_var(pdu, current_name, current_name_len);
|
||||
|
||||
snmp_free_pdu(response);
|
||||
response = NULL;
|
||||
} else {
|
||||
numerr = 0;
|
||||
status = snmp_synch_response(g_snmp_sess_p, pdu, &response);
|
||||
|
||||
if (!response) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!((status == STAT_SUCCESS) && (response->errstat == SNMP_ERR_NOERROR))) {
|
||||
if (mibname == NULL) {
|
||||
/* We are probing for proper mib - ignore errors */
|
||||
snmp_free_pdu(response);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
numerr++;
|
||||
|
||||
if ((numerr == SU_ERR_LIMIT) || ((numerr % SU_ERR_RATE) == 0)) {
|
||||
upslogx(LOG_WARNING, "[%s] Warning: excessive poll "
|
||||
"failures, limiting error reporting",
|
||||
upsname?upsname:device_name);
|
||||
}
|
||||
|
||||
if ((numerr < SU_ERR_LIMIT) || ((numerr % SU_ERR_RATE) == 0)) {
|
||||
if (type == SNMP_MSG_GETNEXT) {
|
||||
upsdebugx(2, "=> No more OID, walk complete");
|
||||
}
|
||||
else {
|
||||
nut_snmp_perror(g_snmp_sess_p, status, response,
|
||||
"nut_snmp_walk: %s", OID);
|
||||
}
|
||||
}
|
||||
|
||||
snmp_free_pdu(response);
|
||||
break;
|
||||
} else {
|
||||
numerr = 0;
|
||||
}
|
||||
|
||||
nb_iteration++;
|
||||
/* +1 is for the terminating NULL */
|
||||
ret_array = realloc(ret_array,sizeof(struct snmp_pdu*)*(nb_iteration+1));
|
||||
ret_array[nb_iteration-1] = response;
|
||||
ret_array[nb_iteration]=NULL;
|
||||
|
||||
current_name = response->variables->name;
|
||||
current_name_len = response->variables->name_length;
|
||||
|
||||
type = SNMP_MSG_GETNEXT;
|
||||
}
|
||||
|
||||
return response;
|
||||
return ret_array;
|
||||
}
|
||||
|
||||
bool_t nut_snmp_get_str(const char *OID, char *buf, size_t buf_len, info_lkp_t *oid2info)
|
||||
struct snmp_pdu *nut_snmp_get(const char *OID)
|
||||
{
|
||||
size_t len = 0;
|
||||
struct snmp_pdu *pdu;
|
||||
struct snmp_pdu ** pdu_array;
|
||||
struct snmp_pdu * ret_pdu;
|
||||
|
||||
upsdebugx(3, "Entering nut_snmp_get_str()");
|
||||
upsdebugx(3, "nut_snmp_get(%s)", OID);
|
||||
|
||||
pdu_array = nut_snmp_walk(OID,1);
|
||||
|
||||
if(pdu_array == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret_pdu = snmp_clone_pdu(*pdu_array);
|
||||
|
||||
nut_snmp_free(pdu_array);
|
||||
|
||||
return ret_pdu;
|
||||
}
|
||||
|
||||
static bool_t decode_str(struct snmp_pdu *pdu, char *buf, size_t buf_len, info_lkp_t *oid2info) {
|
||||
size_t len = 0;
|
||||
|
||||
/* zero out buffer. */
|
||||
memset(buf, 0, buf_len);
|
||||
|
||||
pdu = nut_snmp_get(OID);
|
||||
if (pdu == NULL)
|
||||
return FALSE;
|
||||
|
||||
switch (pdu->variables->type) {
|
||||
case ASN_OCTET_STR:
|
||||
case ASN_OPAQUE:
|
||||
|
@ -573,14 +640,33 @@ bool_t nut_snmp_get_str(const char *OID, char *buf, size_t buf_len, info_lkp_t *
|
|||
len = snprint_objid (buf, buf_len, pdu->variables->val.objid, pdu->variables->val_len / sizeof(oid));
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t nut_snmp_get_str(const char *OID, char *buf, size_t buf_len, info_lkp_t *oid2info)
|
||||
{
|
||||
struct snmp_pdu *pdu;
|
||||
bool_t ret;
|
||||
|
||||
upsdebugx(3, "Entering nut_snmp_get_str()");
|
||||
|
||||
pdu = nut_snmp_get(OID);
|
||||
if (pdu == NULL)
|
||||
return FALSE;
|
||||
|
||||
ret = decode_str(pdu,buf,buf_len,oid2info);
|
||||
|
||||
if(ret == FALSE) {
|
||||
upsdebugx(2, "[%s] unhandled ASN 0x%x received from %s",
|
||||
upsname?upsname:device_name, pdu->variables->type, OID);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
snmp_free_pdu(pdu);
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool_t nut_snmp_get_int(const char *OID, long *pval)
|
||||
|
@ -917,6 +1003,7 @@ bool_t load_mib2nut(const char *mib)
|
|||
OID_pwr_status = m2n->oid_pwr_status;
|
||||
mibname = m2n->mib_name;
|
||||
mibvers = m2n->mib_version;
|
||||
alarms_info = m2n->alarms_info;
|
||||
upsdebugx(1, "load_mib2nut: using %s mib", mibname);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1276,50 +1363,56 @@ bool_t snmp_ups_walk(int mode)
|
|||
outlet_count = atoi(dstate_getinfo("outlet.count"));
|
||||
}
|
||||
|
||||
/* general init of data using the template */
|
||||
instantiate_info(su_info_p, &cur_info_p);
|
||||
/* Only instantiate outlets if needed! */
|
||||
if (outlet_count > 0) {
|
||||
/* general init of data using the template */
|
||||
instantiate_info(su_info_p, &cur_info_p);
|
||||
|
||||
for (cur_outlet_number = base_snmp_outlet_index(su_info_p->OID) ;
|
||||
cur_outlet_number < (outlet_count + base_snmp_outlet_index(su_info_p->OID)) ;
|
||||
cur_outlet_number++)
|
||||
{
|
||||
cur_nut_index = cur_outlet_number + base_nut_outlet_offset();
|
||||
sprintf((char*)cur_info_p.info_type, su_info_p->info_type,
|
||||
cur_nut_index);
|
||||
for (cur_outlet_number = base_snmp_outlet_index(su_info_p->OID) ;
|
||||
cur_outlet_number < (outlet_count + base_snmp_outlet_index(su_info_p->OID)) ;
|
||||
cur_outlet_number++)
|
||||
{
|
||||
cur_nut_index = cur_outlet_number + base_nut_outlet_offset();
|
||||
sprintf((char*)cur_info_p.info_type, su_info_p->info_type,
|
||||
cur_nut_index);
|
||||
|
||||
/* check if default value is also a template */
|
||||
if ((cur_info_p.dfl != NULL) &&
|
||||
(strstr(su_info_p->dfl, "%i") != NULL)) {
|
||||
cur_info_p.dfl = (char *)xmalloc(SU_INFOSIZE);
|
||||
sprintf((char *)cur_info_p.dfl, su_info_p->dfl, cur_nut_index);
|
||||
}
|
||||
|
||||
if (cur_info_p.OID != NULL) {
|
||||
sprintf((char *)cur_info_p.OID, su_info_p->OID, cur_outlet_number);
|
||||
|
||||
/* add outlet instant commands to the info database. */
|
||||
if (SU_TYPE(su_info_p) == SU_TYPE_CMD) {
|
||||
/* FIXME: only add if "su_ups_get(cur_info_p) == TRUE" */
|
||||
if (mode == SU_WALKMODE_INIT)
|
||||
dstate_addcmd(cur_info_p.info_type);
|
||||
/* check if default value is also a template */
|
||||
if ((cur_info_p.dfl != NULL) &&
|
||||
(strstr(su_info_p->dfl, "%i") != NULL)) {
|
||||
cur_info_p.dfl = (char *)xmalloc(SU_INFOSIZE);
|
||||
sprintf((char *)cur_info_p.dfl, su_info_p->dfl, cur_nut_index);
|
||||
}
|
||||
else /* get and process this data */
|
||||
status = get_and_process_data(mode, &cur_info_p);
|
||||
} else {
|
||||
/* server side (ABSENT) data */
|
||||
su_setinfo(&cur_info_p, NULL);
|
||||
}
|
||||
/* set back the flag */
|
||||
su_info_p->flags = cur_info_p.flags;
|
||||
}
|
||||
free((char*)cur_info_p.info_type);
|
||||
if (cur_info_p.OID != NULL)
|
||||
free((char*)cur_info_p.OID);
|
||||
if ((cur_info_p.dfl != NULL) &&
|
||||
(strstr(su_info_p->dfl, "%i") != NULL))
|
||||
free((char*)cur_info_p.dfl);
|
||||
|
||||
} else {
|
||||
if (cur_info_p.OID != NULL) {
|
||||
sprintf((char *)cur_info_p.OID, su_info_p->OID, cur_outlet_number);
|
||||
|
||||
/* add outlet instant commands to the info database. */
|
||||
if (SU_TYPE(su_info_p) == SU_TYPE_CMD) {
|
||||
/* FIXME: only add if "su_ups_get(cur_info_p) == TRUE" */
|
||||
if (mode == SU_WALKMODE_INIT)
|
||||
dstate_addcmd(cur_info_p.info_type);
|
||||
}
|
||||
else /* get and process this data */
|
||||
status = get_and_process_data(mode, &cur_info_p);
|
||||
} else {
|
||||
/* server side (ABSENT) data */
|
||||
su_setinfo(&cur_info_p, NULL);
|
||||
}
|
||||
/* set back the flag */
|
||||
su_info_p->flags = cur_info_p.flags;
|
||||
}
|
||||
free((char*)cur_info_p.info_type);
|
||||
if (cur_info_p.OID != NULL)
|
||||
free((char*)cur_info_p.OID);
|
||||
if ((cur_info_p.dfl != NULL) &&
|
||||
(strstr(su_info_p->dfl, "%i") != NULL))
|
||||
free((char*)cur_info_p.dfl);
|
||||
}
|
||||
else {
|
||||
upsdebugx(1, "No outlet present, discarding template definition...");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* get and process this data */
|
||||
status = get_and_process_data(mode, su_info_p);
|
||||
}
|
||||
|
@ -1335,6 +1428,10 @@ bool_t su_ups_get(snmp_info_t *su_info_p)
|
|||
static char buf[SU_INFOSIZE];
|
||||
bool_t status;
|
||||
long value;
|
||||
struct snmp_pdu ** pdu_array;
|
||||
struct snmp_pdu * current_pdu;
|
||||
alarms_info_t * alarms;
|
||||
int index = 0;
|
||||
|
||||
upsdebugx(2, "su_ups_get: %s %s", su_info_p->info_type, su_info_p->OID);
|
||||
|
||||
|
@ -1351,6 +1448,43 @@ bool_t su_ups_get(snmp_info_t *su_info_p)
|
|||
return status;
|
||||
}
|
||||
|
||||
if (!strcasecmp(su_info_p->info_type, "ups.alarms")) {
|
||||
status = nut_snmp_get_int(su_info_p->OID, &value);
|
||||
if (status == TRUE) {
|
||||
upsdebugx(2, "=> value: %ld", value);
|
||||
if( value > 0 ) {
|
||||
pdu_array = nut_snmp_walk(su_info_p->OID,INT_MAX);
|
||||
if(pdu_array == NULL) {
|
||||
upsdebugx(2, "=> Walk failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
current_pdu = pdu_array[index];
|
||||
while(current_pdu) {
|
||||
decode_str(current_pdu,buf,sizeof(buf),NULL);
|
||||
alarms = alarms_info;
|
||||
while( alarms->OID ) {
|
||||
if(!strcmp(buf+1,alarms_info->OID)) {
|
||||
upsdebugx(3, "Alarm OID %s found => %s", alarms->OID, alarms->info_value);
|
||||
status_set(alarms->info_value);
|
||||
break;
|
||||
}
|
||||
alarms++;
|
||||
}
|
||||
index++;
|
||||
current_pdu = pdu_array[index];
|
||||
}
|
||||
nut_snmp_free(pdu_array);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
upsdebugx(2, "=> Failed");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* another special case */
|
||||
if (!strcasecmp(su_info_p->info_type, "ambient.temperature")) {
|
||||
float temp=0;
|
||||
|
|
|
@ -200,6 +200,11 @@ typedef struct {
|
|||
#define SU_ERR_LIMIT 10 /* start limiting after this many errors in a row */
|
||||
#define SU_ERR_RATE 100 /* only print every nth error once limiting starts */
|
||||
|
||||
typedef struct {
|
||||
const char * OID;
|
||||
const char *info_value;
|
||||
} alarms_info_t;
|
||||
|
||||
typedef struct {
|
||||
const char *mib_name;
|
||||
const char *mib_version;
|
||||
|
@ -208,7 +213,7 @@ typedef struct {
|
|||
snmp_info_t *snmp_info; /* pointer to the good Snmp2Nut lookup data */
|
||||
const char *sysOID; /* OID to match against sysOID, aka MIB
|
||||
* main entry point */
|
||||
|
||||
alarms_info_t *alarms_info;
|
||||
} mib2nut_info_t;
|
||||
|
||||
/* Common SNMP functions */
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "tripplite-hid.h"
|
||||
#include "usb-common.h"
|
||||
|
||||
#define TRIPPLITE_HID_VERSION "TrippLite HID 0.8"
|
||||
#define TRIPPLITE_HID_VERSION "TrippLite HID 0.81"
|
||||
/* 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(void)
|
||||
static void *battery_scale_1dot0(USBDevice_t *device)
|
||||
{
|
||||
/* FIXME: we could remove this one since it's the default! */
|
||||
battery_scale = 1.0;
|
||||
return NULL;
|
||||
}
|
||||
static void *battery_scale_0dot1(void)
|
||||
static void *battery_scale_0dot1(USBDevice_t *device)
|
||||
{
|
||||
battery_scale = 0.1;
|
||||
return NULL;
|
||||
|
@ -95,6 +95,8 @@ static usb_device_id_t tripplite_usb_device_table[] = {
|
|||
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3014), battery_scale_1dot0 },
|
||||
/* e.g. ? */
|
||||
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3015), battery_scale_1dot0 },
|
||||
/* e.g. TrippLite Smart1500LCD (newer unit) */
|
||||
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x3016), battery_scale_1dot0 },
|
||||
/* e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?) */
|
||||
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4001), battery_scale_1dot0 },
|
||||
/* e.g. TrippLite SmartOnline SU6000RT4U? */
|
||||
|
@ -435,8 +437,7 @@ static const char *tripplite_format_serial(HIDDevice_t *hd) {
|
|||
* the device is supported by this subdriver, else 0. */
|
||||
static int tripplite_claim(HIDDevice_t *hd) {
|
||||
|
||||
int status = is_usb_device_supported(tripplite_usb_device_table, hd->VendorID,
|
||||
hd->ProductID);
|
||||
int status = is_usb_device_supported(tripplite_usb_device_table, hd);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
|
|
@ -125,193 +125,6 @@
|
|||
* :S -- enables remote reboot/remote power on
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
POD ("Plain Old Documentation") - run through pod2html or perldoc. See
|
||||
perlpod(1) for more information.
|
||||
|
||||
pod2man --name='TRIPPLITE_USB' --section=8 --release='$Rev: 3555 $' --center='Network UPS Tools (NUT)' tripplite_usb.c
|
||||
|
||||
=head1 NAME
|
||||
|
||||
tripplite_usb - Driver for older Tripp Lite USB UPSes (not PDC HID)
|
||||
|
||||
=head1 NOTE
|
||||
|
||||
This man page only documents the hardware-specific features of the
|
||||
tripplite_usb driver. For information about the core driver, see
|
||||
nutupsdrv(8).
|
||||
|
||||
=head1 SUPPORTED HARDWARE
|
||||
|
||||
This driver should work with older Tripp Lite UPSes which are detected as USB
|
||||
HID-class devices, but are not true HID Power-Device Class devices. So far,
|
||||
the devices supported by tripplite_usb have product ID 0001, and the newer
|
||||
units (such as those with "LCD" in the model name) with product ID 2001 require
|
||||
the usbhid-ups driver instead. Please report success or failure to
|
||||
the nut-upsuser mailing list. A key piece of information is the protocol
|
||||
number, returned in ups.debug.0. Also, be sure to turn on debugging (C<-DDD>)
|
||||
for more informative log messages. If your Tripp Lite UPS uses a serial port,
|
||||
you may wish to investigate the tripplite(8) or tripplite_su(8) driver.
|
||||
|
||||
This driver has been tested with the following models:
|
||||
|
||||
=over
|
||||
|
||||
=item * INTERNETOFFICE700
|
||||
|
||||
=item * OMNISV1000
|
||||
|
||||
=item * OMNISV1500XL (some warnings)
|
||||
|
||||
=item * SMART700USB
|
||||
|
||||
=item * SMART1500RM2U
|
||||
|
||||
=item * SMART2200RMXL2U
|
||||
|
||||
=item * SMART3000RM2U
|
||||
|
||||
=back
|
||||
|
||||
If you have used Tripp Lite's PowerAlert software to connect to your UPS, there
|
||||
is a good chance that tripplite_usb(8) will work if it uses one of the
|
||||
following protocols:
|
||||
|
||||
=over
|
||||
|
||||
=item * Protocol 0004
|
||||
|
||||
=item * Protocol 1001
|
||||
|
||||
=item * Protocol 2001
|
||||
|
||||
=item * Protocol 3003
|
||||
|
||||
=back
|
||||
|
||||
=head1 EXTRA ARGUMENTS
|
||||
|
||||
This driver supports the following optional setting in the ups.conf(5) file
|
||||
(or with C<-x> on the command line):
|
||||
|
||||
=over
|
||||
|
||||
=item offdelay
|
||||
|
||||
This setting controls the delay between receiving the "kill" command (C<-k>)
|
||||
and actually cutting power to the computer.
|
||||
|
||||
=item bus
|
||||
|
||||
This regular expression is used to match the USB bus (as seen in
|
||||
C</proc/bus/usb/devices> or lsusb(8); including leading zeroes).
|
||||
|
||||
=item product
|
||||
|
||||
A regular expression to match the product string for the UPS. This would be
|
||||
useful if you have two different Tripp Lite UPS models connected to the
|
||||
system, and you want to be sure that you shut them down in the correct order.
|
||||
|
||||
Note that this regex is matched against the full USB product string as seen in
|
||||
lsusb(8). The C<ups.model> in the C<upsc> output only lists the name after
|
||||
"TRIPP LITE", so to match a SMART2200RMXL2U, you could use the regex
|
||||
".*SMART2200.*".
|
||||
|
||||
=item productid
|
||||
|
||||
The productid is a regular expression which matches the UPS PID as four
|
||||
hexadecimal digits. So far, the only devices that work with this driver have
|
||||
PID C<0001>.
|
||||
|
||||
=item serial
|
||||
|
||||
It does not appear that these particular Tripp Lite UPSes use the iSerial
|
||||
descriptor field to return a serial number. However, in case your unit does,
|
||||
you may specify it here.
|
||||
|
||||
=back
|
||||
|
||||
For more information on regular expressions, see regex(7)
|
||||
|
||||
=head1 RUNTIME VARIABLES
|
||||
|
||||
=over
|
||||
|
||||
=item ups.delay.shutdown
|
||||
|
||||
This variable is the same as the C<offdelay> setting, but it can be changed at
|
||||
runtime by upsrw(8).
|
||||
|
||||
=item ups.id
|
||||
|
||||
Some SMARTPRO models feature an ID that can be set and retrieved. If your UPS
|
||||
supports this feature, this variable will be listed in the output of upsrw(8).
|
||||
|
||||
=item outlet.1.switch
|
||||
|
||||
Some Tripp Lite units have a switchable outlet (usually outlet #1) which can be
|
||||
turned on and off by writing C<1> or C<0>, respectively, to C<outlet.1.switch>.
|
||||
If your unit has multiple switchable outlets, substitute the outlet number for
|
||||
"1" in the variable name. Be sure to test this first - there is no other way to
|
||||
be certain that the number used by the driver matches the label on the unit.
|
||||
|
||||
=back
|
||||
|
||||
=head1 KNOWN ISSUES AND BUGS
|
||||
|
||||
The driver was not developed with any official documentation from Tripp Lite,
|
||||
so certain events may confuse the driver. If you observe any strange behavior,
|
||||
please re-run the driver with C<-DDD> to increase the verbosity.
|
||||
|
||||
So far, the Tripp Lite UPSes do not seem to have any serial number or other
|
||||
unique identifier accessible through USB. Thus, when monitoring several Tripp
|
||||
Lite USB UPSes, you should use either the C<bus> or C<product> configuration
|
||||
options to uniquely specify which UPS a given driver instance should control.
|
||||
|
||||
For instance, you can easily monitor an OMNIVS1000 and a SMART1500RM2U at the
|
||||
same time, since they have different USB Product ID strings. If you have two
|
||||
SMART1500RM2U units, you would have to find which USB bus number each unit is
|
||||
on (via C<lsusb>), which may result in ambiguities if the available USB ports
|
||||
are on the same bus.
|
||||
|
||||
Some of the SMART*2U models have an ID number, but because this ID is not
|
||||
exposed as a USB string descriptor, there is no easy way to use this ID to
|
||||
distinguish between multiple UPS units on a single machine.
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Charles Lepple E<lt>clepple+nut@gmail.com<gt>, based on the tripplite driver by
|
||||
Rickard E. (Rik) Faith E<lt>faith@alephnull.comE<gt> and Nicholas Kain
|
||||
E<lt>nicholas@kain.usE<gt>. Please do not email the authors directly - use the
|
||||
nut-upsdev mailing list.
|
||||
|
||||
A Tripp Lite OMNIVS1000 was graciously donated to the NUT project by:
|
||||
|
||||
=over
|
||||
|
||||
Relevant Evidence, LLC.
|
||||
|
||||
http://www.relevantevidence.com
|
||||
|
||||
Email: info@relevantevidence.com
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=head2 The core driver:
|
||||
|
||||
nutupsdrv(8), regex(7), usbhid-ups(8)
|
||||
|
||||
=head2 Internet resources:
|
||||
|
||||
The NUT (Network UPS Tools) home page: http://www.networkupstools.org/
|
||||
|
||||
=cut
|
||||
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "libusb.h"
|
||||
#include <math.h>
|
||||
|
@ -348,7 +161,7 @@ static usb_device_id_t tripplite_usb_device_table[] = {
|
|||
|
||||
static int subdriver_match_func(USBDevice_t *hd, void *privdata)
|
||||
{
|
||||
switch (is_usb_device_supported(tripplite_usb_device_table, hd->VendorID, hd->ProductID))
|
||||
switch (is_usb_device_supported(tripplite_usb_device_table, hd))
|
||||
{
|
||||
case SUPPORTED:
|
||||
return 1;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
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 3597 2012-05-15 11:22:06Z aquette $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
|
|
@ -20,27 +20,27 @@
|
|||
#include "common.h"
|
||||
#include "usb-common.h"
|
||||
|
||||
int is_usb_device_supported(usb_device_id_t *usb_device_id_list, int dev_VendorID, int dev_ProductID)
|
||||
int is_usb_device_supported(usb_device_id_t *usb_device_id_list, USBDevice_t *device)
|
||||
{
|
||||
int retval = NOT_SUPPORTED;
|
||||
usb_device_id_t *usbdev;
|
||||
|
||||
for (usbdev = usb_device_id_list; usbdev->vendorID != -1; usbdev++) {
|
||||
|
||||
if (usbdev->vendorID != dev_VendorID) {
|
||||
if (usbdev->vendorID != device->VendorID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* flag as possibly supported if we see a known vendor */
|
||||
retval = POSSIBLY_SUPPORTED;
|
||||
|
||||
if (usbdev->productID != dev_ProductID) {
|
||||
if (usbdev->productID != device->ProductID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* call the specific handler, if it exists */
|
||||
if (usbdev->fun != NULL) {
|
||||
(*usbdev->fun)();
|
||||
(*usbdev->fun)(device);
|
||||
}
|
||||
|
||||
return SUPPORTED;
|
||||
|
|
|
@ -77,7 +77,7 @@ void USBFreeRegexMatcher(USBDeviceMatcher_t *matcher);
|
|||
typedef struct {
|
||||
int vendorID;
|
||||
int productID;
|
||||
void *(*fun)(void); /* handler for specific processing */
|
||||
void *(*fun)(USBDevice_t *); /* handler for specific processing */
|
||||
} usb_device_id_t;
|
||||
|
||||
#define NOT_SUPPORTED 0
|
||||
|
@ -88,6 +88,6 @@ typedef struct {
|
|||
* supported devices. Return values:
|
||||
* NOT_SUPPORTED (0), POSSIBLY_SUPPORTED (1) or SUPPORTED (2) */
|
||||
int is_usb_device_supported(usb_device_id_t *usb_device_id_list,
|
||||
int dev_VendorID, int dev_ProductID);
|
||||
USBDevice_t *device);
|
||||
|
||||
#endif /* NUT_USB_COMMON_H */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#define DRIVER_NAME "Generic HID driver"
|
||||
#define DRIVER_VERSION "0.37"
|
||||
#define DRIVER_VERSION "0.38"
|
||||
|
||||
#include "main.h"
|
||||
#include "libhid.h"
|
||||
|
@ -37,6 +37,7 @@
|
|||
|
||||
/* include all known subdrivers */
|
||||
#include "mge-hid.h"
|
||||
|
||||
#ifndef SHUT_MODE
|
||||
#include "explore-hid.h"
|
||||
#include "apc-hid.h"
|
||||
|
@ -46,6 +47,7 @@
|
|||
#include "powercom-hid.h"
|
||||
#include "tripplite-hid.h"
|
||||
#include "idowell-hid.h"
|
||||
#include "openups-hid.h"
|
||||
#endif
|
||||
|
||||
/* master list of avaiable subdrivers */
|
||||
|
@ -62,6 +64,7 @@ static subdriver_t *subdriver_list[] = {
|
|||
&powercom_subdriver,
|
||||
&tripplite_subdriver,
|
||||
&idowell_subdriver,
|
||||
&openups_subdriver,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@ -717,9 +720,8 @@ void upsdrv_makevartable(void)
|
|||
|
||||
upsdebugx(1, "upsdrv_makevartable...");
|
||||
|
||||
snprintf(temp, sizeof(temp), "Set low battery level, in %% (default=%s).", DEFAULT_LOWBATT);
|
||||
addvar (VAR_VALUE, HU_VAR_LOWBATT, temp);
|
||||
|
||||
snprintf(temp, sizeof(temp), "Set low battery level, in %% (default=%s).", DEFAULT_LOWBATT);
|
||||
addvar (VAR_VALUE, HU_VAR_LOWBATT, temp);
|
||||
|
||||
snprintf(temp, sizeof(temp), "Set shutdown delay, in seconds (default=%s)", DEFAULT_OFFDELAY);
|
||||
addvar(VAR_VALUE, HU_VAR_OFFDELAY, temp);
|
||||
|
@ -742,6 +744,7 @@ void upsdrv_makevartable(void)
|
|||
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_FLAG, "explore", "Diagnostic matching of unsupported UPS");
|
||||
addvar(VAR_FLAG, "maxreport", "Activate tweak for buggy APC Back-UPS firmware");
|
||||
#else
|
||||
addvar(VAR_VALUE, "notification", "Set notification type, (ignored, only for backward compatibility)");
|
||||
#endif
|
||||
|
@ -906,6 +909,11 @@ void upsdrv_initups(void)
|
|||
fatalx(EXIT_FAILURE, "must specify \"vendorid\" when using \"explore\"");
|
||||
}
|
||||
|
||||
/* Activate maxreport tweak */
|
||||
if (testvar("maxreport")) {
|
||||
max_report_size = 1;
|
||||
}
|
||||
|
||||
/* process the UPS selection options */
|
||||
regex_array[0] = getval("vendorid");
|
||||
regex_array[1] = getval("productid");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue