Imported Upstream version 2.6.3
This commit is contained in:
parent
45043b58d0
commit
fad6ced6f6
255 changed files with 11081 additions and 4629 deletions
|
@ -23,7 +23,7 @@ endif
|
|||
if WITH_SNMP
|
||||
AM_CFLAGS += $(LIBNETSNMP_CFLAGS)
|
||||
endif
|
||||
if WITH_NEONXML
|
||||
if WITH_NEON
|
||||
AM_CFLAGS += $(LIBNEON_CFLAGS)
|
||||
endif
|
||||
if WITH_LIBPOWERMAN
|
||||
|
@ -68,7 +68,7 @@ if WITH_HAL
|
|||
halexecdir = $(HAL_CALLOUTS_PATH)
|
||||
halexec_PROGRAMS = $(HAL_DRIVERLIST)
|
||||
endif
|
||||
if WITH_NEONXML
|
||||
if WITH_NEON
|
||||
driverexec_PROGRAMS += $(NEONXML_DRIVERLIST)
|
||||
endif
|
||||
if WITH_LIBPOWERMAN
|
||||
|
@ -182,7 +182,7 @@ newmge_shut_LDADD = $(LDADD)
|
|||
# SNMP
|
||||
snmp_ups_SOURCES = snmp-ups.c apc-mib.c baytech-mib.c compaq-mib.c eaton-mib.c \
|
||||
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c \
|
||||
bestpower-mib.c
|
||||
bestpower-mib.c cyberpower-mib.c
|
||||
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
|
||||
|
||||
# HAL
|
||||
|
@ -228,7 +228,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \
|
|||
powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \
|
||||
safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \
|
||||
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h \
|
||||
apcsmart.h apcsmart_tabs.h apcsmart-old.h
|
||||
apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h
|
||||
|
||||
# Define a dummy library so that Automake builds rules for the
|
||||
# corresponding object files. This library is not actually built,
|
||||
|
|
|
@ -41,7 +41,7 @@ target_triplet = @target@
|
|||
@WITH_HAL_TRUE@am__append_1 = $(LIBHAL_CFLAGS)
|
||||
@WITH_USB_TRUE@am__append_2 = $(LIBUSB_CFLAGS)
|
||||
@WITH_SNMP_TRUE@am__append_3 = $(LIBNETSNMP_CFLAGS)
|
||||
@WITH_NEONXML_TRUE@am__append_4 = $(LIBNEON_CFLAGS)
|
||||
@WITH_NEON_TRUE@am__append_4 = $(LIBNEON_CFLAGS)
|
||||
@WITH_LIBPOWERMAN_TRUE@am__append_5 = $(LIBPOWERMAN_CFLAGS)
|
||||
@WITH_IPMI_TRUE@am__append_6 = $(LIBIPMI_CFLAGS)
|
||||
EXTRA_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_4) \
|
||||
|
@ -60,7 +60,7 @@ EXTRA_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_4) \
|
|||
@SOME_DRIVERS_FALSE@@WITH_USB_TRUE@am__append_9 = $(USB_LIBUSB_DRIVERLIST)
|
||||
@SOME_DRIVERS_FALSE@@WITH_HAL_TRUE@halexec_PROGRAMS = \
|
||||
@SOME_DRIVERS_FALSE@@WITH_HAL_TRUE@ $(am__EXEEXT_12)
|
||||
@SOME_DRIVERS_FALSE@@WITH_NEONXML_TRUE@am__append_10 = $(NEONXML_DRIVERLIST)
|
||||
@SOME_DRIVERS_FALSE@@WITH_NEON_TRUE@am__append_10 = $(NEONXML_DRIVERLIST)
|
||||
@SOME_DRIVERS_FALSE@@WITH_LIBPOWERMAN_TRUE@am__append_11 = powerman-pdu
|
||||
@SOME_DRIVERS_FALSE@@WITH_IPMI_TRUE@am__append_12 = nut-ipmipsu
|
||||
@WITH_SSL_TRUE@am__append_13 = $(LIBSSL_CFLAGS)
|
||||
|
@ -80,6 +80,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
|
|||
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libgd.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libhal.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libltdl.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libneon.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
|
||||
|
@ -130,7 +131,7 @@ am__EXEEXT_5 = netxml-ups$(EXEEXT)
|
|||
@SOME_DRIVERS_FALSE@@WITH_SERIAL_TRUE@am__EXEEXT_6 = $(am__EXEEXT_1)
|
||||
@SOME_DRIVERS_FALSE@@WITH_SNMP_TRUE@am__EXEEXT_7 = $(am__EXEEXT_2)
|
||||
@SOME_DRIVERS_FALSE@@WITH_USB_TRUE@am__EXEEXT_8 = $(am__EXEEXT_3)
|
||||
@SOME_DRIVERS_FALSE@@WITH_NEONXML_TRUE@am__EXEEXT_9 = $(am__EXEEXT_5)
|
||||
@SOME_DRIVERS_FALSE@@WITH_NEON_TRUE@am__EXEEXT_9 = $(am__EXEEXT_5)
|
||||
@SOME_DRIVERS_FALSE@@WITH_LIBPOWERMAN_TRUE@am__EXEEXT_10 = powerman-pdu$(EXEEXT)
|
||||
@SOME_DRIVERS_FALSE@@WITH_IPMI_TRUE@am__EXEEXT_11 = \
|
||||
@SOME_DRIVERS_FALSE@@WITH_IPMI_TRUE@ nut-ipmipsu$(EXEEXT)
|
||||
|
@ -335,7 +336,7 @@ am_snmp_ups_OBJECTS = snmp-ups.$(OBJEXT) apc-mib.$(OBJEXT) \
|
|||
baytech-mib.$(OBJEXT) compaq-mib.$(OBJEXT) eaton-mib.$(OBJEXT) \
|
||||
ietf-mib.$(OBJEXT) mge-mib.$(OBJEXT) netvision-mib.$(OBJEXT) \
|
||||
powerware-mib.$(OBJEXT) raritan-pdu-mib.$(OBJEXT) \
|
||||
bestpower-mib.$(OBJEXT)
|
||||
bestpower-mib.$(OBJEXT) cyberpower-mib.$(OBJEXT)
|
||||
snmp_ups_OBJECTS = $(am_snmp_ups_OBJECTS)
|
||||
snmp_ups_DEPENDENCIES = $(LDADD_DRIVERS) $(am__DEPENDENCIES_1)
|
||||
am_solis_OBJECTS = solis.$(OBJEXT)
|
||||
|
@ -451,6 +452,7 @@ CYGPATH_W = @CYGPATH_W@
|
|||
DBLATEX = @DBLATEX@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DOC_BUILD_LIST = @DOC_BUILD_LIST@
|
||||
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
|
||||
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
|
||||
|
@ -483,6 +485,8 @@ LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
|
|||
LIBHAL_LIBS = @LIBHAL_LIBS@
|
||||
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
|
||||
LIBIPMI_LIBS = @LIBIPMI_LIBS@
|
||||
LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@
|
||||
LIBLTDL_LIBS = @LIBLTDL_LIBS@
|
||||
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
|
||||
LIBNEON_LIBS = @LIBNEON_LIBS@
|
||||
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
|
||||
|
@ -503,6 +507,7 @@ LN_S = @LN_S@
|
|||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NETLIBS = @NETLIBS@
|
||||
NM = @NM@
|
||||
|
@ -534,12 +539,14 @@ SHELL = @SHELL@
|
|||
STATEPATH = @STATEPATH@
|
||||
STRIP = @STRIP@
|
||||
SUN_LIBUSB = @SUN_LIBUSB@
|
||||
TREE_VERSION = @TREE_VERSION@
|
||||
VERSION = @VERSION@
|
||||
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
|
@ -575,7 +582,6 @@ libdir = @libdir@
|
|||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
|
@ -727,7 +733,7 @@ newmge_shut_LDADD = $(LDADD)
|
|||
# SNMP
|
||||
snmp_ups_SOURCES = snmp-ups.c apc-mib.c baytech-mib.c compaq-mib.c eaton-mib.c \
|
||||
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c \
|
||||
bestpower-mib.c
|
||||
bestpower-mib.c cyberpower-mib.c
|
||||
|
||||
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
|
||||
|
||||
|
@ -768,7 +774,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h \
|
|||
powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h \
|
||||
safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h \
|
||||
upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h \
|
||||
apcsmart.h apcsmart_tabs.h apcsmart-old.h
|
||||
apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h
|
||||
|
||||
|
||||
# Define a dummy library so that Automake builds rules for the
|
||||
|
@ -1101,6 +1107,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clone.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compaq-mib.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cps-hid.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cyberpower-mib.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dstate-hal.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dstate.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy_ups-dummy-ups.Po@am__quote@
|
||||
|
|
|
@ -193,8 +193,6 @@ static void apc_ser_set(void)
|
|||
tio.c_iflag |= (IGNCR | IGNPAR);
|
||||
tio.c_iflag &= ~(IXON | IXOFF);
|
||||
|
||||
tio.c_oflag = 0;
|
||||
|
||||
tio.c_cc[VEOL] = '*'; /* specially handled in apc_read() */
|
||||
|
||||
#ifdef _POSIX_VDISABLE
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <usb.h>
|
||||
|
||||
#define SUBDRIVER_NAME "USB communication subdriver"
|
||||
#define SUBDRIVER_VERSION "0.18"
|
||||
#define SUBDRIVER_VERSION "0.19"
|
||||
|
||||
/* communication driver description structure */
|
||||
upsdrv_info_t comm_upsdrv_info = {
|
||||
|
@ -23,6 +23,8 @@ upsdrv_info_t comm_upsdrv_info = {
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
#define MAX_TRY 4
|
||||
|
||||
/* Powerware */
|
||||
#define POWERWARE 0x0592
|
||||
|
||||
|
@ -95,29 +97,33 @@ static unsigned int comm_failures = 0;
|
|||
/* Functions implementations */
|
||||
void send_read_command(unsigned char command)
|
||||
{
|
||||
unsigned char buf[4];
|
||||
unsigned char buf[4];
|
||||
|
||||
buf[0] = PW_COMMAND_START_BYTE;
|
||||
buf[1] = 0x01; /* data length */
|
||||
buf[2] = command; /* command to send */
|
||||
buf[3] = calc_checksum(buf); /* checksum */
|
||||
usb_set_descriptor(upsdev, USB_DT_STRING, 4, buf, 4); /* FIXME: Ignore error */
|
||||
if (upsdev) {
|
||||
buf[0] = PW_COMMAND_START_BYTE;
|
||||
buf[1] = 0x01; /* data length */
|
||||
buf[2] = command; /* command to send */
|
||||
buf[3] = calc_checksum(buf); /* checksum */
|
||||
usb_set_descriptor(upsdev, USB_DT_STRING, 4, buf, 4); /* FIXME: Ignore error */
|
||||
}
|
||||
}
|
||||
|
||||
void send_write_command(unsigned char *command, int command_length)
|
||||
{
|
||||
unsigned char sbuf[128];
|
||||
|
||||
/* Prepare the send buffer */
|
||||
sbuf[0] = PW_COMMAND_START_BYTE;
|
||||
sbuf[1] = (unsigned char)(command_length);
|
||||
memcpy(sbuf+2, command, command_length);
|
||||
command_length += 2;
|
||||
if (upsdev) {
|
||||
/* Prepare the send buffer */
|
||||
sbuf[0] = PW_COMMAND_START_BYTE;
|
||||
sbuf[1] = (unsigned char)(command_length);
|
||||
memcpy(sbuf+2, command, command_length);
|
||||
command_length += 2;
|
||||
|
||||
/* Add checksum */
|
||||
sbuf[command_length] = calc_checksum(sbuf);
|
||||
command_length += 1;
|
||||
usb_set_descriptor(upsdev, USB_DT_STRING, 4, sbuf, command_length); /* FIXME: Ignore error */
|
||||
/* Add checksum */
|
||||
sbuf[command_length] = calc_checksum(sbuf);
|
||||
command_length += 1;
|
||||
usb_set_descriptor(upsdev, USB_DT_STRING, 4, sbuf, command_length); /* FIXME: Ignore error */
|
||||
}
|
||||
}
|
||||
|
||||
/* get the answer of a command from the ups. And check that the answer is for this command */
|
||||
|
@ -128,6 +134,9 @@ int get_answer(unsigned char *data, unsigned char command)
|
|||
unsigned char block_number, sequence, seq_num;
|
||||
struct timeval start_time, now;
|
||||
|
||||
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 */
|
||||
|
@ -287,10 +296,10 @@ int command_write_sequence(unsigned char *command, int command_length, unsigned
|
|||
{
|
||||
int bytes_read = 0;
|
||||
int retry = 0;
|
||||
|
||||
|
||||
while ((bytes_read < 1) && (retry < 5)) {
|
||||
send_write_command(command, command_length);
|
||||
bytes_read = get_answer(answer, command[0]);
|
||||
bytes_read = get_answer(answer, command[0]);
|
||||
retry ++;
|
||||
}
|
||||
|
||||
|
@ -322,12 +331,10 @@ void upsdrv_cleanup(void)
|
|||
|
||||
void upsdrv_reconnect(void)
|
||||
{
|
||||
|
||||
upslogx(LOG_WARNING, "RECONNECT USB DEVICE\n");
|
||||
nutusb_close(upsdev, "USB");
|
||||
upsdev = NULL;
|
||||
sleep(3);
|
||||
upsdrv_initups();
|
||||
upsdrv_initups();
|
||||
}
|
||||
|
||||
/* USB functions */
|
||||
|
@ -370,64 +377,72 @@ static usb_dev_handle *open_powerware_usb(void)
|
|||
|
||||
usb_dev_handle *nutusb_open(const char *port)
|
||||
{
|
||||
static int libusb_init = 0;
|
||||
int dev_claimed = 0;
|
||||
usb_dev_handle *dev_h = NULL;
|
||||
int retry;
|
||||
|
||||
if (!libusb_init)
|
||||
{
|
||||
/* Initialize Libusb */
|
||||
usb_init();
|
||||
libusb_init = 1;
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
}
|
||||
int retry, errout = 0;
|
||||
|
||||
for (retry = 0; dev_h == NULL && retry < 32; retry++)
|
||||
{
|
||||
struct timespec t = {5, 0};
|
||||
upsdebugx(1, "entering nutusb_open()");
|
||||
|
||||
/* Initialize Libusb */
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
|
||||
for (retry = 0; retry <= MAX_TRY ; retry++)
|
||||
{
|
||||
dev_h = open_powerware_usb();
|
||||
if (!dev_h) {
|
||||
upslogx(LOG_WARNING, "Can't open POWERWARE USB device, retrying ...");
|
||||
if (nanosleep(&t, NULL) < 0 && errno == EINTR)
|
||||
break;
|
||||
upsdebugx(1, "Can't open POWERWARE USB device");
|
||||
errout = 1;
|
||||
}
|
||||
else {
|
||||
upsdebugx(1, "device %s opened successfully", usb_device(dev_h)->filename);
|
||||
errout = 0;
|
||||
|
||||
if (usb_claim_interface(dev_h, 0) < 0)
|
||||
{
|
||||
upsdebugx(1, "Can't claim POWERWARE USB interface: %s", usb_strerror());
|
||||
errout = 1;
|
||||
}
|
||||
else {
|
||||
dev_claimed = 1;
|
||||
errout = 0;
|
||||
}
|
||||
/* FIXME: the above part of the opening can go into common... up to here at least */
|
||||
|
||||
if (usb_clear_halt(dev_h, 0x81) < 0)
|
||||
{
|
||||
upsdebugx(1, "Can't reset POWERWARE USB endpoint: %s", usb_strerror());
|
||||
errout = 1;
|
||||
}
|
||||
else
|
||||
errout = 0;
|
||||
}
|
||||
|
||||
/* Test if we succeeded */
|
||||
if ( (dev_h != NULL) && dev_claimed && (errout == 0) )
|
||||
break;
|
||||
else {
|
||||
/* Clear errors, and try again */
|
||||
errout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dev_h)
|
||||
{
|
||||
upslogx(LOG_ERR, "Can't open POWERWARE USB device");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
if (!dev_h && !dev_claimed && retry == MAX_TRY)
|
||||
errout = 1;
|
||||
else
|
||||
upsdebugx(1, "device %s opened successfully", usb_device(dev_h)->filename);
|
||||
return dev_h;
|
||||
|
||||
if (usb_claim_interface(dev_h, 0) < 0)
|
||||
{
|
||||
upslogx(LOG_ERR, "Can't claim POWERWARE USB interface: %s", usb_strerror());
|
||||
goto errout;
|
||||
}
|
||||
else
|
||||
dev_claimed = 1;
|
||||
/* FIXME: this part of the opening can go into common... up to here at least */
|
||||
|
||||
if (usb_clear_halt(dev_h, 0x81) < 0)
|
||||
{
|
||||
upslogx(LOG_ERR, "Can't reset POWERWARE USB endpoint: %s", usb_strerror());
|
||||
goto errout;
|
||||
}
|
||||
return dev_h;
|
||||
|
||||
errout:
|
||||
if (dev_h && dev_claimed)
|
||||
usb_release_interface(dev_h, 0);
|
||||
|
||||
if (dev_h)
|
||||
usb_close(dev_h);
|
||||
|
||||
nutusb_open_error(port);
|
||||
return 0;
|
||||
if (errout == 1)
|
||||
nutusb_open_error(port);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* FIXME: this part can go into common... */
|
||||
|
@ -463,14 +478,16 @@ void nutusb_comm_fail(const char *fmt, ...)
|
|||
|
||||
/* once it's past the limit, only log once every USB_ERR_LIMIT calls */
|
||||
if ((comm_failures > USB_ERR_LIMIT) &&
|
||||
((comm_failures % USB_ERR_LIMIT) != 0))
|
||||
((comm_failures % USB_ERR_LIMIT) != 0)) {
|
||||
/* Try reconnection */
|
||||
upsdrv_reconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
/* generic message if the caller hasn't elaborated */
|
||||
if (!fmt)
|
||||
{
|
||||
upslogx(LOG_WARNING, "Communications with UPS lost"
|
||||
" - check cabling");
|
||||
upslogx(LOG_WARNING, "Communications with UPS lost - check cabling");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1239,13 +1239,13 @@ int instcmd(const char *cmdname, const char *extra)
|
|||
/* set a variable */
|
||||
static int setvar(const char *varname, const char *val)
|
||||
{
|
||||
int i, r;
|
||||
int i;
|
||||
|
||||
if (!strcasecmp(varname, "input.sensitivity")) {
|
||||
for (i=0; i<asize(voltsens); i++) {
|
||||
if (!strcasecmp(val, voltsens[i])) {
|
||||
r = belkin_nut_write_int(REG_VOLTSENS, i);
|
||||
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
|
||||
belkin_nut_write_int(REG_VOLTSENS, i);
|
||||
return STAT_SET_HANDLED; /* Future: failure if result==-1 */
|
||||
}
|
||||
}
|
||||
return STAT_SET_HANDLED; /* Future: failure */
|
||||
|
@ -1261,14 +1261,14 @@ static int setvar(const char *varname, const char *val)
|
|||
} else {
|
||||
i=atoi(val);
|
||||
}
|
||||
r = belkin_nut_write_int(REG_ALARMSTATUS, i);
|
||||
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
|
||||
belkin_nut_write_int(REG_ALARMSTATUS, i);
|
||||
return STAT_SET_HANDLED; /* Future: failure if result==-1 */
|
||||
} else if (!strcasecmp(varname, "input.transfer.low")) {
|
||||
r = belkin_nut_write_int(REG_XFER_LO, atoi(val));
|
||||
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
|
||||
belkin_nut_write_int(REG_XFER_LO, atoi(val));
|
||||
return STAT_SET_HANDLED; /* Future: failure if result==-1 */
|
||||
} else if (!strcasecmp(varname, "input.transfer.high")) {
|
||||
r = belkin_nut_write_int(REG_XFER_HI, atoi(val));
|
||||
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
|
||||
belkin_nut_write_int(REG_XFER_HI, atoi(val));
|
||||
return STAT_SET_HANDLED; /* Future: failure if result==-1 */
|
||||
}
|
||||
|
||||
upslogx(LOG_NOTICE, "setvar: unknown var [%s]", varname);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* found online at "http://www.networkupstools.org/protocols/megatec.html".
|
||||
*
|
||||
* Copyright (C) 2003-2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
* Copyright (C) 2011 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
|
||||
|
@ -27,13 +28,14 @@
|
|||
#include "blazer.h"
|
||||
|
||||
#define DRIVER_NAME "Megatec/Q1 protocol USB driver"
|
||||
#define DRIVER_VERSION "0.03"
|
||||
#define DRIVER_VERSION "0.04"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
DRIVER_NAME,
|
||||
DRIVER_VERSION,
|
||||
"Arjen de Korte <adkorte-guest@alioth.debian.org>",
|
||||
"Arjen de Korte <adkorte-guest@alioth.debian.org>\n" \
|
||||
"Arnaud Quette <arnaud.quette@free.fr>",
|
||||
DRV_BETA,
|
||||
{ NULL }
|
||||
};
|
||||
|
@ -43,6 +45,7 @@ static usb_dev_handle *udev = NULL;
|
|||
static USBDevice_t usbdevice;
|
||||
static USBDeviceMatcher_t *reopen_matcher = NULL;
|
||||
static USBDeviceMatcher_t *regex_matcher = NULL;
|
||||
static int langid_fix = -1;
|
||||
|
||||
static int (*subdriver_command)(const char *cmd, char *buf, size_t buflen) = NULL;
|
||||
|
||||
|
@ -246,13 +249,48 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen)
|
|||
for (retry = 0; retry < 10; retry++) {
|
||||
int ret;
|
||||
|
||||
ret = usb_get_string_simple(udev, command[i].index, buf, buflen);
|
||||
if (langid_fix != -1) {
|
||||
/* Apply langid_fix value */
|
||||
ret = usb_get_string(udev, command[i].index, langid_fix, buf, buflen);
|
||||
}
|
||||
else {
|
||||
ret = usb_get_string_simple(udev, command[i].index, buf, buflen);
|
||||
}
|
||||
|
||||
if (ret <= 0) {
|
||||
upsdebugx(3, "read: %s", ret ? usb_strerror() : "timeout");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* this may serve in the future */
|
||||
upsdebugx(1, "received %d (%d)", ret, buf[0]);
|
||||
|
||||
if (langid_fix != -1) {
|
||||
/* Limit this check, at least for now */
|
||||
/* Invalid receive size - message corrupted */
|
||||
if (ret != buf[0])
|
||||
{
|
||||
upsdebugx(1, "size mismatch: %d / %d", ret, buf[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Simple unicode -> ASCII inplace conversion
|
||||
* FIXME: this code is at least shared with mge-shut/libshut
|
||||
* Create a common function? */
|
||||
unsigned int di, si, size = buf[0];
|
||||
for (di = 0, si = 2; si < size; si += 2) {
|
||||
if (di >= (buflen - 1))
|
||||
break;
|
||||
|
||||
if (buf[si + 1]) /* high byte */
|
||||
buf[di++] = '?';
|
||||
else
|
||||
buf[di++] = buf[si];
|
||||
}
|
||||
buf[di] = 0;
|
||||
ret = di;
|
||||
}
|
||||
|
||||
/* "UPS No Ack" has a special meaning */
|
||||
if (!strcasecmp(buf, "UPS No Ack")) {
|
||||
upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf);
|
||||
|
@ -305,8 +343,8 @@ static void *phoenix_subdriver(void)
|
|||
|
||||
static usb_device_id_t blazer_usb_id[] = {
|
||||
{ USB_DEVICE(0x05b8, 0x0000), &cypress_subdriver }, /* Agiler UPS */
|
||||
{ 0x0001, 0x0000, &krauler_subdriver }, /* Krauler UP-M500VA */
|
||||
{ 0xffff, 0x0000, &krauler_subdriver }, /* Ablerex 625L USB */
|
||||
{ USB_DEVICE(0x0001, 0x0000), &krauler_subdriver }, /* Krauler UP-M500VA */
|
||||
{ USB_DEVICE(0xffff, 0x0000), &krauler_subdriver }, /* Ablerex 625L USB */
|
||||
{ USB_DEVICE(0x0665, 0x5161), &cypress_subdriver }, /* Belkin F6C1200-UNV */
|
||||
{ USB_DEVICE(0x06da, 0x0003), &ippon_subdriver }, /* Mustek Powermust */
|
||||
{ USB_DEVICE(0x0f03, 0x0001), &cypress_subdriver }, /* Unitek Alpha 1200Sx */
|
||||
|
@ -449,6 +487,8 @@ void upsdrv_makevartable(void)
|
|||
|
||||
addvar(VAR_VALUE, "bus", "Regular expression to match USB bus name");
|
||||
|
||||
addvar(VAR_VALUE, "langid_fix", "Apply the language ID workaround to the krauler subdriver (0x409 or 0x4095)");
|
||||
|
||||
blazer_makevartable();
|
||||
}
|
||||
|
||||
|
@ -467,7 +507,8 @@ void upsdrv_initups(void)
|
|||
{ NULL }
|
||||
};
|
||||
|
||||
int ret;
|
||||
int ret, langid;
|
||||
char tbuf[255]; /* Some devices choke on size > 255 */
|
||||
char *regex_array[6];
|
||||
|
||||
char *subdrv = getval("subdriver");
|
||||
|
@ -479,6 +520,17 @@ void upsdrv_initups(void)
|
|||
regex_array[4] = getval("serial");
|
||||
regex_array[5] = getval("bus");
|
||||
|
||||
/* check for language ID workaround (#1) */
|
||||
if (getval("langid_fix")) {
|
||||
/* skip "0x" prefix and set back to hexadecimal */
|
||||
if (sscanf(getval("langid_fix") + 2, "%x", &langid_fix) != 1) {
|
||||
upslogx(LOG_NOTICE, "Error enabling language ID workaround");
|
||||
}
|
||||
else {
|
||||
upsdebugx(2, "language ID workaround enabled (using '0x%x')", langid_fix);
|
||||
}
|
||||
}
|
||||
|
||||
/* pick up the subdriver name if set explicitly */
|
||||
if (subdrv) {
|
||||
int i;
|
||||
|
@ -542,6 +594,23 @@ void upsdrv_initups(void)
|
|||
|
||||
dstate_setinfo("ups.vendorid", "%04x", usbdevice.VendorID);
|
||||
dstate_setinfo("ups.productid", "%04x", usbdevice.ProductID);
|
||||
|
||||
/* check for language ID workaround (#2) */
|
||||
if (langid_fix != -1) {
|
||||
/* Future improvement:
|
||||
* Asking for the zero'th index is special - it returns a string
|
||||
* descriptor that contains all the language IDs supported by the
|
||||
* device. Typically there aren't many - often only one. The
|
||||
* language IDs are 16 bit numbers, and they start at the third byte
|
||||
* in the descriptor. See USB 2.0 specification, section 9.6.7, for
|
||||
* more information on this.
|
||||
* This should allow automatic application of the workaround */
|
||||
ret = usb_get_string(udev, 0, 0, tbuf, sizeof(tbuf));
|
||||
if (ret >= 4) {
|
||||
langid = tbuf[2] | (tbuf[3] << 8);
|
||||
upsdebugx(1, "First supported language ID: 0x%x (please report to the NUT maintainer!)", langid);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
blazer_initups();
|
||||
}
|
||||
|
|
81
drivers/cyberpower-mib.c
Normal file
81
drivers/cyberpower-mib.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* cyberpower-mib.c - data to monitor Cyberpower RMCARD
|
||||
*
|
||||
* Copyright (C) 2010 - Eric Schultz <paradxum@mentaljynx.com>
|
||||
*
|
||||
* derived (i.e. basically copied and modified) of bestpower by:
|
||||
* Copyright (C) 2010 - Arnaud Quette <arnaud.quette@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cyberpower-mib.h"
|
||||
|
||||
#define CYBERPOWER_MIB_VERSION "0.1"
|
||||
#define CYBERPOWER_OID_MODEL_NAME ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0"
|
||||
|
||||
#define CYBERPOWER_SYSOID ".1.3.6.1.4.1.3808"
|
||||
|
||||
static info_lkp_t cyberpower_power_status[] = {
|
||||
{ 2, "OL" },
|
||||
{ 3, "OB" },
|
||||
{ 4, "OL" },
|
||||
{ 5, "OL" },
|
||||
{ 7, "OL" },
|
||||
{ 1, "NULL" },
|
||||
{ 6, "NULL" },
|
||||
{ 0, "NULL" }
|
||||
} ;
|
||||
|
||||
/* Snmp2NUT lookup table for CyberPower MIB */
|
||||
static snmp_info_t cyberpower_mib[] = {
|
||||
/* Device page */
|
||||
{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "ups",
|
||||
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
|
||||
|
||||
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "CYBERPOWER",
|
||||
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
|
||||
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, CYBERPOWER_OID_MODEL_NAME,
|
||||
"CyberPower", SU_FLAG_STATIC, NULL, NULL },
|
||||
|
||||
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.1.2.3.0",
|
||||
"", SU_FLAG_STATIC, NULL },
|
||||
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.1.2.1.0",
|
||||
"", SU_FLAG_STATIC, NULL },
|
||||
{ "ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.1.2.2.0", "",
|
||||
0, NULL },
|
||||
|
||||
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.4.1.1.0", "",
|
||||
0 /*SU_STATUS_PWR*/, &cyberpower_power_status[0] },
|
||||
|
||||
/* Battery runtime is expressed in minutes */
|
||||
{ "battery.runtime", 0, 60.0, ".1.3.6.1.4.1.3808.1.1.1.2.2.4.0", "",
|
||||
0, NULL },
|
||||
/* The elapsed time in seconds since the
|
||||
* UPS has switched to battery power */
|
||||
{ "battery.runtime.elapsed", 0, 1.0, ".1.3.6.1.4.1.3808.1.1.1.2.1.2.0", "",
|
||||
0, NULL },
|
||||
{ "battery.voltage", 0, 0.1, ".1.3.6.1.4.1.3808.1.1.1.2.2.2.0", "",
|
||||
0, NULL },
|
||||
{ "battery.current", 0, 0.1, ".1.3.6.1.4.1.3808.1.1.1.2.2.7.0", "",
|
||||
0, NULL },
|
||||
|
||||
/* end of structure. */
|
||||
{ NULL, 0, 0, NULL, NULL, 0, NULL, NULL }
|
||||
} ;
|
||||
|
||||
mib2nut_info_t cyberpower = { "cyberpower", CYBERPOWER_MIB_VERSION, "",
|
||||
CYBERPOWER_OID_MODEL_NAME, cyberpower_mib, CYBERPOWER_SYSOID };
|
9
drivers/cyberpower-mib.h
Normal file
9
drivers/cyberpower-mib.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef CYBERPOWER_MIB_H
|
||||
#define CYBERPOWER_MIB_H
|
||||
|
||||
#include "main.h"
|
||||
#include "snmp-ups.h"
|
||||
|
||||
extern mib2nut_info_t cyberpower;
|
||||
|
||||
#endif /* CYBERPOWER_MIB_H */
|
|
@ -201,6 +201,11 @@ static int instcmd(const char *cmdname, const char *extra)
|
|||
return STAT_INSTCMD_HANDLED;
|
||||
}
|
||||
*/
|
||||
/* FIXME: the below is only valid if (mode == MODE_DUMMY)
|
||||
* if (mode == MODE_REPEATER) => forward
|
||||
* if (mode == MODE_META) => ?
|
||||
*/
|
||||
|
||||
upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
|
||||
return STAT_INSTCMD_UNKNOWN;
|
||||
}
|
||||
|
@ -258,6 +263,10 @@ static int setvar(const char *varname, const char *val)
|
|||
|
||||
upsdebugx(2, "entering setvar(%s, %s)", varname, val);
|
||||
|
||||
/* FIXME: the below is only valid if (mode == MODE_DUMMY)
|
||||
* if (mode == MODE_REPEATER) => forward
|
||||
* if (mode == MODE_META) => ?
|
||||
*/
|
||||
if (!strncmp(varname, "ups.status", 10))
|
||||
{
|
||||
status_init();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "eaton-mib.h"
|
||||
|
||||
#define EATON_APHEL_MIB_VERSION "0.45"
|
||||
#define EATON_APHEL_MIB_VERSION "0.46"
|
||||
|
||||
/* APHEL-GENESIS-II-MIB (monitored ePDU)
|
||||
* *************************************
|
||||
|
@ -67,14 +67,14 @@ static snmp_info_t eaton_aphel_genesisII_mib[] = {
|
|||
|
||||
/* Outlet page */
|
||||
/* we can't use template since there is no counterpart to outlet.count */
|
||||
{ "outlet.1.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".1.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.2.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".2.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.3.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".3.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.4.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".4.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.5.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".5.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.6.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".6.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.7.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".7.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.8.current", 0, 0.001, APHEL1_OID_OUTLET_CURRENT ".8.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.1.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".1.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.2.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".2.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.3.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".3.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.4.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".4.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.5.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".5.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.6.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".6.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.7.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".7.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
{ "outlet.8.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".8.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
|
||||
|
||||
/* end of structure. */
|
||||
{ NULL, 0, 0, NULL, NULL, 0, NULL, NULL }
|
||||
|
@ -211,7 +211,7 @@ static snmp_info_t eaton_aphel_revelation_mib[] = {
|
|||
/* Eaton PDU-MIB - Marlin MIB
|
||||
* ************************** */
|
||||
|
||||
#define EATON_MARLIN_MIB_VERSION "0.05"
|
||||
#define EATON_MARLIN_MIB_VERSION "0.06"
|
||||
#define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7"
|
||||
#define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0"
|
||||
|
||||
|
@ -223,6 +223,14 @@ static info_lkp_t marlin_outlet_status_info[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* Ugly hack: having the matching OID present means that the outlet is
|
||||
* switchable. So, it should not require this value lookup */
|
||||
static info_lkp_t outlet_switchability_info[] = {
|
||||
{ -1, "yes" },
|
||||
{ 0, "yes" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
/* Snmp2NUT lookup table for Eaton Marlin MIB */
|
||||
static snmp_info_t eaton_marlin_mib[] = {
|
||||
/* Device page */
|
||||
|
@ -301,7 +309,6 @@ static snmp_info_t eaton_marlin_mib[] = {
|
|||
|
||||
/* outlet template definition
|
||||
* Indexes start from 1, ie outlet.1 => <OID>.1 */
|
||||
{ "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.0.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL, NULL },
|
||||
/* Note: the first definition is used to determine the base index (ie 0 or 1) */
|
||||
{ "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.3.0.%i", NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_OUTLET, NULL, NULL },
|
||||
{ "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.2.0.%i",
|
||||
|
@ -312,6 +319,8 @@ static snmp_info_t eaton_marlin_mib[] = {
|
|||
{ "outlet.%i.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.6.5.1.3.0.%i", NULL, SU_OUTLET, NULL, NULL },
|
||||
{ "outlet.%i.voltage", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.3.1.2.0.%i", NULL, SU_OUTLET, NULL, NULL },
|
||||
{ "outlet.%i.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.6.5.1.2.0.%i", NULL, SU_OUTLET, NULL, NULL },
|
||||
/* FIXME: handle non switchable units (only measurements), which do not expose this OID */
|
||||
{ "outlet.%i.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.0.%i", "no", SU_FLAG_STATIC | SU_FLAG_OK, &outlet_switchability_info[0], NULL },
|
||||
|
||||
/* TODO: handle statistics
|
||||
* outletWh.0.1
|
||||
|
|
|
@ -213,7 +213,6 @@ upsdrv_initinfo(void)
|
|||
void
|
||||
upsdrv_updateinfo(void)
|
||||
{
|
||||
char status[256];
|
||||
int x, flags;
|
||||
double utility, outvolt, battvolt, loadpct;
|
||||
|
||||
|
@ -292,7 +291,6 @@ upsdrv_updateinfo(void)
|
|||
|
||||
status_init();
|
||||
|
||||
status[0] = '\0';
|
||||
if (!(flags & 0x02))
|
||||
status_set("OFF");
|
||||
else if (flags & 0x01)
|
||||
|
|
|
@ -247,8 +247,7 @@ void sec_poll ( int pollflag ) {
|
|||
|
||||
void upsdrv_initinfo(void)
|
||||
{
|
||||
|
||||
int msglen, e, v;
|
||||
int msglen, v;
|
||||
char *a,*p,avail_list[300];
|
||||
|
||||
/* find out which variables/commands this UPS supports */
|
||||
|
@ -264,7 +263,6 @@ void upsdrv_initinfo(void)
|
|||
if (strlen(avail_list) == 0){
|
||||
fatalx(EXIT_FAILURE, "No available variables found!");}
|
||||
a = avail_list;
|
||||
e = 0;
|
||||
while ((p = strtok(a, ",")) != NULL) {
|
||||
a = NULL;
|
||||
v = atoi(p);
|
||||
|
|
|
@ -323,10 +323,10 @@ void upsdrv_shutdown(void)
|
|||
* work, else:*/
|
||||
/* fatalx(EXIT_FAILURE, "Shutdown only supported with the Generic Driver, type 6 and special cable"); */
|
||||
/*fatalx(EXIT_FAILURE, "shutdown not supported");*/
|
||||
int i, ret;
|
||||
int i;
|
||||
for(i=0;i<=5;i++)
|
||||
{
|
||||
ret = ser_send_char(upsfd, '#');
|
||||
ser_send_char(upsfd, '#');
|
||||
usleep(50000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -678,7 +678,8 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
|
|||
u_short Pos=0;
|
||||
u_char Retry=0;
|
||||
int recv;
|
||||
shut_data_t sdata;
|
||||
/* FIXME: use this
|
||||
* shut_data_t sdata; */
|
||||
|
||||
upsdebugx (4, "entering shut_packet_recv (%i)", datalen);
|
||||
|
||||
|
@ -687,7 +688,7 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
|
|||
/* if(serial_read (SHUT_TIMEOUT, &Start[0]) > 0) */
|
||||
if(ser_get_char(upsfd, &Start[0], SHUT_TIMEOUT/1000, 0) > 0)
|
||||
{
|
||||
sdata.shut_pkt.bType = Start[0];
|
||||
/* sdata.shut_pkt.bType = Start[0]; */
|
||||
if(Start[0]==SHUT_SYNC)
|
||||
{
|
||||
upsdebugx (4, "received SYNC token");
|
||||
|
@ -702,7 +703,7 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
|
|||
{
|
||||
upsdebug_hex(4, "Receive", Start, 2);
|
||||
Size=Start[1]&0x0F;
|
||||
sdata.shut_pkt.bLength = Size;
|
||||
/* sdata.shut_pkt.bLength = Size; */
|
||||
for(recv=0;recv<Size;recv++)
|
||||
{
|
||||
/* if(serial_read (SHUT_TIMEOUT, &Frame[recv]) < 1) */
|
||||
|
|
|
@ -92,14 +92,13 @@ long int get_long(unsigned char *buffer) { /* return a long integer reading 4 by
|
|||
d=buffer[3];
|
||||
result = (256*256*256*d) + (256*256*c) + (256*b) + a;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void send_zeros(void) { /* send 100 times the value 0x00.....it seems to be used for resetting */
|
||||
unsigned char buf[100]; /* the ups serial port */
|
||||
int i;
|
||||
|
||||
|
||||
memset(buf, '\0', sizeof(buf));
|
||||
i = ser_send_buf(upsfd, buf, sizeof(buf));
|
||||
ser_send_buf(upsfd, buf, sizeof(buf));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ static snmp_info_t mge_mib[] = {
|
|||
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".1.7.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
|
||||
{ "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".12.12.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
|
||||
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".5.14.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_lowbatt_info },
|
||||
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".5.16.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_lowbatt_info },
|
||||
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_onbatt_info },
|
||||
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".7.4.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_bypass_info },
|
||||
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".7.8.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_boost_info },
|
||||
|
|
|
@ -796,7 +796,6 @@ int shut_packet_recv (u_char *Buf, int datalen)
|
|||
u_short Pos=0;
|
||||
u_char Retry=0;
|
||||
int recv;
|
||||
shut_data_t sdata;
|
||||
|
||||
upsdebugx (4, "entering shut_packet_recv (%i)", datalen);
|
||||
|
||||
|
@ -804,7 +803,6 @@ int shut_packet_recv (u_char *Buf, int datalen)
|
|||
{
|
||||
if(serial_read (DEFAULT_TIMEOUT, &Start[0]) >= 0)
|
||||
{
|
||||
sdata.shut_pkt.bType = Start[0];
|
||||
if(Start[0]==SHUT_SYNC)
|
||||
{
|
||||
upsdebugx (4, "received SYNC token");
|
||||
|
@ -819,7 +817,6 @@ int shut_packet_recv (u_char *Buf, int datalen)
|
|||
{
|
||||
upsdebug_hex(3, "Receive", Start, 2);
|
||||
Size=Start[1]&0x0F;
|
||||
sdata.shut_pkt.bLength = Size;
|
||||
for(recv=0;recv<Size;recv++)
|
||||
if(serial_read (DEFAULT_TIMEOUT, &Frame[recv]) < 0)
|
||||
break;
|
||||
|
|
|
@ -189,24 +189,23 @@ int CheckErrCode(unsigned char * Buff)
|
|||
|
||||
void SendCmdToSerial(unsigned char *Buff, int Len)
|
||||
{
|
||||
int i, ret ;
|
||||
unsigned char Tmp[20], Xor ;
|
||||
int i;
|
||||
unsigned char Tmp[20], Xor ;
|
||||
|
||||
Tmp[0] = STX_CHAR ;
|
||||
Xor = Tmp[1] = (unsigned char) (Len & 0x1f) ;
|
||||
for (i=0 ; i < Tmp[1] ; i++)
|
||||
{
|
||||
Tmp[i+2] = Buff[i] ;
|
||||
Xor ^= Buff[i] ;
|
||||
}
|
||||
Tmp[Len+2] = Xor ;
|
||||
Tmp[0] = STX_CHAR ;
|
||||
Xor = Tmp[1] = (unsigned char) (Len & 0x1f) ;
|
||||
for (i=0 ; i < Tmp[1] ; i++)
|
||||
{
|
||||
Tmp[i+2] = Buff[i] ;
|
||||
Xor ^= Buff[i] ;
|
||||
}
|
||||
Tmp[Len+2] = Xor ;
|
||||
|
||||
upsdebug_hex(4, "->UPS", Tmp, Len+3) ;
|
||||
|
||||
/* flush serial port */
|
||||
ret = ser_flush_in(upsfd, "", 0) ; /* empty input buffer */
|
||||
|
||||
ret = ser_send_buf(upsfd, Tmp, Len+3) ; /* send data to the UPS */
|
||||
ser_flush_in(upsfd, "", 0) ; /* empty input buffer */
|
||||
ser_send_buf(upsfd, Tmp, Len+3) ; /* send data to the UPS */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef NUT_IPMI_H
|
||||
#define NUT_IPMI_H
|
||||
|
||||
typedef enum {
|
||||
PSU_STATUS_UNKNOWN = 1,
|
||||
PSU_PRESENT, /* = status OL */
|
||||
|
@ -54,4 +57,7 @@ typedef struct IPMIDevice_s {
|
|||
int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev);
|
||||
void nut_ipmi_close(void);
|
||||
int nut_ipmi_monitoring_init();
|
||||
int ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev);
|
||||
int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev);
|
||||
|
||||
#endif /* NUT_IPMI_H */
|
||||
|
||||
|
|
|
@ -21,11 +21,27 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
TODO:
|
||||
* add power control support (ipmipower): seems OOB only!
|
||||
-n, --on Power on the target hosts.
|
||||
-f, --off Power off the target hosts.
|
||||
-c, --cycle Power cycle the target hosts.
|
||||
-r, --reset Reset the target hosts.
|
||||
-s, --stat Get power status of the target hosts.
|
||||
--pulse Send power diagnostic interrupt to target hosts.
|
||||
--soft Initiate a soft-shutdown of the OS via ACPI.
|
||||
--on-if-off Issue a power on command instead of a power cycle
|
||||
or hard reset command if the remote machine's
|
||||
power is currently off.
|
||||
--wait-until-off Regularly query the remote BMC and return only
|
||||
after the machine has powered off.
|
||||
--wait-until-on Regularly query the remote BMC and return only
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "timehead.h"
|
||||
#include <freeipmi/freeipmi.h>
|
||||
#include <ipmi_monitoring.h>
|
||||
#include <ipmi_monitoring_bitmasks.h>
|
||||
|
@ -711,6 +727,7 @@ int nut_ipmi_monitoring_init()
|
|||
return -1;
|
||||
}
|
||||
|
||||
#if HAVE_FREEIPMI_MONITORING
|
||||
/* FIXME: replace "/tmp" by a proper place, using mkdtemp() or similar */
|
||||
if (ipmi_monitoring_ctx_sdr_cache_directory (mon_ctx, "/tmp") < 0) {
|
||||
upsdebugx (1, "ipmi_monitoring_ctx_sdr_cache_directory() error: %s",
|
||||
|
@ -723,16 +740,20 @@ int nut_ipmi_monitoring_init()
|
|||
ipmi_monitoring_ctx_errormsg (mon_ctx));
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_MONITORING */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
#if HAVE_FREEIPMI_MONITORING
|
||||
/* It seems we don't need more! */
|
||||
unsigned int sensor_reading_flags = IPMI_MONITORING_SENSOR_READING_FLAGS_IGNORE_NON_INTERPRETABLE_SENSORS;
|
||||
int sensor_count, i, str_count;
|
||||
int psu_status = PSU_STATUS_UNKNOWN;
|
||||
int retval = 0;
|
||||
|
||||
if (mon_ctx == NULL) {
|
||||
upsdebugx (1, "Monitoring context not initialized!");
|
||||
|
@ -930,6 +951,7 @@ int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev)
|
|||
|
||||
status_commit();
|
||||
}
|
||||
#endif /* HAVE_FREEIPMI_MONITORING */
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "powercom-hid.h"
|
||||
#include "usb-common.h"
|
||||
|
||||
#define POWERCOM_HID_VERSION "PowerCOM HID 0.2"
|
||||
#define POWERCOM_HID_VERSION "PowerCOM HID 0.3"
|
||||
/* FIXME: experimental flag to be put in upsdrv_info */
|
||||
|
||||
/* PowerCOM */
|
||||
|
@ -43,6 +43,8 @@ static usb_device_id_t powercom_usb_device_table[] = {
|
|||
{ USB_DEVICE(POWERCOM_VENDORID, 0x00a5), NULL },
|
||||
/* PowerCOM BNT - Black Knight Pro */
|
||||
{ USB_DEVICE(POWERCOM_VENDORID, 0x00a6), NULL },
|
||||
/* PowerCOM BNT-xxxAP */
|
||||
{ USB_DEVICE(POWERCOM_VENDORID, 0x0004), NULL },
|
||||
|
||||
/* Terminating entry */
|
||||
{ -1, -1, NULL }
|
||||
|
|
|
@ -477,55 +477,48 @@ static int
|
|||
send_command( int cmd )
|
||||
{
|
||||
|
||||
int i, chk, checksum=0, iend=18, sizes, ret, kount; /*, j, uc; */
|
||||
unsigned char ch, psend[19];
|
||||
sizes = 19;
|
||||
checksum = 0;
|
||||
int i, chk, checksum = 0, iend = 18, sizes = 19, ret, kount; /*, j, uc; */
|
||||
unsigned char ch, psend[sizes];
|
||||
|
||||
/* mounting buffer to send */
|
||||
|
||||
for(i = 0; i < iend; i++ )
|
||||
{
|
||||
if ( i == 0 )
|
||||
chk = 0x01;
|
||||
else
|
||||
for(i = 0; i < iend; i++ )
|
||||
{
|
||||
if( i == 1)
|
||||
chk = cmd;
|
||||
else
|
||||
chk = 0x00; /* 0x20; */
|
||||
if ( i == 0 )
|
||||
chk = 0x01;
|
||||
else
|
||||
{
|
||||
if( i == 1)
|
||||
chk = cmd;
|
||||
else
|
||||
chk = 0x00; /* 0x20; */
|
||||
}
|
||||
|
||||
ch = chk;
|
||||
psend[i] = ch; /* psend[0 - 17] */
|
||||
if( i > 0 ) /* psend[0] not computed */
|
||||
checksum = checksum + chk;
|
||||
}
|
||||
|
||||
ch = chk;
|
||||
psend[i] = ch; /* psend[0 - 17] */
|
||||
if( i > 0 ) /* psend[0] not computed */
|
||||
checksum = checksum + chk;
|
||||
}
|
||||
ch = checksum;
|
||||
ch = (~( ch) ); /* not ch */
|
||||
psend[iend] = ch;
|
||||
|
||||
ch = checksum;
|
||||
ch = (~( ch) ); /* not ch */
|
||||
psend[iend] = ch;
|
||||
|
||||
/* send five times the command */
|
||||
kount = 0;
|
||||
while ( kount < 5 )
|
||||
{
|
||||
/* ret = ser_send_buf_pace(upsfd, UPSDELAY, psend, sizes ); */ /* optional delay */
|
||||
|
||||
for(i=0; i < 19; i++)
|
||||
/* send five times the command */
|
||||
kount = 0;
|
||||
while ( kount < 5 )
|
||||
{
|
||||
ret = ser_send_char( upsfd, psend[i] );
|
||||
/* usleep ( UPSDELAY ); sending without delay */
|
||||
/* ret = ser_send_buf_pace(upsfd, UPSDELAY, psend, sizes ); */ /* optional delay */
|
||||
|
||||
for(i = 0 ; i < sizes ; i++)
|
||||
{
|
||||
ret = ser_send_char( upsfd, psend[i] );
|
||||
/* usleep ( UPSDELAY ); sending without delay */
|
||||
}
|
||||
usleep( UPSDELAY ); /* delay between sent command */
|
||||
kount++;
|
||||
}
|
||||
|
||||
usleep( UPSDELAY ); /* delay between sent command */
|
||||
|
||||
kount++;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void sendshut( void )
|
||||
|
@ -645,17 +638,6 @@ static void getupdateinfo(void)
|
|||
unsigned char temp[256];
|
||||
int tam;
|
||||
|
||||
int hours, mins;
|
||||
|
||||
/* time update */
|
||||
time_t *tmt;
|
||||
struct tm *now;
|
||||
tmt = ( time_t * ) malloc( sizeof( time_t ) );
|
||||
time( tmt );
|
||||
now = localtime( tmt );
|
||||
hours = now->tm_hour;
|
||||
mins = now->tm_min;
|
||||
|
||||
temp[0] = 0; /* flush temp buffer */
|
||||
tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "baytech-mib.h"
|
||||
#include "compaq-mib.h"
|
||||
#include "bestpower-mib.h"
|
||||
#include "cyberpower-mib.h"
|
||||
#include "ietf-mib.h"
|
||||
|
||||
static mib2nut_info_t *mib2nut[] = {
|
||||
|
@ -58,6 +59,7 @@ static mib2nut_info_t *mib2nut[] = {
|
|||
&baytech,
|
||||
&compaq,
|
||||
&bestpower,
|
||||
&cyberpower,
|
||||
/*
|
||||
* Prepend vendor specific MIB mappings before IETF, so that
|
||||
* if a device supports both IETF and vendor specific MIB,
|
||||
|
@ -80,7 +82,7 @@ const char *mibvers;
|
|||
static void disable_transfer_oids(void);
|
||||
|
||||
#define DRIVER_NAME "Generic SNMP UPS driver"
|
||||
#define DRIVER_VERSION "0.56"
|
||||
#define DRIVER_VERSION "0.58"
|
||||
|
||||
/* driver description structure */
|
||||
upsdrv_info_t upsdrv_info = {
|
||||
|
@ -982,20 +984,12 @@ int base_snmp_outlet_index(const char *OID_template)
|
|||
if (outlet_index_base == -1)
|
||||
{
|
||||
/* not initialised yet */
|
||||
/* Workaround for Eaton Marlin, while waiting for a FW fix and
|
||||
* a driver rewrite (advanced hooks) */
|
||||
if ((mibname != NULL) && (!strncmp(mibname, "eaton_epdu", 11)))
|
||||
{
|
||||
upsdebugx(3, "Appying Eaton Marlin workaround");
|
||||
outlet_index_base = base_index = 1;
|
||||
} else {
|
||||
for (base_index = 0 ; base_index < 2 ; base_index++) {
|
||||
sprintf(test_OID, OID_template, base_index);
|
||||
if (nut_snmp_get(test_OID) != NULL)
|
||||
break;
|
||||
}
|
||||
outlet_index_base = base_index;
|
||||
for (base_index = 0 ; base_index < 2 ; base_index++) {
|
||||
sprintf(test_OID, OID_template, base_index);
|
||||
if (nut_snmp_get(test_OID) != NULL)
|
||||
break;
|
||||
}
|
||||
outlet_index_base = base_index;
|
||||
}
|
||||
upsdebugx(3, "base_snmp_outlet_index: %i", outlet_index_base);
|
||||
return base_index;
|
||||
|
@ -1218,6 +1212,7 @@ bool_t snmp_ups_walk(int mode)
|
|||
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
@ -320,7 +320,6 @@ static void confups( void )
|
|||
{
|
||||
|
||||
int i, chks = 0;
|
||||
unsigned char tst;
|
||||
|
||||
ConfigPack[0] = 0xCF;
|
||||
ConfigPack[1] = ihour;
|
||||
|
@ -339,8 +338,6 @@ static void confups( void )
|
|||
/* MSB zero */
|
||||
ConfigPack[10] = ConfigPack[10] & (~(0x80));
|
||||
|
||||
tst = ConfigPack[10];
|
||||
|
||||
for(i=0; i < 11; i++)
|
||||
chks = chks + ConfigPack[i];
|
||||
|
||||
|
@ -355,9 +352,8 @@ static void confups( void )
|
|||
static void prnInfo( void )
|
||||
{
|
||||
|
||||
int iw, sunday=0, monday=0, tuesday=0, wednesday=0, thursday=0, friday=0, saturday=0;
|
||||
int sunday=0, monday=0, tuesday=0, wednesday=0, thursday=0, friday=0, saturday=0;
|
||||
unsigned char dweek;
|
||||
iw = weekn;
|
||||
|
||||
printf( UPS_DATE, Year, Month, Day );
|
||||
printf( SYS_DATE, anon, mesn, dian, seman );
|
||||
|
|
|
@ -71,10 +71,7 @@ void USBFreeExactMatcher(USBDeviceMatcher_t *matcher);
|
|||
void USBFreeRegexMatcher(USBDeviceMatcher_t *matcher);
|
||||
|
||||
/* dummy USB function and macro, inspired from the Linux kernel
|
||||
* this allows USB information extraction
|
||||
* CAUTION: only use with *valid* device identifiers, Ie the following is not
|
||||
* valid (from blazer_usb, krauler subdriver): 0x0001:0x0000
|
||||
*/
|
||||
* this allows USB information extraction */
|
||||
#define USB_DEVICE(vendorID, productID) vendorID, productID
|
||||
|
||||
typedef struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue