Imported Upstream version 2.6.4

This commit is contained in:
Arnaud Quette 2012-06-01 15:55:19 +02:00
parent fad6ced6f6
commit fefe62b2bd
257 changed files with 6020 additions and 1394 deletions

View file

@ -512,6 +512,7 @@ MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NM = @NM@
NMEDIT = @NMEDIT@
NUT_NETVERSION = @NUT_NETVERSION@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_NAME = @OS_NAME@
@ -525,6 +526,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PIDPATH = @PIDPATH@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
@ -532,6 +534,7 @@ PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
SBINDIR = @SBINDIR@
SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@

View file

@ -31,8 +31,15 @@
*
* examples found on the Net and other sources:
* 'enterprises.apc.products.system.smartUPS.smartUPS700'
* - from fence agents
* '.1.3.6.1.4.1.318.1.3.4.5': ApcRPDU,
* '.1.3.6.1.4.1.318.1.3.4.4': ApcMSP
* - from Bill Seligman
* .1.3.6.1.4.1.318.1.3.2.11
* .1.3.6.1.4.1.318.1.3.2.12
* .1.3.6.1.4.1.318.1.3.27
* .1.3.6.1.4.1.318.1.3.2.7
* .1.3.6.1.4.1.318.1.3.2.8
*/
/* TODO: find the right sysOID for this MIB

View file

@ -45,6 +45,81 @@ upsdrv_info_t upsdrv_info = {
static int ups_status = 0;
/*
* Aix compatible names
*/
#if defined(VWERSE) && !defined(VWERASE)
#define VWERASE VWERSE
#endif /* VWERSE && !VWERASE */
#if defined(VDISCRD) && !defined(VDISCARD)
#define VDISCARD VDISCRD
#endif /* VDISCRD && !VDISCARD */
#ifndef CTRL
#define CONTROL(x) (x&037)
#else
#define CONTROL CTRL
#endif
/*
* Allow use of system default characters if defined and reasonable.
* These are based on the BSD ttydefaults.h
*/
#ifndef CDISCARD
#define CDISCARD CONTROL('O')
#endif
#ifndef CDSUSP
#define CDSUSP CONTROL('Y')
#endif
#ifndef CEOF
#define CEOF CONTROL('D')
#endif
#ifndef CEOL
#define CEOL 0xff /* was 0 */
#endif
#ifndef CERASE
#define CERASE 0177
#endif
#ifndef CINTR
#define CINTR CONTROL('C')
#endif
#ifndef CKILL
#define CKILL CONTROL('U') /* was '@' */
#endif
#ifndef CLNEXT
#define CLNEXT CONTROL('V')
#endif
#ifndef CMIN
#define CMIN CEOF
#endif
#ifndef CQUIT
#define CQUIT CONTROL('\\')
#endif
#ifndef CRPRNT
#define CRPRNT CONTROL('R')
#endif
#ifndef CREPRINT
#define CREPRINT CRPRNT
#endif
#ifndef CSTART
#define CSTART CONTROL('Q')
#endif
#ifndef CSTOP
#define CSTOP CONTROL('S')
#endif
#ifndef CSUSP
#define CSUSP CONTROL('Z')
#endif
#ifndef CTIME
#define CTIME CEOL
#endif
#ifndef CWERASE
#define CWERASE CONTROL('W')
#endif
/* some forwards */
static int sdcmd_S(const void *);
@ -188,7 +263,10 @@ static void apc_ser_set(void)
tio.c_cflag |= (CS8 | CLOCAL | CREAD);
tio.c_lflag |= ICANON;
tio.c_lflag &= ~ISIG;
#ifdef NOKERNINFO
tio.c_lflag |= NOKERNINFO;
#endif
tio.c_lflag &= ~(ISIG | IEXTEN);
tio.c_iflag |= (IGNCR | IGNPAR);
tio.c_iflag &= ~(IXON | IXOFF);
@ -220,11 +298,92 @@ static void apc_ser_set(void)
if (tcsetattr(upsfd, TCSANOW, &tio))
fatal_with_errno(EXIT_FAILURE, "tcsetattr(%s)", device_path);
/* clear status flags so that they don't affect our binary compare */
#ifdef PENDIN
tio.c_lflag &= ~PENDIN;
#endif
#ifdef FLUSHO
tio.c_lflag &= ~FLUSHO;
#endif
memset(&tio_chk, 0, sizeof(tio_chk));
if (tcgetattr(upsfd, &tio_chk))
fatal_with_errno(EXIT_FAILURE, "tcgetattr(%s)", device_path);
if (memcmp(&tio_chk, &tio, sizeof(tio)))
fatalx(EXIT_FAILURE, "unable to set the required attributes (%s)", device_path);
/* clear status flags so that they don't affect our binary compare */
#ifdef PENDIN
tio_chk.c_lflag &= ~PENDIN;
#endif
#ifdef FLUSHO
tio_chk.c_lflag &= ~FLUSHO;
#endif
if (memcmp(&tio_chk, &tio, sizeof(tio))) {
struct cchar {
const char *name;
int sub;
u_char def;
};
const struct cchar cchars1[] = {
#ifdef VDISCARD
{ "discard", VDISCARD, CDISCARD },
#endif
#ifdef VDSUSP
{ "dsusp", VDSUSP, CDSUSP },
#endif
{ "eof", VEOF, CEOF },
{ "eol", VEOL, CEOL },
{ "eol2", VEOL2, CEOL },
{ "erase", VERASE, CERASE },
#ifdef VINTR
{ "intr", VINTR, CINTR },
#endif
{ "kill", VKILL, CKILL },
{ "lnext", VLNEXT, CLNEXT },
{ "min", VMIN, CMIN },
{ "quit", VQUIT, CQUIT },
#ifdef VREPRINT
{ "reprint", VREPRINT, CREPRINT },
#endif
{ "start", VSTART, CSTART },
#ifdef VSTATUS
{ "status", VSTATUS, CSTATUS },
#endif
{ "stop", VSTOP, CSTOP },
{ "susp", VSUSP, CSUSP },
{ "time", VTIME, CTIME },
{ "werase", VWERASE, CWERASE },
{ .name = NULL },
};
const struct cchar *cp;
struct termios *tp;
upslogx(LOG_NOTICE, "%s: device reports different attributes than what were set", device_path);
/*
* According to the manual the most common problem is
* mis-matched combinations of input and output baud rates. If
* the combination is not supported then neither are changed.
* This should not be a problem here since we set them both to
* the same extremely common rate of 2400.
*/
tp = &tio;
upsdebugx(1, "tcsetattr(): gfmt1:cflag=%x:iflag=%x:lflag=%x:oflag=%x:",
(unsigned int) tp->c_cflag, (unsigned int) tp->c_iflag,
(unsigned int) tp->c_lflag, (unsigned int) tp->c_oflag);
for (cp = cchars1; cp->name; ++cp)
upsdebugx(1, "\t%s=%x:", cp->name, tp->c_cc[cp->sub]);
upsdebugx(1, "\tispeed=%d:ospeed=%d", (int) cfgetispeed(tp), (int) cfgetospeed(tp));
tp = &tio_chk;
upsdebugx(1, "tcgetattr(): gfmt1:cflag=%x:iflag=%x:lflag=%x:oflag=%x:",
(unsigned int) tp->c_cflag, (unsigned int) tp->c_iflag,
(unsigned int) tp->c_lflag, (unsigned int) tp->c_oflag);
for (cp = cchars1; cp->name; ++cp)
upsdebugx(1, "\t%s=%x:", cp->name, tp->c_cc[cp->sub]);
upsdebugx(1, "\tispeed=%d:ospeed=%d", (int) cfgetispeed(tp), (int) cfgetospeed(tp));
}
cable = getval("cable");
if (cable && !strcasecmp(cable, ALT_CABLE_1)) {
@ -464,7 +623,8 @@ static int apc_write_long(const char *code)
return -1;
}
return ser_send_pace(upsfd, 50000, "%s", code + 1);
ret = ser_send_pace(upsfd, 50000, "%s", code + 1);
return ret < 0 ? ret : ret + 1;
}
static int apc_write_rep(unsigned char code)
@ -1747,9 +1907,9 @@ static int setvar_string(apc_vartab_t *vt, const char *val)
*ptr++ = '\015'; /* pad with CRs */
*ptr = 0;
ret = apc_write_long(ptr);
ret = apc_write_long(temp);
if ((size_t)ret != strlen(ptr)) {
if (ret != APC_STRLEN + 1) {
upslog_with_errno(LOG_ERR, "setvar_string: apc_write_long failed");
return STAT_SET_FAILED;
}

View file

@ -24,7 +24,7 @@
#define __apcsmart_h__
#define DRIVER_NAME "APC Smart protocol driver"
#define DRIVER_VERSION "3.0"
#define DRIVER_VERSION "3.04"
#define ALT_CABLE_1 "940-0095B"
@ -115,14 +115,14 @@
/* status bits */
#define APC_STAT_CAL 0x01 /* calibration */
#define APC_STAT_TRIM 0x02 /* SmartTrim */
#define APC_STAT_BOOST 0x04 /* SmartBoost */
#define APC_STAT_OL 0x08 /* on line */
#define APC_STAT_OB 0x10 /* on battery */
#define APC_STAT_OVER 0x20 /* overload */
#define APC_STAT_LB 0x40 /* low battery */
#define APC_STAT_RB 0x80 /* replace battery */
#define APC_STAT_CAL (1 << 0) /* calibration */
#define APC_STAT_TRIM (1 << 1) /* SmartTrim */
#define APC_STAT_BOOST (1 << 2) /* SmartBoost */
#define APC_STAT_OL (1 << 3) /* on line */
#define APC_STAT_OB (1 << 4) /* on battery */
#define APC_STAT_OVER (1 << 5) /* overload */
#define APC_STAT_LB (1 << 6) /* low battery */
#define APC_STAT_RB (1 << 7) /* replace battery */
/*
* serial protocol: special commands - initialization and such

View file

@ -6,8 +6,10 @@
* emes -at- geomer.de *
* All rights reserved.*
Copyright (C) 2004 Kjell Claesson <kjell.claesson-at-epost.tidanet.se>
and Tore Ørpetveit <tore-at-orpetveit.net>
Copyright (C)
2004 Kjell Claesson <kjell.claesson-at-epost.tidanet.se>
2004 Tore Ørpetveit <tore-at-orpetveit.net>
2011 - 2012 Arnaud Quette <ArnaudQuette@Eaton.com>
Thanks to Tore Ørpetveit <tore-at-orpetveit.net> that sent me the
manuals for bcm/xcp.
@ -124,7 +126,7 @@ TODO List:
#include "bcmxcp.h"
#define DRIVER_NAME "BCMXCP UPS driver"
#define DRIVER_VERSION "0.25"
#define DRIVER_VERSION "0.26"
#define MAX_NUT_NAME_LENGTH 128
#define NUT_OUTLET_POSITION 7
@ -157,6 +159,7 @@ static int init_outlet(unsigned char len);
static int instcmd(const char *cmdname, const char *extra);
static int setvar (const char *varname, const char *val);
static const char *nut_find_infoval(info_lkp_t *xcp2info, const double value);
const char *FreqTol[3] = {"+/-2%", "+/-5%", "+/-7"};
const char *ABMStatus[4] = {"Charging", "Discharging", "Floating", "Resting"};
@ -166,6 +169,32 @@ int nphases = 0;
int outlet_block_len = 0;
const char *cpu_name[5] = {"Cont:", "Inve:", "Rect:", "Netw:", "Disp:"};
/* Battery test results */
info_lkp_t batt_test_info[] = {
{ 0, "No test initiated", NULL },
{ 1, "In progress", NULL },
{ 2, "Done and passed", NULL },
{ 3, "Aborted", NULL },
{ 4, "Done and error", NULL },
{ 5, "Test scheduled", NULL },
/* Not sure about the meaning of the below ones! */
{ 6, NULL, NULL }, /* The string was present but it has now been removed */
{ 7, NULL, NULL }, /* The string was not installed at the last power up */
{ 0, NULL, NULL }
};
/* allocate storage for shared variables (extern in bcmxcp.h) */
BCMXCP_METER_MAP_ENTRY_t
bcmxcp_meter_map[BCMXCP_METER_MAP_MAX];
BCMXCP_ALARM_MAP_ENTRY_t
bcmxcp_alarm_map[BCMXCP_ALARM_MAP_MAX];
BCMXCP_STATUS_t
bcmxcp_status;
/* get_word function from nut driver metasys.c */
int get_word(const unsigned char *buffer) /* return an integer reading a word in the supplied buffer */
{
@ -583,7 +612,12 @@ void init_alarm_map()
bcmxcp_alarm_map[BCMXCP_ALARM_CHARGER_ON_COMMAND].alarm_desc = "CHARGER_ON_COMMAND";
bcmxcp_alarm_map[BCMXCP_ALARM_CHARGER_OFF_COMMAND].alarm_desc = "CHARGER_OFF_COMMAND";
bcmxcp_alarm_map[BCMXCP_ALARM_UPS_NORMAL].alarm_desc = "UPS_NORMAL";
bcmxcp_alarm_map[BCMXCP_ALARM_INVERTER_PHASE_ROTATION].alarm_desc = "INVERTER_PHASE_ROTATION";
bcmxcp_alarm_map[BCMXCP_ALARM_UPS_OFF].alarm_desc = "UPS_OFF";
bcmxcp_alarm_map[BCMXCP_ALARM_EXTERNAL_COMMUNICATION_FAILURE].alarm_desc = "EXTERNAL_COMMUNICATION_FAILURE";
bcmxcp_alarm_map[BCMXCP_ALARM_BATTERY_TEST_INPROGRESS].alarm_desc = "BATTERY_TEST_INPROGRESS";
bcmxcp_alarm_map[BCMXCP_ALARM_SYSTEM_TEST_INPROGRESS].alarm_desc = "SYSTEM_TEST_INPROGRESS";
bcmxcp_alarm_map[BCMXCP_ALARM_BATTERY_TEST_ABORTED].alarm_desc = "BATTERY_TEST_ABORTED";
}
@ -936,7 +970,7 @@ void init_config(void)
int voltage = 0, res, len;
char sValue[17];
res = command_read_sequence(PW_CONFIG_BLOC_REQ, answer);
res = command_read_sequence(PW_CONFIG_BLOCK_REQ, answer);
if (res <= 0)
fatal_with_errno(EXIT_FAILURE, "Could not communicate with the ups");
@ -1104,12 +1138,12 @@ void upsdrv_initinfo(void)
dstate_setinfo("ups.firmware", "%s", pTmp);
free(pTmp);
/* Increment index to point at end of CPU bytes. */
iIndex += len * 2;
}
free(pTmp);
/* Get rating in kVA, if present */
if ((iRating = answer[iIndex++]) > 0)
iRating *= 1000;
@ -1244,6 +1278,8 @@ void upsdrv_updateinfo(void)
char sValue[128];
int iIndex, res;
float output, max_output, fValue = 0.0f;
int batt_status = 0;
const char *nutvalue;
/* Get info from UPS */
res = command_read_sequence(PW_METER_BLOCK_REQ, answer);
@ -1332,6 +1368,14 @@ void upsdrv_updateinfo(void)
if (iIndex == BCMXCP_ALARM_BATTERY_LOW) {
bcmxcp_status.alarm_low_battery = 1;
}
if (iIndex == BCMXCP_ALARM_BATTERY_TEST_FAILED) {
bcmxcp_status.alarm_replace_battery = 1;
}
if (iIndex == BCMXCP_ALARM_BATTERY_NEEDS_SERVICE) {
bcmxcp_status.alarm_replace_battery = 1;
}
}
}
}
@ -1404,10 +1448,38 @@ void upsdrv_updateinfo(void)
status_set("OB");
if (bcmxcp_status.alarm_low_battery)
status_set("LB");
if (bcmxcp_status.alarm_replace_battery)
status_set("RB");
status_commit();
}
/* Get battery info from UPS, if exist */
res = command_read_sequence(PW_BATTERY_REQ, answer);
if (res <= 0)
{
upsdebugx(1, "Failed to read Battery Status from UPS");
}
else
{
/* Only parse the status (first byte)
* Powerware 5115 RM output:
* 02 00 78 1d 42 00 e0 17 42 1e 00 00 00 00 00 00 00 00 00 01 03
* Powerware 9130 output:
* 03 0a d7 25 42 0a d7 25 42 00 9a 19 6d 43 cd cc 4c 3e 01 00 01 03
*/
upsdebug_hex(2, "Battery Status", answer, res);
batt_status = answer[0];
if ((nutvalue = nut_find_infoval(batt_test_info, batt_status)) != NULL) {
dstate_setinfo("ups.test.result", "%s", nutvalue);
upsdebugx(2, "Battery Status = %s (%i)", nutvalue, batt_status);
}
else {
upsdebugx(1, "Failed to extract Battery Status from answer");
}
}
dstate_dataok();
}
@ -1428,7 +1500,7 @@ void upsdrv_shutdown(void)
it doesn't respond at first if possible */
send_write_command(AUTHOR, 4);
sleep(1); /* Need to. Have to wait at least 0,25 sec max 16 sec */
sleep(PW_SLEEP); /* Need to. Have to wait at least 0,25 sec max 16 sec */
cbuf[0] = PW_LOAD_OFF_RESTART;
cbuf[1] = (unsigned char)(bcmxcp_status.shutdowndelay & 0x00ff); /* "delay" sec delay for shutdown, */
@ -1493,12 +1565,12 @@ static int instcmd(const char *cmdname, const char *extra)
) {
send_write_command(AUTHOR, 4);
sleep(1); /* Need to. Have to wait at least 0,25 sec max 16 sec */
sleep(PW_SLEEP); /* Need to. Have to wait at least 0,25 sec max 16 sec */
/* Get the shutdown delay, if any */
snprintf(varname, sizeof(varname)-1, "outlet.%c.delay.shutdown", cmdname[7]);
if ((varvalue = dstate_getinfo(varname)) != NULL) {
sddelay = atoi(dstate_getinfo(varname));
sddelay = atoi(varvalue);
}
cbuf[0] = PW_LOAD_OFF_RESTART;
@ -1546,7 +1618,7 @@ static int instcmd(const char *cmdname, const char *extra)
if (!strcasecmp(cmdname, "shutdown.return")) {
send_write_command(AUTHOR, 4);
sleep(1); /* Need to. Have to wait at least 0,25 sec max 16 sec */
sleep(PW_SLEEP); /* Need to. Have to wait at least 0,25 sec max 16 sec */
cbuf[0] = PW_LOAD_OFF_RESTART;
cbuf[1] = (unsigned char)(bcmxcp_status.shutdowndelay & 0x00ff); /* "delay" sec delay for shutdown, */
@ -1590,7 +1662,7 @@ static int instcmd(const char *cmdname, const char *extra)
if (!strcasecmp(cmdname, "shutdown.stayoff")) {
send_write_command(AUTHOR, 4);
sleep(1); /* Need to. Have to wait at least 0,25 sec max 16 sec */
sleep(PW_SLEEP); /* Need to. Have to wait at least 0,25 sec max 16 sec */
res = command_read_sequence(PW_UPS_OFF, answer);
if (res <= 0) {
@ -1626,10 +1698,13 @@ static int instcmd(const char *cmdname, const char *extra)
}
/* Note: test result will be parsed from Battery status block,
* part of the update loop, and published into ups.test.result
*/
if (!strcasecmp(cmdname, "test.battery.start")) {
send_write_command(AUTHOR, 4);
sleep(1); /* Need to. Have to wait at least 0,25 sec max 16 sec */
sleep(PW_SLEEP); /* Need to. Have to wait at least 0,25 sec max 16 sec */
cbuf[0] = PW_INIT_BAT_TEST;
cbuf[1] = 0x0A; /* 10 sec start delay for test.*/
@ -1665,12 +1740,6 @@ static int instcmd(const char *cmdname, const char *extra)
break;
}
}
/* Get test info from UPS ?
Should we wait for 50 sec and get the
answer from the test.
Or return, as we may lose line power
and need to do a shutdown.*/
}
upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
@ -1715,8 +1784,7 @@ int setvar (const char *varname, const char *val)
}
send_write_command(AUTHOR, 4);
/* Need to. Have to wait at least 0.25 sec max 16 sec */
sleep (1);
sleep(PW_SLEEP); /* Need to. Have to wait at least 0,25 sec max 16 sec */
outlet_num = varname[NUT_OUTLET_POSITION] - '0';
if (outlet_num < 1 || outlet_num > 9) {
@ -1781,4 +1849,28 @@ int setvar (const char *varname, const char *val)
return STAT_SET_INVALID;
}
/*******************************
* Extracted from usbhid-ups.c *
*******************************/
/* find the NUT value matching that XCP Item value */
static const char *nut_find_infoval(info_lkp_t *xcp2info, const double value)
{
info_lkp_t *info_lkp;
/* if a conversion function is defined, use 'value' as argument for it */
if (xcp2info->fun != NULL) {
return xcp2info->fun(value);
}
/* use 'value' as an index for a lookup in an array */
for (info_lkp = xcp2info; info_lkp->nut_value != NULL; info_lkp++) {
if (info_lkp->xcp_value == (long)value) {
upsdebugx(5, "nut_find_infoval: found %s (value: %ld)", info_lkp->nut_value, (long)value);
return info_lkp->nut_value;
}
}
upsdebugx(3, "hu_find_infoval: no matching INFO_* value for this XCP value (%g)", value);
return NULL;
}

View file

@ -7,6 +7,11 @@
#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 */
#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
@ -20,8 +25,8 @@
#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_BLOC_REQ (unsigned char)0x36 /* Model serial#, ... length 1 */
#define PW_BAT_TEST_REQ (unsigned char)0x3B /* Charging, floating, ... 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 */
@ -342,10 +347,15 @@
#define BCMXCP_ALARM_CHARGER_ON_COMMAND 235
#define BCMXCP_ALARM_CHARGER_OFF_COMMAND 236
#define BCMXCP_ALARM_UPS_NORMAL 237
#define BCMXCP_ALARM_EXTERNAL_COMMUNICATION_FAILURE 238
#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 240 /* Max no of entries in BCM/XCP alarm map (adjusted upwards to nearest multi of 8 */
#define BCMXCP_ALARM_MAP_MAX 260 /* Max no of entries in BCM/XCP alarm map (adjusted upwards to nearest multi of 8 */
typedef struct { /* Entry in BCM/XCP - UPS - NUT mapping table */
const char *nut_entity; /* The NUT variable name */
@ -353,7 +363,7 @@ typedef struct { /* Entry in BCM/XCP - UPS - NUT mapping table */
unsigned int meter_block_index; /* The position of this meter in the UPS meter block */
} BCMXCP_METER_MAP_ENTRY_t;
BCMXCP_METER_MAP_ENTRY_t
extern BCMXCP_METER_MAP_ENTRY_t
bcmxcp_meter_map[BCMXCP_METER_MAP_MAX];
typedef struct { /* Entry in BCM/XCP - UPS mapping table */
@ -361,7 +371,7 @@ typedef struct { /* Entry in BCM/XCP - UPS mapping table */
const char *alarm_desc; /* Description of this alarm */
} BCMXCP_ALARM_MAP_ENTRY_t;
BCMXCP_ALARM_MAP_ENTRY_t
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 */
@ -370,13 +380,22 @@ typedef struct { /* A place to store status info and other data not for NUT *
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;
BCMXCP_STATUS_t
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 */
} info_lkp_t;
#endif /*_POWERWARE_H */

View file

@ -6,7 +6,7 @@
#define PW_MAX_BAUD 5
#define SUBDRIVER_NAME "RS-232 communication subdriver"
#define SUBDRIVER_VERSION "0.18"
#define SUBDRIVER_VERSION "0.19"
/* communication driver description structure */
upsdrv_info_t comm_upsdrv_info = {
@ -45,6 +45,8 @@ static void send_command(unsigned char *command, int command_length)
sbuf[command_length] = calc_checksum(sbuf);
command_length += 1;
upsdebug_hex (3, "send_command", sbuf, command_length);
while (retry++ < PW_MAX_TRY) {
if (retry == PW_MAX_TRY) {
@ -189,6 +191,7 @@ int get_answer(unsigned char *data, unsigned char command)
}
upsdebug_hex (5, "get_answer", data, end_length);
ser_comm_good();
return end_length;

View file

@ -12,7 +12,7 @@
#include <usb.h>
#define SUBDRIVER_NAME "USB communication subdriver"
#define SUBDRIVER_VERSION "0.19"
#define SUBDRIVER_VERSION "0.21"
/* communication driver description structure */
upsdrv_info_t comm_upsdrv_info = {
@ -104,6 +104,7 @@ void send_read_command(unsigned char command)
buf[1] = 0x01; /* data length */
buf[2] = command; /* command to send */
buf[3] = calc_checksum(buf); /* checksum */
upsdebug_hex (3, "send_read_command", buf, 4);
usb_set_descriptor(upsdev, USB_DT_STRING, 4, buf, 4); /* FIXME: Ignore error */
}
}
@ -122,6 +123,7 @@ void send_write_command(unsigned char *command, int command_length)
/* Add checksum */
sbuf[command_length] = calc_checksum(sbuf);
command_length += 1;
upsdebug_hex (3, "send_write_command", sbuf, command_length);
usb_set_descriptor(upsdev, USB_DT_STRING, 4, sbuf, command_length); /* FIXME: Ignore error */
}
}
@ -266,7 +268,8 @@ int get_answer(unsigned char *data, unsigned char command)
end_length += length;
my_buf += length + 5;
}
upsdebugx(4, "get_answer: exiting (len=%d)", end_length);
upsdebug_hex (5, "get_answer", data, end_length);
return end_length;
}
@ -299,6 +302,7 @@ int command_write_sequence(unsigned char *command, int command_length, unsigned
while ((bytes_read < 1) && (retry < 5)) {
send_write_command(command, command_length);
sleep(PW_SLEEP);
bytes_read = get_answer(answer, command[0]);
retry ++;
}
@ -388,7 +392,7 @@ usb_dev_handle *nutusb_open(const char *port)
usb_find_busses();
usb_find_devices();
for (retry = 0; retry <= MAX_TRY ; retry++)
for (retry = 0; retry < MAX_TRY ; retry++)
{
dev_h = open_powerware_usb();
if (!dev_h) {

View file

@ -1,8 +1,9 @@
/* belkin-hid.h - data to monitor Belkin UPS Systems USB/HID devices with NUT
/* belkin-hid.c - data to monitor Belkin UPS Systems USB/HID devices with NUT
*
* Copyright (C)
* 2003 - 2008 Arnaud Quette <arnaud.quette@free.fr>
* 2005 Peter Selinger <selinger@users.sourceforge.net>
* 2011 Charles Lepple <clepple+nut@gmail>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
*
@ -28,13 +29,18 @@
#include "belkin-hid.h"
#include "usb-common.h"
#define BELKIN_HID_VERSION "Belkin HID 0.12"
#define BELKIN_HID_VERSION "Belkin HID 0.15"
/* Belkin */
#define BELKIN_VENDORID 0x050d
/* Liebert */
#define LIEBERT_VENDORID 0x10af
/* Note that there are at least two Liebert firmware types which both report
* a VID:PID of 10af:0001. The newer ones tend not to have the Belkin broken
* Usage Pages (and therefore use standard HID PDC paths) but they have
* incorrect exponents for some fields.
*/
/* USB IDs device table */
static usb_device_id_t belkin_usb_device_table[] = {
@ -64,6 +70,123 @@ static usb_device_id_t belkin_usb_device_table[] = {
{ -1, -1, NULL }
};
static const char *liebert_online_fun(double value);
static const char *liebert_discharging_fun(double value);
static const char *liebert_charging_fun(double value);
static const char *liebert_lowbatt_fun(double value);
static const char *liebert_replacebatt_fun(double value);
static const char *liebert_shutdownimm_fun(double value);
static const char *liebert_config_voltage_fun(double value);
static const char *liebert_line_voltage_fun(double value);
static info_lkp_t liebert_online_info[] = {
{ 0, NULL, liebert_online_fun }
};
static info_lkp_t liebert_discharging_info[] = {
{ 0, NULL, liebert_discharging_fun }
};
static info_lkp_t liebert_charging_info[] = {
{ 0, NULL, liebert_charging_fun }
};
static info_lkp_t liebert_lowbatt_info[] = {
{ 0, NULL, liebert_lowbatt_fun }
};
static info_lkp_t liebert_replacebatt_info[] = {
{ 0, NULL, liebert_replacebatt_fun }
};
static info_lkp_t liebert_shutdownimm_info[] = {
{ 0, NULL, liebert_shutdownimm_fun }
};
static info_lkp_t liebert_config_voltage_info[] = {
{ 0, NULL, liebert_config_voltage_fun },
};
static info_lkp_t liebert_line_voltage_info[] = {
{ 0, NULL, liebert_line_voltage_fun },
};
static double liebert_config_voltage_mult = 1.0;
static double liebert_line_voltage_mult = 1.0;
static char liebert_conversion_buf[10];
/* These lookup functions also cover the 1e-7 factor which seems to be due to a
* broken report descriptor in certain Liebert units.
*/
static const char *liebert_online_fun(double value)
{
return value ? "online" : "!online";
}
static const char *liebert_discharging_fun(double value)
{
return value ? "dischrg" : "!dischrg";
}
static const char *liebert_charging_fun(double value)
{
return value ? "chrg" : "!chrg";
}
static const char *liebert_lowbatt_fun(double value)
{
return value ? "lowbatt" : "!lowbatt";
}
static const char *liebert_replacebatt_fun(double value)
{
return value ? "replacebatt" : "!replacebatt";
}
static const char *liebert_shutdownimm_fun(double value)
{
return value ? "shutdownimm" : "!shutdownimm";
}
/*! Apply heuristics to Liebert ConfigVoltage for correction of other values.
* Logic is weird since the ConfigVoltage item comes after InputVoltage and
* OutputVoltage.
*/
static const char *liebert_config_voltage_fun(double value)
{
if( value < 1 ) {
if( abs(value - 1e-7) < 1e-9 ) {
liebert_config_voltage_mult = 1e8;
liebert_line_voltage_mult = 1e7; /* stomp this in case input voltage was low */
upsdebugx(2, "ConfigVoltage = %g -> assuming correction factor = %g",
value, liebert_config_voltage_mult);
} else {
upslogx(LOG_NOTICE, "ConfigVoltage exponent looks wrong, but not correcting.");
}
}
snprintf(liebert_conversion_buf, sizeof(liebert_conversion_buf), "%.1f",
value * liebert_config_voltage_mult);
return liebert_conversion_buf;
}
static const char *liebert_line_voltage_fun(double value)
{
if( value < 1 ) {
if( abs(value - 1e-7) < 1e-9 ) {
liebert_line_voltage_mult = 1e7;
upsdebugx(2, "Input/OutputVoltage = %g -> assuming correction factor = %g",
value, liebert_line_voltage_mult);
} else {
upslogx(LOG_NOTICE, "LineVoltage exponent looks wrong, but not correcting.");
}
}
snprintf(liebert_conversion_buf, sizeof(liebert_conversion_buf), "%.1f",
value * liebert_line_voltage_mult);
return liebert_conversion_buf;
}
/* some conversion functions specific to Belkin */
/* returns statically allocated string - must not use it again before
@ -338,12 +461,27 @@ static hid_info_t belkin_hid2nut[] = {
{ "ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", 0, stringid_conversion },
{ "ups.test.result", 0, 0, "UPS.BELKINControls.BELKINTest", NULL, "%s", 0, belkin_test_info },
{ "ups.type", 0, 0, "UPS.BELKINDevice.BELKINUPSType", NULL, "%s", 0, belkin_upstype_conversion },
/* Liebert PSA: */
{ "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL }, /* why .broken above? */
{ "input.frequency", 0, 0, "UPS.Input.Frequency", NULL, "%s", 0, divide_by_10_conversion },
{ "input.voltage", 0, 0, "UPS.Input.Voltage", NULL, "%s", 0, liebert_line_voltage_info },
{ "output.voltage", 0, 0, "UPS.Output.Voltage", NULL, "%s", 0, liebert_line_voltage_info },
/* You would think these next two would be off by the same factor. You'd be wrong. */
{ "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%s", 0, liebert_line_voltage_info },
{ "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, "%s", HU_FLAG_STATIC, liebert_config_voltage_info },
{ "ups.load", 0, 0, "UPS.Output.PercentLoad", NULL, "%.0f", 0, NULL },
/* status */
{ "BOOL", 0, 0, "UPS.PowerSummary.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.ShutdownImminent", NULL, NULL, 0, shutdownimm_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_discharging_info }, /* might not need to be liebert_* version */
{ "BOOL", 0, 0, "UPS.PowerSummary.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_charging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.ShutdownImminent", NULL, NULL, 0, liebert_shutdownimm_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_online_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_discharging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_charging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, liebert_shutdownimm_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_online_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_replacebatt_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, liebert_lowbatt_info },
/* { "BOOL", 0, 0, "UPS.PowerSummary.BelowRemainingCapacityLimit", NULL, "%s", 0, lowbatt_info }, broken! */
{ "BOOL", 0, 0, "UPS.BELKINStatus.BELKINPowerStatus", NULL, NULL, 0, belkin_overload_conversion },
{ "BOOL", 0, 0, "UPS.BELKINStatus.BELKINPowerStatus", NULL, NULL, 0, belkin_overheat_conversion },

View file

@ -33,8 +33,8 @@
#define inline __inline
#endif
#define DRIVER_NAME "Best Fortress UPS driver"
#define DRIVER_VERSION "0.02"
#define DRIVER_NAME "Best Fortress UPS driver"
#define DRIVER_VERSION "0.05"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -116,7 +116,7 @@ static int checksum (char * s)
int sum;
for (i = 40, sum = 0; s[0] && s[1] && i > 0; i--, s += 2) {
sum += (fromhex (s[0]) << 4) + fromhex (s[1]);
}
}
return sum;
}
@ -201,22 +201,30 @@ void upsdrv_updateinfo(void)
char temp[256];
char *p;
int loadva;
int len;
int len, recv;
int retry;
char ch;
int checksum_ok, is_online=1, is_off, low_batt, trimming, boosting;
upsdebugx(1, "upsdrv_updateinfo");
for (retry = 0; retry < 5; ++retry) {
upsflushin (0, 0, "\r ");
upssend ("f\r");
while (ser_get_char(upsfd, &ch, 0, UPSDELAY) > 0 && ch != '\n'); /* response starts with \r\n */
temp[2] = 0;
do {
if (upsrecv (temp+2, sizeof temp - 2, ENDCHAR, IGNCHARS) <= 0) {
if ((recv = upsrecv (temp+2, sizeof temp - 2, ENDCHAR, IGNCHARS)) <= 0) {
upsflushin (0, 0, "\r ");
upssend ("f\r");
while (ser_get_char(upsfd, &ch, 0, UPSDELAY) > 0 && ch != '\n'); /* response starts with \r\n */
}
} while (temp[2] == 0);
/*syslog (LOG_DAEMON | LOG_NOTICE,"ups: got '%s'\n", p);*/
upsdebugx(1, "upsdrv_updateinfo: received %i bytes (try %i)", recv, retry);
upsdebug_hex(5, "buffer", temp, recv);
/* syslog (LOG_DAEMON | LOG_NOTICE,"ups: got %d chars '%s'\n", recv, temp + 2); */
/* status example:
000000000001000000000000012201210000001200014500000280600000990025000000000301BE
000000000001000000000000012401230000001200014800000280600000990025000000000301B7
@ -248,6 +256,8 @@ void upsdrv_updateinfo(void)
}
if (!checksum_ok) {
upsdebugx(2, "checksum corruption");
upsdebug_hex(3, "buffer", temp, len);
dstate_datastale();
return;
}

View file

@ -23,7 +23,7 @@
#include "serial.h"
#define DRIVER_NAME "Best UPS driver"
#define DRIVER_VERSION "1.05"
#define DRIVER_VERSION "1.06"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -422,6 +422,7 @@ void upsdrv_help(void)
void upsdrv_makevartable(void)
{
addvar(VAR_VALUE, "nombattvolt", "Override nominal battery voltage");
addvar(VAR_VALUE, "battvoltmult", "Battery voltage multiplier");
addvar(VAR_VALUE, "ID", "Force UPS ID response string");
}

View file

@ -2,9 +2,11 @@
* blazer.c: driver core for Megatec/Q1 protocol based UPSes
*
* A document describing the protocol implemented by this driver can be
* found online at "http://www.networkupstools.org/protocols/megatec.html".
* found online at http://www.networkupstools.org/ups-protocols/megatec.html
*
* Copyright (C) 2008,2009 - Arjen de Korte <adkorte-guest@alioth.debian.org>
* Copyright (C)
* 2008,2009 - Arjen de Korte <adkorte-guest@alioth.debian.org>
* 2012 - Arnaud Quette <ArnaudQuette@Eaton.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
@ -223,9 +225,9 @@ static int blazer_status(const char *cmd)
}
if (val[7] == '1') { /* Beeper On */
dstate_setinfo("beeper.status", "enabled");
dstate_setinfo("ups.beeper.status", "enabled");
} else {
dstate_setinfo("beeper.status", "disabled");
dstate_setinfo("ups.beeper.status", "disabled");
}
if (val[4] == '1') { /* UPS Type is Standby (0 is On_line) */
@ -280,6 +282,7 @@ static int blazer_status(const char *cmd)
if (val[6] == '1') { /* Shutdown Active */
alarm_set("Shutdown imminent!");
status_set("FSD");
}
alarm_commit();
@ -425,6 +428,13 @@ static int blazer_instcmd(const char *cmdname, const char *extra)
}
if (!strcasecmp(cmdname, "shutdown.return")) {
/*
* 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) {
snprintf(buf, sizeof(buf), "S.%dR%04d\r", offdelay / 6, ondelay);
} else {
@ -450,11 +460,14 @@ static int blazer_instcmd(const char *cmdname, const char *extra)
}
/*
* If a command is invalid, it will be echoed back
* If a command is invalid, it will be echoed back.
* As an exception, Best UPS units will report "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)) {
upslogx(LOG_ERR, "instcmd: command [%s] failed", cmdname);
return STAT_INSTCMD_FAILED;
}
}
upslogx(LOG_INFO, "instcmd: command [%s] handled", cmdname);
@ -523,6 +536,22 @@ static void blazer_initbattery(void)
{
const char *val;
/* 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)) {
upslogx(LOG_INFO, "No values provided for battery high/low voltages in ups.conf\n");
/* Basic formula, which should cover most cases */
batt.volt.low = 104 * batt.volt.nom / 120;
batt.volt.high = 130 * batt.volt.nom / 120;
/* Publish these data too */
dstate_setinfo("battery.voltage.low", "%.2f", batt.volt.low);
dstate_setinfo("battery.voltage.high", "%.2f", batt.volt.high);
upslogx(LOG_INFO, "Using 'guestimation' (low: %f, high: %f)!", batt.volt.low, batt.volt.high);
}
val = getval("runtimecal");
if (val) {
double rh, lh, rl, ll;

View file

@ -26,7 +26,7 @@
#include "blazer.h"
#define DRIVER_NAME "Megatec/Q1 protocol serial driver"
#define DRIVER_VERSION "1.51"
#define DRIVER_VERSION "1.55"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -37,7 +37,7 @@ upsdrv_info_t upsdrv_info = {
{ NULL }
};
#define SER_WAIT_SEC 1
#define SER_WAIT_SEC 1 /* 3 seconds for Best UPS */
/*
* Generic command processing function. Send a command and read a reply.
@ -58,7 +58,7 @@ int blazer_command(const char *cmd, char *buf, size_t buflen)
return ret;
}
upsdebugx(3, "send: %.*s", (int)strcspn(cmd, "\r"), cmd);
upsdebugx(3, "send: '%.*s'", (int)strcspn(cmd, "\r"), cmd);
ret = ser_get_buf(upsfd, buf, buflen, SER_WAIT_SEC, 0);
@ -67,7 +67,7 @@ int blazer_command(const char *cmd, char *buf, size_t buflen)
return ret;
}
upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf);
upsdebugx(3, "read: '%.*s'", (int)strcspn(buf, "\r"), buf);
return ret;
#else
const struct {

View file

@ -5,7 +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>
* 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
@ -28,7 +28,7 @@
#include "blazer.h"
#define DRIVER_NAME "Megatec/Q1 protocol USB driver"
#define DRIVER_VERSION "0.04"
#define DRIVER_VERSION "0.08"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -64,7 +64,7 @@ static int cypress_command(const char *cmd, char *buf, size_t buflen)
/* Write data in 8-byte chunks */
/* ret = usb->set_report(udev, 0, (unsigned char *)&tmp[i], 8); */
ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
0x09, 0x200, 0, &tmp[i], 8, 1000);
0x09, 0x200, 0, &tmp[i], 8, 5000);
if (ret <= 0) {
upsdebugx(3, "send: %s", ret ? usb_strerror() : "timeout");
@ -346,7 +346,11 @@ static usb_device_id_t blazer_usb_id[] = {
{ 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, 0x0002), &cypress_subdriver }, /* Online Yunto YQ450 */
{ USB_DEVICE(0x06da, 0x0003), &ippon_subdriver }, /* Mustek Powermust */
{ USB_DEVICE(0x06da, 0x0004), &cypress_subdriver }, /* Phoenixtec Innova 3/1 T */
{ USB_DEVICE(0x06da, 0x0005), &cypress_subdriver }, /* Phoenixtec Innova RT */
{ USB_DEVICE(0x06da, 0x0201), &cypress_subdriver }, /* Phoenixtec Innova T */
{ USB_DEVICE(0x0f03, 0x0001), &cypress_subdriver }, /* Unitek Alpha 1200Sx */
{ USB_DEVICE(0x14f0, 0x00c9), &phoenix_subdriver }, /* GE EP series */
/* end of list */

View file

@ -1,14 +1,15 @@
/* compaq-mib.c - data to monitor SNMP UPS with NUT
*
* Copyright (C) 2002-2006
* Arnaud Quette <arnaud.quette@free.fr>
* Niels Baggesen <niels@baggesen.net>
* Philip Ward <p.g.ward@stir.ac.uk>
* Copyright (C)
* 2002-2012 Arnaud Quette <arnaud.quette@free.fr>
* 2002-2006 Niels Baggesen <niels@baggesen.net>
* 2002-2006 Philip Ward <p.g.ward@stir.ac.uk>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
* This program was sponsored by MGE UPS SYSTEMS, and now Eaton
*
* This version has been tested using an HP R5500XR UPS with AF401A
* management card and a single phase input.
* This version has been tested using:
* HP R5500XR UPS with management card AF401A and a single phase input
* HP R/T3000 UPS with management card AF465A and a single phase input
*
* 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
@ -29,48 +30,58 @@
#include "compaq-mib.h"
#define CPQPOWER_MIB_VERSION "1.0"
#define CPQPOWER_MIB_VERSION "1.5"
#define DEFAULT_ONDELAY 30
#define DEFAULT_OFFDELAY 20
#define STR_DEFAULT_ONDELAY "30"
#define STR_DEFAULT_OFFDELAY "20"
/* Note: RFC-1628 (UPS MIB) is also supported on these devices! */
/* SNMP OIDs set */
#define CPQPOWER_OID_UPS_MIB "1.3.6.1.4.1.232.165.3"
#define CPQPOWER_OID_UPS_MIB ".1.3.6.1.4.1.232.165.3"
/* FIXME: to be verified */
#define CPQPOWER_SYSOID CPQPOWER_OID_UPS_MIB
#define CPQPOWER_OID_MFR_NAME CPQPOWER_OID_UPS_MIB ".1.1.0" /* UPS-MIB::upsIdentManufacturer */
#define CPQPOWER_OID_MODEL_NAME CPQPOWER_OID_UPS_MIB ".1.2.0" /* UPS-MIB::upsIdentModel */
#define CPQPOWER_OID_FIRMREV CPQPOWER_OID_UPS_MIB ".1.3.0" /* UPS-MIB::upsIdentUPSSoftwareVersion */
#define CPQPOWER_OID_OEMCODE CPQPOWER_OID_UPS_MIB ".1.4.0" /* UPS-MIB::upsIdentAgentSoftwareVersion */
#define CPQPOWER_OID_MFR_NAME ".1.3.6.1.4.1.232.165.3.1.1.0" /* UPS-MIB::upsIdentManufacturer */
#define CPQPOWER_OID_MODEL_NAME ".1.3.6.1.4.1.232.165.3.1.2.0" /* UPS-MIB::upsIdentModel */
#define CPQPOWER_OID_FIRMREV ".1.3.6.1.4.1.232.165.3.1.3.0" /* UPS-MIB::upsIdentUPSSoftwareVersion */
#define CPQPOWER_OID_OEMCODE ".1.3.6.1.4.1.232.165.3.1.4.0" /* UPS-MIB::upsIdentAgentSoftwareVersion */
#define CPQPOWER_OID_BATT_RUNTIME CPQPOWER_OID_UPS_MIB ".2.1.0" /* UPS-MIB::upsEstimatedMinutesRemaining */
#define CPQPOWER_OID_BATT_VOLTAGE CPQPOWER_OID_UPS_MIB ".2.2.0" /* UPS-MIB::upsBatteryVoltage */
#define CPQPOWER_OID_BATT_CURRENT CPQPOWER_OID_UPS_MIB ".2.3.0" /* UPS-MIB::upsBatteryCurrent */
#define CPQPOWER_OID_BATT_CHARGE CPQPOWER_OID_UPS_MIB ".2.4.0" /* UPS-MIB::upsBattCapacity */
#define CPQPOWER_OID_BATT_STATUS CPQPOWER_OID_UPS_MIB ".2.5.0" /* UPS-MIB::upsBatteryAbmStatus */
#define CPQPOWER_OID_BATT_RUNTIME ".1.3.6.1.4.1.232.165.3.2.1.0" /* UPS-MIB::upsEstimatedMinutesRemaining */
#define CPQPOWER_OID_BATT_VOLTAGE ".1.3.6.1.4.1.232.165.3.2.2.0" /* UPS-MIB::upsBatteryVoltage */
#define CPQPOWER_OID_BATT_CURRENT ".1.3.6.1.4.1.232.165.3.2.3.0" /* UPS-MIB::upsBatteryCurrent */
#define CPQPOWER_OID_BATT_CHARGE ".1.3.6.1.4.1.232.165.3.2.4.0" /* UPS-MIB::upsBattCapacity */
#define CPQPOWER_OID_BATT_STATUS ".1.3.6.1.4.1.232.165.3.2.5.0" /* UPS-MIB::upsBatteryAbmStatus */
#define CPQPOWER_OID_IN_FREQ CPQPOWER_OID_UPS_MIB ".3.1.0" /* UPS-MIB::upsInputFrequency */
#define CPQPOWER_OID_IN_LINEBADS CPQPOWER_OID_UPS_MIB ".3.2.0" /* UPS-MIB::upsInputLineBads */
#define CPQPOWER_OID_IN_LINES CPQPOWER_OID_UPS_MIB ".3.3.0" /* UPS-MIB::upsInputNumPhases */
#define CPQPOWER_OID_IN_FREQ ".1.3.6.1.4.1.232.165.3.3.1.0" /* UPS-MIB::upsInputFrequency */
#define CPQPOWER_OID_IN_LINEBADS ".1.3.6.1.4.1.232.165.3.3.2.0" /* UPS-MIB::upsInputLineBads */
#define CPQPOWER_OID_IN_LINES ".1.3.6.1.4.1.232.165.3.3.3.0" /* UPS-MIB::upsInputNumPhases */
#define CPQPOWER_OID_IN_PHASE CPQPOWER_OID_UPS_MIB ".3.4.1.1" /* UPS-MIB::upsInputPhase */
#define CPQPOWER_OID_IN_VOLTAGE CPQPOWER_OID_UPS_MIB ".3.4.1.2" /* UPS-MIB::upsInputVoltage */
#define CPQPOWER_OID_IN_CURRENT CPQPOWER_OID_UPS_MIB ".3.4.1.3" /* UPS-MIB::upsInputCurrent */
#define CPQPOWER_OID_IN_POWER CPQPOWER_OID_UPS_MIB ".3.4.1.4" /* UPS-MIB::upsInputWatts */
#define CPQPOWER_OID_IN_PHASE ".1.3.6.1.4.1.232.165.3.3.4.1.1" /* UPS-MIB::upsInputPhase */
#define CPQPOWER_OID_IN_VOLTAGE ".1.3.6.1.4.1.232.165.3.3.4.1.2" /* UPS-MIB::upsInputVoltage */
#define CPQPOWER_OID_IN_CURRENT ".1.3.6.1.4.1.232.165.3.3.4.1.3" /* UPS-MIB::upsInputCurrent */
#define CPQPOWER_OID_IN_POWER ".1.3.6.1.4.1.232.165.3.3.4.1.4" /* UPS-MIB::upsInputWatts */
#define CPQPOWER_OID_LOAD_LEVEL CPQPOWER_OID_UPS_MIB ".4.1.0" /* UPS-MIB::upsOutputLoad */
#define CPQPOWER_OID_OUT_FREQUENCY CPQPOWER_OID_UPS_MIB ".4.2.0" /* UPS-MIB::upsOutputFrequency */
#define CPQPOWER_OID_OUT_LINES CPQPOWER_OID_UPS_MIB ".4.3.0" /* UPS-MIB::upsOutputNumPhases */
#define CPQPOWER_OID_LOAD_LEVEL ".1.3.6.1.4.1.232.165.3.4.1.0" /* UPS-MIB::upsOutputLoad */
#define CPQPOWER_OID_OUT_FREQUENCY ".1.3.6.1.4.1.232.165.3.4.2.0" /* UPS-MIB::upsOutputFrequency */
#define CPQPOWER_OID_OUT_LINES ".1.3.6.1.4.1.232.165.3.4.3.0" /* UPS-MIB::upsOutputNumPhases */
#define CPQPOWER_OID_OUT_PHASE CPQPOWER_OID_UPS_MIB ".4.4.1.1" /* UPS-MIB::upsOutputPhase */
#define CPQPOWER_OID_OUT_VOLTAGE CPQPOWER_OID_UPS_MIB ".4.4.1.2" /* UPS-MIB::upsOutputVoltage */
#define CPQPOWER_OID_OUT_CURRENT CPQPOWER_OID_UPS_MIB ".4.4.1.3" /* UPS-MIB::upsOutputCurrent */
#define CPQPOWER_OID_OUT_POWER CPQPOWER_OID_UPS_MIB ".4.4.1.4" /* UPS-MIB::upsOutputWatts */
#define CPQPOWER_OID_OUT_PHASE ".1.3.6.1.4.1.232.165.3.4.4.1.1" /* UPS-MIB::upsOutputPhase */
#define CPQPOWER_OID_OUT_VOLTAGE ".1.3.6.1.4.1.232.165.3.4.4.1.2" /* UPS-MIB::upsOutputVoltage */
#define CPQPOWER_OID_OUT_CURRENT ".1.3.6.1.4.1.232.165.3.4.4.1.3" /* UPS-MIB::upsOutputCurrent */
#define CPQPOWER_OID_OUT_POWER ".1.3.6.1.4.1.232.165.3.4.4.1.4" /* UPS-MIB::upsOutputWatts */
#define CPQPOWER_OID_POWER_STATUS CPQPOWER_OID_UPS_MIB ".4.5.0" /* UPS-MIB::upsOutputSource */
#define CPQPOWER_OID_POWER_STATUS ".1.3.6.1.4.1.232.165.3.4.5.0" /* UPS-MIB::upsOutputSource */
#define CPQPOWER_OID_AMBIENT_TEMP CPQPOWER_OID_UPS_MIB ".6.1.0" /* UPS-MIB::upsEnvAmbientTemp */
#define CPQPOWER_OID_AMBIENT_TEMP ".1.3.6.1.4.1.232.165.3.6.1.0" /* UPS-MIB::upsEnvAmbientTemp */
#define CPQPOWER_OID_UPS_TEST_BATT ".1.3.6.1.4.1.232.165.3.7.1.0" /* UPS-MIB::upsTestBattery */
#define CPQPOWER_OID_UPS_TEST_RES ".1.3.6.1.4.1.232.165.3.7.2.0" /* UPS-MIB::upsTestBatteryStatus */
#define CPQPOWER_OID_ALARM_OB ".1.3.6.1.4.1.232.165.3.7.3.0" /* UPS-MIB::upsOnBattery */
#define CPQPOWER_OID_ALARM_LB ".1.3.6.1.4.1.232.165.3.7.4.0" /* UPS-MIB::upsLowBattery */
#define CPQPOWER_OID_UPS_TEST_BATT CPQPOWER_OID_UPS_MIB ".7.1.0" /* UPS-MIB::upsTestBattery */
#define CPQPOWER_OID_UPS_TEST_RES CPQPOWER_OID_UPS_MIB ".7.2.0" /* UPS-MIB::upsTestBatteryStatus */
#define CPQPOWER_OID_ALARM_OB CPQPOWER_OID_UPS_MIB ".7.3.0" /* UPS-MIB::upsOnBattery */
#define CPQPOWER_OID_ALARM_LB CPQPOWER_OID_UPS_MIB ".7.4.0" /* UPS-MIB::upsLowBattery */
static info_lkp_t cpqpower_alarm_ob[] = {
{ 1, "OB" },
@ -132,7 +143,28 @@ static info_lkp_t cpqpower_test_res_info[] = {
{ 0, "NULL" }
} ;
#define CPQPOWER_OID_SD_AFTER_DELAY CPQPOWER_OID_UPS_MIB ".8.1.0" /* UPS-MIB::upsShutdownAfterDelay */
#define CPQPOWER_START_TEST 1
static info_lkp_t cpqpower_outlet_status_info[] = {
{ 1, "on" },
{ 2, "off" },
{ 3, "pendingOff" }, /* transitional status */
{ 4, "pendingOn" }, /* transitional status */
{ 5, "unknown" },
{ 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 cpqpower_outlet_switchability_info[] = {
{ 1, "yes" },
{ 2, "yes" },
{ 3, "yes" },
{ 4, "yes" },
{ 0, NULL }
};
#define CPQPOWER_OID_SD_AFTER_DELAY ".1.3.6.1.4.1.232.165.3.8.1.0" /* UPS-MIB::upsControlOutputOffDelay */
#define CPQPOWER_OFF_DO 0
/* Snmp2NUT lookup table */
@ -142,10 +174,15 @@ static snmp_info_t cpqpower_mib[] = {
/* info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_MFR_NAME, "HP/Compaq", SU_FLAG_STATIC, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_MODEL_NAME, "SNMP UPS", SU_FLAG_STATIC, NULL },
{ "ups.model.aux", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_OEMCODE, "", SU_FLAG_STATIC, NULL },
/* { "ups.model.aux", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_OEMCODE, "", SU_FLAG_STATIC, NULL },*/
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.232.165.1.2.7.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
/* FIXME: split between firmware and firmware.aux ("00.01.0019;00.01.0004")
* UPS Firmware Revision : 00.01.0004
* Communication Board Firmware Revision : 00.01.0019 */
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_FIRMREV, "", SU_FLAG_STATIC, NULL },
{ "ups.load", 0, 1.0, CPQPOWER_OID_LOAD_LEVEL, "", 0, NULL },
{ "ups.realpower", 0, 1.0, CPQPOWER_OID_OUT_POWER, "", SU_OUTPUT_1, NULL },
{ "ups.realpower", 0, 1.0, ".1.3.6.1.4.1.232.165.3.9.3.0", "", SU_OUTPUT_1, NULL },
{ "ups.L1.realpower", 0, 0.1, CPQPOWER_OID_OUT_POWER ".1", "", SU_OUTPUT_3, NULL },
{ "ups.L2.realpower", 0, 0.1, CPQPOWER_OID_OUT_POWER ".2", "", SU_OUTPUT_3, NULL },
{ "ups.L3.realpower", 0, 0.1, CPQPOWER_OID_OUT_POWER ".3", "", SU_OUTPUT_3, NULL },
@ -154,27 +191,54 @@ static snmp_info_t cpqpower_mib[] = {
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_ALARM_OB, "", SU_STATUS_BATT, cpqpower_alarm_ob },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_ALARM_LB, "", SU_STATUS_BATT, cpqpower_alarm_lb },
/* { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_BATT_STATUS, "", SU_STATUS_BATT, ietf_batt_info }, */
/* FIXME: this should use either .1.3.6.1.4.1.232.165.3.11.1.0 (upsTopologyType)
* or .1.3.6.1.4.1.232.165.3.11.2.0 (upsTopoMachineCode) */
{ "ups.type", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_POWER_STATUS, "", SU_STATUS_PWR, cpqpower_mode_info },
{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_UPS_TEST_RES, "", 0, cpqpower_test_res_info },
/* FIXME: handle ups.date and ups.time
* - OID: .1.3.6.1.4.1.232.165.3.9.5.0
* - format MM/DD/YYYY HH:MM:SS */
/* FIXME: handle upsInputSource.0 (".1.3.6.1.4.1.232.165.3.3.5.0")
* other(1)
* none(2)
* primaryUtility(3)
* bypassFeed(4)
* secondaryUtility(5)
* generator(6)
* flywheel(7)
* fuelcell(8) */
{ "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.8.1.0", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.8.2.0", STR_DEFAULT_ONDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.timer.shutdown", 0, 1, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_FLAG_OK, NULL },
{ "ups.timer.start", 0, 1, ".1.3.6.1.4.1.232.165.3.8.2.0", "", SU_FLAG_OK, NULL },
/* Ambient page */
{ "ambient.temperature", 0, 1.0, CPQPOWER_OID_AMBIENT_TEMP, "", 0, NULL },
{ "ambient.temperature.low", 0, 1.0, ".1.3.6.1.4.1.232.165.3.6.2.0", "", 0, NULL },
{ "ambient.temperature.high", 0, 1.0, ".1.3.6.1.4.1.232.165.3.6.3.0", "", 0, NULL },
/* Battery page */
{ "battery.charge", 0, 1.0, CPQPOWER_OID_BATT_CHARGE, "", 0, NULL },
{ "battery.runtime", 0, 60.0, CPQPOWER_OID_BATT_RUNTIME, "", 0, NULL },
{ "battery.runtime", 0, 1.0, CPQPOWER_OID_BATT_RUNTIME, "", 0, NULL },
{ "battery.voltage", 0, 0.1, CPQPOWER_OID_BATT_VOLTAGE, "", 0, NULL },
{ "battery.current", 0, 0.1, CPQPOWER_OID_BATT_CURRENT, "", 0, NULL },
/* FIXME: need the new variable (for ABM)
{ "battery.status", 0, 0.1, ".1.3.6.1.4.1.232.165.3.2.5.0", "", 0, NULL }, */
/* Input page */
{ "input.phases", 0, 1.0, CPQPOWER_OID_IN_LINES, "", SU_FLAG_SETINT, NULL, &input_phases },
/* { "input.phase", 0, 1.0, CPQPOWER_OID_IN_PHASE, "", SU_OUTPUT_1, NULL }, */
{ "input.frequency", 0, 0.1, CPQPOWER_OID_IN_FREQ , "", 0, NULL },
{ "input.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE, "", SU_OUTPUT_1, NULL },
{ "input.voltage", 0, 1.0, ".1.3.6.1.4.1.232.165.3.3.4.1.2.1", "", SU_OUTPUT_1, NULL },
{ "input.voltage.nominal", ST_FLAG_RW | ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.9.2.0", "", SU_OUTPUT_1, NULL },
{ "input.L1-N.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE ".1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE ".2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE ".3", "", SU_INPUT_3, NULL },
{ "input.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT, "", SU_OUTPUT_1, NULL },
{ "input.current", 0, 0.1, ".1.3.6.1.4.1.232.165.3.3.4.1.3.1", "", SU_OUTPUT_1, NULL },
{ "input.L1.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT ".1", "", SU_INPUT_3, NULL },
{ "input.L2.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT ".2", "", SU_INPUT_3, NULL },
{ "input.L3.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT ".3", "", SU_INPUT_3, NULL },
@ -188,21 +252,76 @@ static snmp_info_t cpqpower_mib[] = {
{ "output.phases", 0, 1.0, CPQPOWER_OID_OUT_LINES, "", SU_FLAG_SETINT, NULL, &output_phases },
/* { "output.phase", 0, 1.0, CPQPOWER_OID_OUT_PHASE, "", SU_OUTPUT_1, NULL }, */
{ "output.frequency", 0, 0.1, CPQPOWER_OID_OUT_FREQUENCY, "", 0, NULL },
/* FIXME: handle multiplier (0.1 there) */
{ "output.frequency.nominal", ST_FLAG_RW | ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.9.4.0", "", SU_OUTPUT_1, NULL },
{ "output.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE, "", SU_OUTPUT_1, NULL },
{ "output.voltage", 0, 1.0, ".1.3.6.1.4.1.232.165.3.4.4.1.2.1", "", SU_OUTPUT_1, NULL },
{ "output.voltage.nominal", ST_FLAG_RW | ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.9.1.0", "", SU_OUTPUT_1, NULL },
{ "output.L1-N.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE ".1", "", SU_OUTPUT_3, NULL },
{ "output.L2-N.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE ".2", "", SU_OUTPUT_3, NULL },
{ "output.L3-N.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE ".3", "", SU_OUTPUT_3, NULL },
{ "output.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT, "", SU_OUTPUT_1, NULL },
{ "output.current", 0, 0.1, ".1.3.6.1.4.1.232.165.3.4.4.1.3.1", "", SU_OUTPUT_1, NULL },
/* { "output.realpower", 0, 1.0, ".1.3.6.1.4.1.232.165.3.4.4.1.4", "", SU_OUTPUT_1, NULL }, */
{ "output.L1.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT ".1", "", SU_OUTPUT_3, NULL },
{ "output.L2.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT ".2", "", SU_OUTPUT_3, NULL },
{ "output.L3.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT ".3", "", SU_OUTPUT_3, NULL },
/* FIXME: what to map with these?
* Name/OID: upsConfigLowOutputVoltageLimit.0; Value (Integer): 160
* => input.transfer.low?
* Name/OID: upsConfigHighOutputVoltageLimit.0; Value (Integer): 288
* => input.transfer.high? */
/* Outlet page */
{ "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "All outlets",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "outlet.count", 0, 1, ".1.3.6.1.4.1.232.165.3.10.1.0", "0", 0, NULL }, /* upsNumReceptacles */
/* { "outlet.current", 0, 0.001, AR_OID_UNIT_CURRENT ".0", NULL, 0, NULL, NULL },
{ "outlet.voltage", 0, 0.001, AR_OID_UNIT_VOLTAGE ".0", NULL, 0, NULL, NULL },
{ "outlet.realpower", 0, 1.0, AR_OID_UNIT_ACTIVEPOWER ".0", NULL, 0, NULL, NULL },
{ "outlet.power", 0, 1.0, AR_OID_UNIT_APPARENTPOWER ".0", NULL, 0, NULL, NULL }, */
/* outlet template definition */
/* FIXME always true? */
{ "outlet.%i.switchable", ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.10.2.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, &cpqpower_outlet_switchability_info[0], NULL },
{ "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.232.165.3.10.2.1.1.%i", "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK | SU_OUTLET, NULL, NULL },
/* { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, AR_OID_OUTLET_NAME ".%i", NULL, SU_OUTLET, NULL, NULL }, */
{ "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.232.165.3.10.2.1.2.%i", NULL, SU_FLAG_OK | SU_OUTLET, &cpqpower_outlet_status_info[0], NULL },
/* FIXME: come up with a suitable varname!
* - The delay after going On Battery until the Receptacle is automatically turned Off.
* A value of -1 means that this Output should never be turned Off automatically, but must be turned Off only by command.
* { "outlet.%i.autoswitch.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.10.2.1.5.%i", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, // upsRecepAutoOffDelay
* - Seconds delay after the Outlet is signaled to turn On before the Output is Automatically turned ON.
* A value of -1 means that this Output should never be turned On automatically, but only when specifically commanded to do so.
* { "outlet.%i.autoswitch.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.10.2.1.5.%i", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, // upsRecepAutoOnDelay
*/
/* FIXME: also define .stop (as for 'shutdown.reboot')
* and .delay */
{ "outlet.%i.load.off", 0, 0, ".1.3.6.1.4.1.232.165.3.10.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
{ "outlet.%i.load.on", 0, 0, ".1.3.6.1.4.1.232.165.3.10.2.1.4.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
/* FIXME: also define a .delay or map to "outlet.%i.delay.shutdown" */
{ "outlet.%i.load.cycle", 0, 0, ".1.3.6.1.4.1.232.165.3.10.2.1.7.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
/* instant commands. */
{ "load.off", 0, CPQPOWER_OFF_DO, CPQPOWER_OID_SD_AFTER_DELAY, "", SU_TYPE_CMD, NULL },
/* { CMD_SHUTDOWN, 0, CPQPOWER_OFF_GRACEFUL, CPQPOWER_OID_OFF, "", 0, NULL }, */
/* We need to duplicate load.{on,off} Vs load.{on,off}.delay, since
* "0" cancels the shutdown, so we put "1" (second) for immediate off! */
{ "load.off", 0, 1, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_TYPE_CMD, NULL },
{ "load.on", 0, 1, ".1.3.6.1.4.1.232.165.3.8.2.0", "", SU_TYPE_CMD, NULL },
{ "shutdown.stop", 0, 0, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
/* FIXME: need ups.{timer,delay}.{start,shutdown} param counterparts! */
{ "load.off.delay", 0, DEFAULT_OFFDELAY, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_TYPE_CMD, NULL },
{ "load.on.delay", 0, DEFAULT_ONDELAY, ".1.3.6.1.4.1.232.165.3.8.2.0", "", SU_TYPE_CMD, NULL },
/* { CMD_SHUTDOWN, 0, CPQPOWER_OFF_GRACEFUL, CPQPOWER_OID_OFF, "", 0, NULL }, */
{ "shutdown.reboot", 0, 0, ".1.3.6.1.4.1.232.165.3.8.6.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
{ "test.battery.start", 0, CPQPOWER_START_TEST, ".1.3.6.1.4.1.232.165.3.7.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }
};
mib2nut_info_t compaq = { "cpqpower", CPQPOWER_MIB_VERSION, "", CPQPOWER_OID_MFR_NAME, cpqpower_mib };
mib2nut_info_t compaq = { "cpqpower", CPQPOWER_MIB_VERSION, "", CPQPOWER_OID_MFR_NAME, cpqpower_mib, CPQPOWER_SYSOID };

View file

@ -52,7 +52,7 @@ static usb_device_id_t cps_usb_device_table[] = {
{ USB_DEVICE(CPS_VENDORID, 0x0005), NULL },
/* Dynex DX-800U? */
{ USB_DEVICE(CPS_VENDORID, 0x0501), &cps_battery_scale },
/* OR2200LCDRM2U */
/* OR2200LCDRM2U, OR700LCDRM1U, PR6000LCDRTXL5U */
{ USB_DEVICE(CPS_VENDORID, 0x0601), NULL },
/* Terminating entry */

View file

@ -3,6 +3,7 @@
Copyright (C)
2003 Russell Kroll <rkroll@exploits.org>
2008 Arjen de Korte <adkorte-guest@alioth.debian.org>
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
@ -273,6 +274,7 @@ static int st_tree_dump_conn(st_tree_t *node, conn_t *conn)
{
int ret;
enum_t *etmp;
range_t *rtmp;
if (!node) {
return 1; /* not an error */
@ -297,6 +299,13 @@ static int st_tree_dump_conn(st_tree_t *node, conn_t *conn)
}
}
/* send any ranges */
for (rtmp = node->range_list; rtmp; rtmp = rtmp->next) {
if (!send_to_one(conn, "ADDRANGE %s %i %i\n", node->var, rtmp->min, rtmp->max)) {
return 0;
}
}
/* provide any auxiliary data */
if (node->aux) {
if (!send_to_one(conn, "SETAUX %s %d\n", node->var, node->aux)) {
@ -318,7 +327,9 @@ static int st_tree_dump_conn(st_tree_t *node, conn_t *conn)
snprintfcat(flist, sizeof(flist), " STRING");
}
send_to_one(conn, "SETFLAGS %s\n", flist);
if (!send_to_one(conn, "SETFLAGS %s\n", flist)) {
return 0;
}
}
if (node->right) {
@ -633,6 +644,19 @@ int dstate_addenum(const char *var, const char *fmt, ...)
return ret;
}
int dstate_addrange(const char *var, const int min, const int max)
{
int ret;
ret = state_addrange(dtree_root, var, min, max);
if (ret == 1) {
send_to_all("ADDRANGE %s %i %i\n", var, min, max);
}
return ret;
}
void dstate_setflags(const char *var, int flags)
{
st_tree_t *sttmp;
@ -739,6 +763,20 @@ int dstate_delenum(const char *var, const char *val)
return ret;
}
int dstate_delrange(const char *var, const int min, const int max)
{
int ret;
ret = state_delrange(dtree_root, var, min, max);
/* update listeners */
if (ret == 1) {
send_to_all("DELRANGE %s \"%i %i\"\n", var, min, max);
}
return ret;
}
int dstate_delcmd(const char *cmd)
{
int ret;

View file

@ -1,6 +1,8 @@
/* dstate.h - Network UPS Tools driver-side state management
Copyright (C) 2003 Russell Kroll <rkroll@exploits.org>
Copyright (C)
2003 Russell Kroll <rkroll@exploits.org>
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
@ -45,12 +47,14 @@ 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);
void dstate_addcmd(const char *cmdname);
int dstate_delinfo(const char *var);
int dstate_delenum(const char *var, const char *val);
int dstate_delrange(const char *var, const int min, const int max);
int dstate_delcmd(const char *cmd);
void dstate_free(void);
const st_tree_t *dstate_getroot(void);

View file

@ -40,7 +40,7 @@
#include "dummy-ups.h"
#define DRIVER_NAME "Device simulation and repeater driver"
#define DRIVER_VERSION "0.12"
#define DRIVER_VERSION "0.13"
/* driver description structure */
upsdrv_info_t upsdrv_info =

View file

@ -1,7 +1,7 @@
/* dummy-ups.h - NUT testing driver and repeater
Copyright (C)
2005 - 2010 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
2005 - 2012 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
@ -18,11 +18,15 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* This file list all valid data with their type and info.
* this are then enable through a definition file, specified
/* This file lists all valid data with their type and info.
*
* These are then enabled through a definition file, specified
* as the "port" parameter (only the file name, not the path).
*
* The format of this file is the same as an upsc dump:
*
* <varname>: <value>
*
* FIXME: use cmdvartab for conformance checking
* ...
* Once the driver is loaded:
@ -36,24 +40,31 @@
/* Struct & data for ups.status processing */
/* --------------------------------------------------------------- */
#if 0 /* XXX status lookup table not currently used???? */
/*
* Status lookup table type definition
*/
typedef struct {
const char *status_str; /* ups.status string */
int status_value; /* ups.status value */
const char *status_str; /* ups.status string */
int status_value; /* ups.status flag bit */
} 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 */
#define STATUS_CAL (1 << 0) /* calibration */
#define STATUS_TRIM (1 << 1) /* SmartTrim */
#define STATUS_BOOST (1 << 2) /* SmartBoost */
#define STATUS_OL (1 << 3) /* on line */
#define STATUS_OB (1 << 4) /* on battery */
#define STATUS_OVER (1 << 5) /* overload */
#define STATUS_LB (1 << 6) /* low battery */
#define STATUS_RB (1 << 7) /* replace battery */
#define STATUS_BYPASS (1 << 8) /* on bypass */
#define STATUS_OFF (1 << 9) /* ups is off */
#define STATUS_CHRG (1 << 10) /* charging */
#define STATUS_DISCHRG (1 << 11) /* discharging */
/*
* Status lookup table
*/
status_lkp_t status_info[] = {
{ "CAL", STATUS_CAL },
{ "TRIM", STATUS_TRIM },
@ -69,7 +80,7 @@ status_lkp_t status_info[] = {
{ "DISCHRG", STATUS_DISCHRG },
{ "NULL", 0 },
};
/* from usbhid-ups.h */
#endif /* 0 -- not currently used??? */
typedef struct {
char hid_value; /* HID value */
@ -96,7 +107,6 @@ typedef struct {
/* data flags */
#define DU_FLAG_NONE 0
#define DU_FLAG_INIT 1 /* intialy show element to upsd */
#define DU_TYPE_CMD 2
/* --------------------------------------------------------------- */
/* Data table (all possible info from NUT, then enable upon cong */
@ -166,16 +176,16 @@ battery.alarm.threshold
battery.date
battery.packs
battery.packs.bad
ambient.temperature
ambient.temperature.alarm
ambient.temperature.high
ambient.temperature.low
ambient.humidity
ambient.humidity.alarm
ambient.humidity.high
ambient.humidity.low
*/
{ "ambient.temperature", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.temperature.alarm", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.temperature.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.temperature.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.humidity", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.humidity.alarm", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.humidity.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
{ "ambient.humidity.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL },
/*
FIXME: how to manage these?
outlet.n.id
outlet.n.desc

View file

@ -1,9 +1,9 @@
/* ietf-mib.c - data to monitor SNMP UPS (RFC 1628 compliant) with NUT
*
* Copyright (C) 2002-2006
* Arnaud Quette <arnaud.quette@free.fr>
* Niels Baggesen <niels@baggesen.net>
* Arjen de Korte <adkorte-guest@alioth.debian.org>
* 2002-2012 Arnaud Quette <arnaud.quette@free.fr>
* 2002-2006 Niels Baggesen <niels@baggesen.net>
* 2002-2006 Arjen de Korte <adkorte-guest@alioth.debian.org>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
*
@ -26,7 +26,7 @@
#include "ietf-mib.h"
#define IETF_MIB_VERSION "1.3"
#define IETF_MIB_VERSION "1.4"
/* SNMP OIDs set */
#define IETF_OID_UPS_MIB "1.3.6.1.2.1.33.1."
@ -263,7 +263,7 @@ static snmp_info_t ietf_mib[] = {
{ "output.power.nominal", 0, 1.0, IETF_OID_UPS_MIB "9.5.0", "", 0, NULL }, /* upsConfigOutputVA */
{ "output.realpower.nominal", 0, 1.0, IETF_OID_UPS_MIB "9.6.0", "", 0, NULL }, /* upsConfigOutputPower */
{ "battery.runtime.low", 0, 60.0, IETF_OID_UPS_MIB "9.7.0", "", 0, NULL }, /* upsConfigLowBattTime */
{ "beeper.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "9.8.0", "", 0, ietf_beeper_status_info }, /* upsConfigAudibleStatus */
{ "ups.beeper.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_UPS_MIB "9.8.0", "", 0, ietf_beeper_status_info }, /* upsConfigAudibleStatus */
{ "beeper.disable", 0, 1, IETF_OID_UPS_MIB "9.8.0", "", SU_TYPE_CMD, NULL },
{ "beeper.enable", 0, 2, IETF_OID_UPS_MIB "9.8.0", "", SU_TYPE_CMD, NULL },
{ "beeper.mute", 0, 3, IETF_OID_UPS_MIB "9.8.0", "", SU_TYPE_CMD, NULL },

View file

@ -41,7 +41,7 @@
#include "common.h" /* for xmalloc, upsdebugx prototypes */
#define SHUT_DRIVER_NAME "SHUT communication driver"
#define SHUT_DRIVER_VERSION "0.82"
#define SHUT_DRIVER_VERSION "0.83"
/* communication driver description structure */
upsdrv_info_t comm_upsdrv_info = {
@ -610,7 +610,7 @@ void setline(int upsfd, int set)
int shut_synchronise(int upsfd)
{
int retCode = 0;
u_char c = SHUT_SYNC, reply;
u_char c = SHUT_SYNC_OFF, reply;
int try;
upsdebugx (2, "entering shut_synchronise()");
@ -695,6 +695,12 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
memcpy(Buf, Start, 1);
return 1;
}
else if(Start[0]==SHUT_SYNC_OFF)
{
upsdebugx (4, "received SYNC_OFF token");
memcpy(Buf, Start, 1);
return 1;
}
else
{
/* if((serial_read (SHUT_TIMEOUT, &Start[1]) > 0) && */
@ -703,6 +709,12 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
{
upsdebug_hex(4, "Receive", Start, 2);
Size=Start[1]&0x0F;
if( Size > 8 ) {
upsdebugx (4, "shut_packet_recv: invalid frame size = %d", Size);
ser_send_char(upsfd, SHUT_NOK);
Retry++;
break;
}
/* sdata.shut_pkt.bLength = Size; */
for(recv=0;recv<Size;recv++)
{
@ -722,13 +734,15 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
Buf+=Size;
Pos+=Size;
Retry=0;
ser_send_char(upsfd, SHUT_OK);
/* shut_token_send(SHUT_OK); */
if(Start[0]&SHUT_PKT_LAST)
/* Check if there are more data to receive */
if((Start[0] & 0xf0) == SHUT_PKT_LAST)
{
if ((Start[0]&SHUT_PKT_LAST) == SHUT_TYPE_NOTIFY)
/* Check if it's a notification */
if ((Start[0] & 0x0f) == SHUT_TYPE_NOTIFY)
{
/* TODO: process notification (dropped for now) */
upsdebugx (4, "=> notification");
@ -736,7 +750,7 @@ int shut_packet_recv(int upsfd, u_char *Buf, int datalen)
Pos=0;
}
else
return Pos;
return Pos;
}
else
upsdebugx (4, "need more data (%i)!", datalen);
@ -876,8 +890,10 @@ int shut_control_msg(int upsfd, int requesttype, int request,
upsdebug_hex(4, "data", bytes, data_size);
}
}
else
data_size = (size >= 8) ? 8 : remaining_size;
else {
/* Always 8 bytes payload for GET_REPORT with SHUT */
data_size = 8;
}
/* Forge the SHUT Frame */
shut_pkt[0] = SHUT_TYPE_REQUEST + ( ((requesttype == REQUEST_TYPE_SET_REPORT) && (remaining_size>8))? 0 : SHUT_PKT_LAST);
@ -970,7 +986,7 @@ int shut_wait_ack(int upsfd)
upsdebugx (2, "shut_wait_ack(): NACK received");
retCode = -2;
}
else if ((c & SHUT_PKT_LAST) == SHUT_TYPE_NOTIFY)
else if ((c & 0x0f) == SHUT_TYPE_NOTIFY)
{
upsdebugx (2, "shut_wait_ack(): NOTIFY received");
retCode = -3;

View file

@ -29,7 +29,7 @@
#define LIEBERT_HID_VERSION "Liebert HID 0.3"
/* FIXME: experimental flag to be put in upsdrv_info */
/* Phoenixtec */
/* Phoenixtec Power Co., Ltd */
#define LIEBERT_VENDORID 0x06da
/* USB IDs device table */

View file

@ -108,7 +108,7 @@ void dump_buffer(unsigned char *buffer, int buf_len) {
int i;
for (i = 0; i < buf_len; i++) {
printf("byte %d: %x\n", i, buffer[i]);
}
}
return;
}
@ -127,7 +127,7 @@ void send_read_command(char command) {
if (retry == 4) send_zeros(); /* last retry is preceded by a serial reset...*/
sent = ser_send_buf(upsfd, buf, 4);
retry += 1;
}
}
}
/* send a write command to the UPS, the write command and the value to be written are passed
@ -136,20 +136,20 @@ void send_read_command(char command) {
void send_write_command(unsigned char *command, int command_length) {
int i, retry, sent, checksum;
unsigned char raw_buf[255];
/* prepares the raw data */
raw_buf[0] = 0x02; /* STX byte */
raw_buf[1] = (unsigned char)(command_length + 1); /* data length + checksum */
memcpy(raw_buf+2, command, command_length);
command_length += 2;
/* calculate checksum */
checksum = 0;
for (i = 1; i < command_length; i++) checksum += raw_buf[i];
checksum = checksum % 256;
raw_buf[command_length] = (unsigned char)checksum;
command_length +=1;
retry = 0;
sent = 0;
while ((sent != (command_length)) && (retry < 5)) {
@ -157,7 +157,7 @@ void send_write_command(unsigned char *command, int command_length) {
sent = ser_send_buf(upsfd, raw_buf, (command_length));
if (sent != (command_length)) printf("Error sending command %d\n", raw_buf[2]);
retry += 1;
}
}
}
@ -192,7 +192,7 @@ int get_answer(unsigned char *data) {
ser_comm_fail("Receive error (data): got %d bytes instead of %d!!!\n", res, packet_length);
return -1;
}
/* now we have the whole answer from the ups, we can checksum it
checksum byte is equal to the sum modulus 256 of all the data bytes + packet_length
(no STX no checksum byte itself) */
@ -215,7 +215,7 @@ int get_answer(unsigned char *data) {
int command_read_sequence(unsigned char command, unsigned char *data) {
int bytes_read = 0;
int retry = 0;
while ((bytes_read < 1) && (retry < 5)) {
send_read_command(command);
bytes_read = get_answer(data);
@ -806,7 +806,7 @@ void upsdrv_updateinfo(void)
printf("status unknown \n");
break;
}
status_commit();
status_commit();
dstate_dataok();
}
return;
@ -815,8 +815,7 @@ void upsdrv_updateinfo(void)
void upsdrv_shutdown(void)
{
unsigned char command[10], answer[10];
/* Ensure that the ups is configured for automatically
restart after a complete battery discharge
and when the power comes back after a shutdown */
@ -831,14 +830,14 @@ void upsdrv_shutdown(void)
command[5]=0x01; /* autorestart after battery depleted enabled */
command_write_sequence(command, 6, answer);
}
/* shedule a shutdown in 120 seconds */
command[0]=UPS_SET_SCHEDULING;
command[1]=0x96; /* remaining */
command[2]=0x00; /* time */
command[3]=0x00; /* to */
command[4]=0x00; /* shutdown 150 secs */
/* restart time has been set to 1 instead of 0 for avoiding
a bug in some ups firmware */
command[5]=0x01; /* programmed */
@ -860,7 +859,7 @@ static int instcmd(const char *cmdname, const char *extra)
{
unsigned char command[10], answer[10];
int res;
if (!strcasecmp(cmdname, "beeper.off")) {
/* compatibility mode for old command */
upslogx(LOG_WARNING,
@ -892,7 +891,7 @@ static int instcmd(const char *cmdname, const char *extra)
command[2]=0x00; /* time */
command[3]=0x00; /* to */
command[4]=0x00; /* shutdown 30 secs */
command[5]=0x01; /* programmed */
command[6]=0x00; /* time */
command[7]=0x00; /* to */
@ -900,7 +899,7 @@ static int instcmd(const char *cmdname, const char *extra)
command_write_sequence(command, 9, answer);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "shutdown.stayoff")) {
/* shedule a shutdown in 30 seconds with no restart (-1) */
command[0]=UPS_SET_SCHEDULING;
@ -916,7 +915,7 @@ static int instcmd(const char *cmdname, const char *extra)
command_write_sequence(command, 9, answer);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "shutdown.stop")) {
/* set shutdown and restart time to -1 (no shutdown, no restart) */
command[0]=UPS_SET_SCHEDULING;
@ -943,7 +942,7 @@ static int instcmd(const char *cmdname, const char *extra)
command_write_sequence(command, 2, answer);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "test.failure.stop")) {
/* restore standard mode (mains power) */
command[0]=UPS_SET_BATTERY_TEST;
@ -954,7 +953,7 @@ static int instcmd(const char *cmdname, const char *extra)
command_write_sequence(command, 2, answer);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "test.battery.start")) {
/* launch battery test */
command[0]=UPS_SET_BATTERY_TEST;
@ -996,7 +995,7 @@ static int instcmd(const char *cmdname, const char *extra)
upslogx(LOG_NOTICE, "test battery byte 1 = %x", answer[1]);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "beeper.enable")) {
/* set buzzer to not muted */
command[0]=UPS_SET_BUZZER_MUTE;
@ -1007,7 +1006,7 @@ static int instcmd(const char *cmdname, const char *extra)
command_write_sequence(command, 2, answer);
return STAT_INSTCMD_HANDLED;
}
if (!strcasecmp(cmdname, "beeper.mute")) {
/* set buzzer to muted */
command[0]=UPS_SET_BUZZER_MUTE;

View file

@ -1,6 +1,6 @@
/* mge-hid.c - data to monitor MGE UPS SYSTEMS HID (USB and serial) devices
/* mge-hid.c - data to monitor Eaton / MGE HID (USB and serial) devices
*
* Copyright (C) 2003 - 2009
* Copyright (C) 2003 - 2012
* Arnaud Quette <arnaud.quette@free.fr>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
@ -22,11 +22,21 @@
*
*/
/* TODO list:
* - better processing of FW info:
* * some models (HP R5000) include firmware.aux (00.01.0021;00.01.00)
* * other (9130) need more processing (0128 => 1.28)
* ...
* - better handling of input.transfer.* (need dstate_addrange)
* - outlet management logic (Ie, for outlet.X.load.{on,off}.delay
* => use outlet.X.delay.{start,stop}
*/
#include "main.h" /* for getval() */
#include "usbhid-ups.h"
#include "mge-hid.h"
#define MGE_HID_VERSION "MGE HID 1.27"
#define MGE_HID_VERSION "MGE HID 1.31"
/* (prev. MGE Office Protection Systems, prev. MGE UPS SYSTEMS) */
/* Eaton */
@ -38,6 +48,9 @@
/* Powerware */
#define POWERWARE_VENDORID 0x0592
/* Hewlett Packard */
#define HP_VENDORID 0x03f0
#ifndef SHUT_MODE
#include "usb-common.h"
@ -53,6 +66,14 @@ static usb_device_id_t mge_usb_device_table[] = {
/* PW 9140 */
{ USB_DEVICE(POWERWARE_VENDORID, 0x0004), NULL },
/* R/T3000 */
{ USB_DEVICE(HP_VENDORID, 0x1fe5), NULL },
/* R/T3000 */
{ USB_DEVICE(HP_VENDORID, 0x1fe6), NULL },
/* various models */
{ USB_DEVICE(HP_VENDORID, 0x1fe7), NULL },
{ USB_DEVICE(HP_VENDORID, 0x1fe8), NULL },
/* Terminating entry */
{ -1, -1, NULL }
};
@ -326,6 +347,53 @@ static info_lkp_t pegasus_threshold_info[] = {
{ 0, NULL, NULL }
};
/* allow limiting standard yes/no info (here, to enable ECO mode) to
* ups.model = Protection Station, Ellipse Eco and 3S (US 750 and AUS 700 only!)
* this allows to enable special flags used in hid_info_t entries (Ie RW) */
static const char *pegasus_yes_no_info_fun(double value)
{
switch (mge_type & 0xFF00) /* Ignore model byte */
{
case MGE_PEGASUS:
break;
case MGE_3S:
/* Only consider non European models */
if (country_code != COUNTRY_EUROPE)
break;
default:
return NULL;
}
return (value == 0) ? "no" : "yes";
}
/* Conversion back of yes/no info */
static double pegasus_yes_no_info_nuf(const char *value)
{
switch (mge_type & 0xFF00) /* Ignore model byte */
{
case MGE_PEGASUS:
break;
case MGE_3S:
/* Only consider non European models */
if (country_code != COUNTRY_EUROPE)
break;
default:
return 0;
}
if (!strncmp(value, "yes", 3))
return 1;
else
return 0;
}
info_lkp_t pegasus_yes_no_info[] = {
{ 0, "no", pegasus_yes_no_info_fun, pegasus_yes_no_info_nuf },
{ 1, "yes", pegasus_yes_no_info_fun, pegasus_yes_no_info_nuf },
{ 0, NULL, NULL }
};
/* Determine country using UPS.PowerSummary.Country.
* If not present:
* if PowerConverter.Output.Voltage >= 200 => "Europe"
@ -448,7 +516,7 @@ static info_lkp_t nominal_output_voltage_info[] = {
/* Vendor-specific usage table */
/* --------------------------------------------------------------- */
/* MGE UPS SYSTEMS usage table */
/* Eaton / MGE HID usage table */
static usage_lkp_t mge_usage_lkp[] = {
{ "Undefined", 0xffff0000 },
{ "STS", 0xffff0001 },
@ -474,7 +542,7 @@ static usage_lkp_t mge_usage_lkp[] = {
{ "EventID", 0xffff001f },
{ "CircuitBreaker", 0xffff0020 },
{ "TransferForbidden", 0xffff0021 },
{ "OverallAlarm", 0xffff0022 },
{ "OverallAlarm", 0xffff0022 }, /* renamed to Alarm in Eaton SW! */
{ "Dephasing", 0xffff0023 },
{ "BypassBreaker", 0xffff0024 },
{ "PowerModule", 0xffff0025 },
@ -486,8 +554,9 @@ static usage_lkp_t mge_usage_lkp[] = {
{ "NotificationStatus", 0xffff002b },
{ "ProtectionLost", 0xffff002c },
{ "ConfigurationFailure", 0xffff002d },
{ "CompatibilityFailure", 0xffff002e },
/* 0xffff002e-0xffff003f => Reserved */
{ "SwitchType", 0xffff0040 },
{ "SwitchType", 0xffff0040 }, /* renamed to Type in Eaton SW! */
{ "ConverterType", 0xffff0041 },
{ "FrequencyConverterMode", 0xffff0042 },
{ "AutomaticRestart", 0xffff0043 },
@ -556,8 +625,12 @@ static usage_lkp_t mge_usage_lkp[] = {
{ "HighHumidity", 0xffff0082 },
{ "LowTemperature", 0xffff0083 },
{ "HighTemperature", 0xffff0084 },
/* 0xffff0085-0xffff008f (minus 0xffff0086) => Reserved */
{ "ECOControl", 0xffff0085 },
{ "Efficiency", 0xffff0086 },
{ "ABMEnable", 0xffff0087 },
{ "NegativeCurrent", 0xffff0088 },
{ "AutomaticStart", 0xffff0089 },
/* 0xffff008a-0xffff008f => Reserved */
{ "Count", 0xffff0090 },
{ "Timer", 0xffff0091 },
{ "Interval", 0xffff0092 },
@ -569,16 +642,26 @@ static usage_lkp_t mge_usage_lkp[] = {
{ "Code", 0xffff0098 },
{ "DataValid", 0xffff0099 },
{ "ToggleTimer", 0xffff009a },
/* 0xffff009b-0xffff009f => Reserved */
{ "PDU", 0xffff00a0 },
{ "BypassTransferDelay", 0xffff009b },
{ "HysteresysVoltageTransfer", 0xffff009c },
{ "SlewRate", 0xffff009d },
/* 0xffff009e-0xffff009f => Reserved */
{ "PDU", 0xffff00a0 },
{ "Breaker", 0xffff00a1 },
{ "BreakerID", 0xffff00a2 },
{ "OverVoltage", 0xffff00a3 },
{ "OverVoltage", 0xffff00a3 },
{ "Tripped", 0xffff00a4 },
{ "OverEnergy", 0xffff00a5 },
{ "OverHumidity", 0xffff00a6 },
{ "LCDControl", 0xffff00a6 },
/* 0xffff00a8-0xffff00df => Reserved */
{ "OverHumidity", 0xffff00a6 },
{ "ConfigurationReset", 0xffff00a7 }, /* renamed from LCDControl in Eaton SW! */
{ "Level", 0xffff00a8 },
{ "PDUType", 0xffff00a9 },
{ "ReactivePower", 0xffff00aa },
{ "Pole", 0xffff00ab },
{ "PoleID", 0xffff00ac },
{ "Reset", 0xffff00ad },
{ "WatchdogReset", 0xffff00ae },
/* 0xffff00af-0xffff00df => Reserved */
{ "COPIBridge", 0xffff00e0 },
/* 0xffff00e1-0xffff00ef => Reserved */
{ "iModel", 0xffff00f0 },
@ -586,7 +669,8 @@ static usage_lkp_t mge_usage_lkp[] = {
{ "iTechnicalLevel", 0xffff00f2 },
{ "iPartNumber", 0xffff00f3 },
{ "iReferenceNumber", 0xffff00f4 },
/* 0xffff00f5-0xffff00ff => Reserved */
{ "iGang", 0xffff00f5 },
/* 0xffff00f6-0xffff00ff => Reserved */
/* end of table */
{ NULL, 0 }
@ -941,7 +1025,7 @@ static hid_info_t mge_hid2nut[] =
{ "outlet.power", 0, 0, "UPS.OutletSystem.Outlet.[1].ApparentPower", NULL, "%.0f", 0, NULL },
{ "outlet.realpower", 0, 0, "UPS.OutletSystem.Outlet.[1].ActivePower", NULL, "%.0f", 0, NULL },
{ "outlet.current", 0, 0, "UPS.OutletSystem.Outlet.[1].Current", NULL, "%.2f", 0, NULL },
{ "outlet.powerfactor", 0, 0, "UPS.OutletSystem.Outlet.[1].PowerFactor", NULL, "%.2f", 0, NULL }, // "%s", 0, mge_powerfactor_conversion },
{ "outlet.powerfactor", 0, 0, "UPS.OutletSystem.Outlet.[1].PowerFactor", NULL, "%.2f", 0, NULL }, /* "%s", 0, mge_powerfactor_conversion }, */
/* First outlet */
{ "outlet.1.id", 0, 0, "UPS.OutletSystem.Outlet.[2].OutletID", NULL, "%.0f", HU_FLAG_STATIC, NULL },
@ -950,18 +1034,22 @@ static hid_info_t mge_hid2nut[] =
{ "outlet.1.status", 0, 0, "UPS.OutletSystem.Outlet.[2].PresentStatus.SwitchOn/Off", NULL, "%s", 0, on_off_info },
/* For low end models, with 1 non backup'ed outlet */
{ "outlet.1.status", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, "%s", 0, on_off_info },
/* FIXME: change to outlet.1.battery.charge.low, as in mge-xml.c?! */
{ "outlet.1.autoswitch.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.OutletSystem.Outlet.[2].RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "outlet.1.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[2].ShutdownTimer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "outlet.1.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[2].StartupTimer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "outlet.1.power", 0, 0, "UPS.OutletSystem.Outlet.[2].ApparentPower", NULL, "%.0f", 0, NULL },
{ "outlet.1.realpower", 0, 0, "UPS.OutletSystem.Outlet.[2].ActivePower", NULL, "%.0f", 0, NULL },
{ "outlet.1.current", 0, 0, "UPS.OutletSystem.Outlet.[2].Current", NULL, "%.2f", 0, NULL },
{ "outlet.1.powerfactor", 0, 0, "UPS.OutletSystem.Outlet.[2].PowerFactor", NULL, "%.2f", 0, NULL }, // "%s", 0, mge_powerfactor_conversion },
{ "outlet.1.powerfactor", 0, 0, "UPS.OutletSystem.Outlet.[2].PowerFactor", NULL, "%.2f", 0, NULL }, /* "%s", 0, mge_powerfactor_conversion }, */
/* Second outlet */
{ "outlet.2.id", 0, 0, "UPS.OutletSystem.Outlet.[3].OutletID", NULL, "%.0f", HU_FLAG_STATIC, NULL },
{ "outlet.2.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[3].OutletID", NULL, "PowerShare Outlet 2", HU_FLAG_ABSENT, NULL },
/* needed for Pegasus to enable master/slave mode */
{ "outlet.2.switchable", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.OutletSystem.Outlet.[3].PresentStatus.Switchable", NULL, "%s", HU_FLAG_SEMI_STATIC, yes_no_info },
/* needed for Pegasus to enable master/slave mode:
* FIXME: rename to something more suitable (outlet.?) */
{ "outlet.2.switchable", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.OutletSystem.Outlet.[3].PresentStatus.Switchable", NULL, "%s", HU_FLAG_SEMI_STATIC, pegasus_yes_no_info },
/* Generic version (RO) for other models */
{ "outlet.2.switchable", 0, 0, "UPS.OutletSystem.Outlet.[3].PresentStatus.Switchable", NULL, "%s", 0, yes_no_info },
{ "outlet.2.status", 0, 0, "UPS.OutletSystem.Outlet.[3].PresentStatus.SwitchOn/Off", NULL, "%s", 0, on_off_info },
{ "outlet.2.autoswitch.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 3, "UPS.OutletSystem.Outlet.[3].RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "outlet.2.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[3].ShutdownTimer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
@ -969,7 +1057,7 @@ static hid_info_t mge_hid2nut[] =
{ "outlet.2.power", 0, 0, "UPS.OutletSystem.Outlet.[3].ApparentPower", NULL, "%.0f", 0, NULL },
{ "outlet.2.realpower", 0, 0, "UPS.OutletSystem.Outlet.[3].ActivePower", NULL, "%.0f", 0, NULL },
{ "outlet.2.current", 0, 0, "UPS.OutletSystem.Outlet.[3].Current", NULL, "%.2f", 0, NULL },
{ "outlet.2.powerfactor", 0, 0, "UPS.OutletSystem.Outlet.[3].PowerFactor", NULL, "%.2f", 0, NULL }, // "%s", 0, mge_powerfactor_conversion },
{ "outlet.2.powerfactor", 0, 0, "UPS.OutletSystem.Outlet.[3].PowerFactor", NULL, "%.2f", 0, NULL }, /* "%s", 0, mge_powerfactor_conversion }, */
/* instant commands. */
/* splited into subset while waiting for extradata support
@ -1084,20 +1172,37 @@ static int mge_claim(HIDDevice_t *hd) {
switch (status) {
case POSSIBLY_SUPPORTED:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
return 1;
}
possibly_supported("Eaton / MGE", hd);
return 0;
case POSSIBLY_SUPPORTED:
case SUPPORTED:
return 1;
switch (hd->VendorID)
{
case HP_VENDORID:
case DELL_VENDORID:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
return 1;
}
case NOT_SUPPORTED:
default:
return 0;
/*
* this vendor makes lots of USB devices that are
* not a UPS, so don't use possibly_supported here
*/
return 0;
default: /* Valid for Eaton */
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
return 1;
}
possibly_supported("Eaton / MGE", hd);
return 0;
}
case SUPPORTED:
return 1;
case NOT_SUPPORTED:
default:
return 0;
}
#else
return 1;

View file

@ -1,11 +1,12 @@
/* mge-mib.c - data to monitor MGE UPS SYSTEMS SNMP devices with NUT
*
* Copyright (C) 2002-2003
* Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
* J.W. Hoogervorst <jeroen@hoogervorst.net>
* Copyright (C)
* 2002-2012 Arnaud Quette <http://arnaud.quette.free.fr/contact.html>
* 2002-2003 J.W. Hoogervorst <jeroen@hoogervorst.net>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
* and MGE Office Protection Systems <http://www.mgeops.com>
* MGE Office Protection Systems <http://www.mgeops.com>
* Eaton <http://powerquality.eaton.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
@ -26,7 +27,7 @@
#include "mge-mib.h"
#define MGE_MIB_VERSION "0.4"
#define MGE_MIB_VERSION "0.5"
/* TODO:
* - MGE PDU MIB and sysOID (".1.3.6.1.4.1.705.2") */
@ -72,6 +73,73 @@ static info_lkp_t mge_overload_info[] = {
{ 0, "NULL" }
};
static info_lkp_t mge_replacebatt_info[] = {
{ 1, "RB" },
{ 2, "" },
{ 0, "NULL" }
};
static info_lkp_t mge_output_util_off_info[] = {
{ 1, "OFF" },
{ 2, "" },
{ 0, "NULL" }
};
static info_lkp_t mge_transfer_reason_info[] = {
{ 1, "" },
{ 2, "input voltage out of range" },
{ 3, "input frequency out of range" },
{ 4, "utility off" },
{ 0, "NULL" }
};
static info_lkp_t ietf_test_result_info[] = {
{ 1, "done and passed" },
{ 2, "done and warning" },
{ 3, "done and error" },
{ 4, "aborted" },
{ 5, "in progress" },
{ 6, "no test initiated" },
{ 0, "NULL" }
};
static info_lkp_t ietf_beeper_status_info[] = {
{ 1, "disabled" },
{ 2, "enabled" },
{ 3, "muted" },
{ 0, "NULL" }
};
static info_lkp_t ietf_yes_no_info[] = {
{ 1, "yes" },
{ 2, "no" },
{ 0, "NULL" }
};
/* FIXME: the below may introduce status redundancy, that needs to be
* adressed by the driver, as for usbhid-ups! */
static info_lkp_t ietf_power_source_info[] = {
{ 1, "" /* other */ },
{ 2, "OFF" /* none */ },
#if 0
{ 3, "OL" /* normal */ },
#endif
{ 4, "BYPASS" /* bypass */ },
{ 5, "OB" /* battery */ },
{ 6, "BOOST" /* booster */ },
{ 7, "TRIM" /* reducer */ },
{ 0, "NULL" }
};
/* Parameters default values */
#define STR_DEFAULT_ONDELAY "30" /* Delay between return of utility power */
/* and powering up of load, in seconds */
/* CAUTION: ondelay > offdelay */
#define DEFAULT_ONDELAY 30
#define STR_DEFAULT_OFFDELAY "20" /* Delay before power off, in seconds */
#define DEFAULT_OFFDELAY 20
#define MGE_NOTHING_VALUE 1
#define MGE_START_VALUE 2
#define MGE_STOP_VALUE 3
@ -82,80 +150,122 @@ static info_lkp_t mge_overload_info[] = {
static snmp_info_t mge_mib[] = {
/* UPS page */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "MGE UPS SYSTEMS", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".1.1.0", "Generic SNMP UPS", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "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 },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".7.10.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_overload_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, MGE_BASE_OID ".7.12.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_trim_info },
{ "ups.load", 0, 1, MGE_BASE_OID ".7.2.1.4.1", "", SU_OUTPUT_1, NULL },
{ "ups.L1.load", 0, 1, MGE_BASE_OID ".7.2.1.4.1", "", SU_OUTPUT_3, NULL },
{ "ups.L2.load", 0, 1, MGE_BASE_OID ".7.2.1.4.2", "", SU_OUTPUT_3, NULL },
{ "ups.L3.load", 0, 1, MGE_BASE_OID ".7.2.1.4.3", "", SU_OUTPUT_3, NULL },
/* { "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 3, MGE_OID_GRACEDELAY, "", SU_FLAG_OK, NULL }, */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Eaton", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.1.1.0", "Generic SNMP UPS", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.1.7.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.1.4.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.12.12.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.1", "", SU_OUTPUT_1, NULL },
{ "ups.beeper.status", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.2.1.33.1.9.8.0", "", 0, ietf_beeper_status_info },
{ "ups.L1.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.1", "", SU_OUTPUT_3, NULL },
{ "ups.L2.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.2", "", SU_OUTPUT_3, NULL },
{ "ups.L3.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.3", "", SU_OUTPUT_3, NULL },
{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.33.1.7.3.0", "", 0, ietf_test_result_info },
{ "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, "1.3.6.1.2.1.33.1.8.2.0", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, "1.3.6.1.2.1.33.1.8.3.0", STR_DEFAULT_ONDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.timer.shutdown", 0, 1, "1.3.6.1.2.1.33.1.8.2.0", "", SU_FLAG_OK, NULL },
{ "ups.timer.start", 0, 1, "1.3.6.1.2.1.33.1.8.3.0", "", SU_FLAG_OK, NULL },
{ "ups.timer.reboot", 0, 1, "1.3.6.1.2.1.33.1.8.4.0", "", SU_FLAG_OK, NULL },
{ "ups.start.auto", ST_FLAG_RW, 1, "1.3.6.1.2.1.33.1.8.5.0", "", SU_FLAG_OK, ietf_yes_no_info },
/* status data */
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.5.11.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_replacebatt_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.5.14.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_lowbatt_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.5.16.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_lowbatt_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_onbatt_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.4.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_bypass_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.7.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_output_util_off_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.8.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_boost_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.10.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_overload_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.12.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_trim_info },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.33.1.4.1.0", "", SU_STATUS_PWR | SU_FLAG_OK, ietf_power_source_info },
/* FIXME: Alarms
* - upsmgBatteryChargerFault (.1.3.6.1.4.1.705.1.5.15.0), yes (1), no (2)
* => Battery charger fail!
* - upsmgBatteryFaultBattery (.1.3.6.1.4.1.705.1.5.9.0), yes (1), no (2)
* => "Battery fault!" or?
* - upsmgOutputOverTemp (.1.3.6.1.4.1.705.1.7.11.0), yes (1), no (2)
* => "Temperature too high!"
* - upsmgOutputInverterOff (.1.3.6.1.4.1.705.1.7.9.0), yes (1), no (2)
* => "??"
* - upsmgInputBadStatus (.1.3.6.1.4.1.705.1.6.3.0), yes (1), no (2)
* => "bad volt or bad freq"
*/
/* Input page */
{ "input.phases", 0, 1.0, MGE_BASE_OID ".6.1.0", "", SU_FLAG_SETINT, NULL, &input_phases },
{ "input.voltage", 0, 0.1, MGE_BASE_OID ".6.2.1.2.1", "", SU_INPUT_1, NULL },
{ "input.L1-N.voltage", 0, 0.1, MGE_BASE_OID ".6.2.1.2.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage", 0, 0.1, MGE_BASE_OID ".6.2.1.2.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage", 0, 0.1, MGE_BASE_OID ".6.2.1.2.3", "", SU_INPUT_3, NULL },
{ "input.frequency", 0, 0.1, MGE_BASE_OID ".6.2.1.3.1", "", SU_INPUT_1, NULL },
{ "input.L1.frequency", 0, 0.1, MGE_BASE_OID ".6.2.1.3.1", "", SU_INPUT_3, NULL },
{ "input.L2.frequency", 0, 0.1, MGE_BASE_OID ".6.2.1.3.2", "", SU_INPUT_3, NULL },
{ "input.L3.frequency", 0, 0.1, MGE_BASE_OID ".6.2.1.3.3", "", SU_INPUT_3, NULL },
{ "input.voltage.minimum", 0, 0.1, MGE_BASE_OID ".6.2.1.4.1", "", SU_INPUT_1, NULL },
{ "input.L1-N.voltage.minimum", 0, 0.1, MGE_BASE_OID ".6.2.1.4.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage.minimum", 0, 0.1, MGE_BASE_OID ".6.2.1.4.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage.minimum", 0, 0.1, MGE_BASE_OID ".6.2.1.4.3", "", SU_INPUT_3, NULL },
{ "input.voltage.maximum", 0, 0.1, MGE_BASE_OID ".6.2.1.5.1", "", SU_INPUT_1, NULL },
{ "input.L1-N.voltage.maximum", 0, 0.1, MGE_BASE_OID ".6.2.1.5.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage.maximum", 0, 0.1, MGE_BASE_OID ".6.2.1.5.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage.maximum", 0, 0.1, MGE_BASE_OID ".6.2.1.5.3", "", SU_INPUT_3, NULL },
{ "input.current", 0, 0.1, MGE_BASE_OID ".6.2.1.6.1", "", SU_INPUT_1, NULL },
{ "input.L1.current", 0, 0.1, MGE_BASE_OID ".6.2.1.6.1", "", SU_INPUT_3, NULL },
{ "input.L2.current", 0, 0.1, MGE_BASE_OID ".6.2.1.6.2", "", SU_INPUT_3, NULL },
{ "input.L3.current", 0, 0.1, MGE_BASE_OID ".6.2.1.6.3", "", SU_INPUT_3, NULL },
{ "input.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.6.1.0", "", SU_FLAG_SETINT, NULL, &input_phases },
{ "input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL },
{ "input.L1-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.3", "", SU_INPUT_3, NULL },
{ "input.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.1", "", SU_INPUT_1, NULL },
{ "input.L1.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.1", "", SU_INPUT_3, NULL },
{ "input.L2.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.2", "", SU_INPUT_3, NULL },
{ "input.L3.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.3.3", "", SU_INPUT_3, NULL },
{ "input.voltage.minimum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.4.1", "", SU_INPUT_1, NULL },
{ "input.L1-N.voltage.minimum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.4.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage.minimum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.4.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage.minimum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.4.3", "", SU_INPUT_3, NULL },
{ "input.voltage.maximum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.5.1", "", SU_INPUT_1, NULL },
{ "input.L1-N.voltage.maximum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.5.1", "", SU_INPUT_3, NULL },
{ "input.L2-N.voltage.maximum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.5.2", "", SU_INPUT_3, NULL },
{ "input.L3-N.voltage.maximum", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.5.3", "", SU_INPUT_3, NULL },
{ "input.current", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.6.1", "", SU_INPUT_1, NULL },
{ "input.L1.current", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.6.1", "", SU_INPUT_3, NULL },
{ "input.L2.current", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.6.2", "", SU_INPUT_3, NULL },
{ "input.L3.current", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.6.3", "", SU_INPUT_3, NULL },
{ "input.transfer.reason", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.6.4.0", "", SU_FLAG_OK, mge_transfer_reason_info },
/* Output page */
{ "output.phases", 0, 1.0, MGE_BASE_OID ".7.1.0", "", SU_FLAG_SETINT, NULL, &output_phases },
{ "output.voltage", 0, 0.1, MGE_BASE_OID ".7.2.1.2.1", "", SU_OUTPUT_1, NULL },
{ "output.L1-N.voltage", 0, 0.1, MGE_BASE_OID ".7.2.1.2.1", "", SU_OUTPUT_3, NULL },
{ "output.L2-N.voltage", 0, 0.1, MGE_BASE_OID ".7.2.1.2.2", "", SU_OUTPUT_3, NULL },
{ "output.L3-N.voltage", 0, 0.1, MGE_BASE_OID ".7.2.1.2.3", "", SU_OUTPUT_3, NULL },
{ "output.frequency", 0, 0.1, MGE_BASE_OID ".7.2.1.3.1", "", SU_OUTPUT_1, NULL },
{ "output.L1.frequency", 0, 0.1, MGE_BASE_OID ".7.2.1.3.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.frequency", 0, 0.1, MGE_BASE_OID ".7.2.1.3.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.frequency", 0, 0.1, MGE_BASE_OID ".7.2.1.3.3", "", SU_OUTPUT_3, NULL },
{ "output.current", 0, 0.1, MGE_BASE_OID ".7.2.1.5.1", "", SU_OUTPUT_1, NULL },
{ "output.L1.current", 0, 0.1, MGE_BASE_OID ".7.2.1.5.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.current", 0, 0.1, MGE_BASE_OID ".7.2.1.5.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.current", 0, 0.1, MGE_BASE_OID ".7.2.1.5.3", "", SU_OUTPUT_3, NULL },
{ "output.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.7.1.0", "", SU_FLAG_SETINT, NULL, &output_phases },
{ "output.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.1", "", SU_OUTPUT_1, NULL },
{ "output.L1-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.1", "", SU_OUTPUT_3, NULL },
{ "output.L2-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.2", "", SU_OUTPUT_3, NULL },
{ "output.L3-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.3", "", SU_OUTPUT_3, NULL },
{ "output.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.3.1", "", SU_OUTPUT_1, NULL },
{ "output.L1.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.3.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.3.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.frequency", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.3.3", "", SU_OUTPUT_3, NULL },
{ "output.current", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.5.1", "", SU_OUTPUT_1, NULL },
{ "output.L1.current", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.5.1", "", SU_OUTPUT_3, NULL },
{ "output.L2.current", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.5.2", "", SU_OUTPUT_3, NULL },
{ "output.L3.current", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.5.3", "", SU_OUTPUT_3, NULL },
/* Battery page */
{ "battery.charge", 0, 1, MGE_BASE_OID ".5.2.0", "", SU_FLAG_OK, NULL },
{ "battery.runtime", 0, 1, MGE_BASE_OID ".5.1.0", "", SU_FLAG_OK, NULL },
{ "battery.charge.low", ST_FLAG_STRING | ST_FLAG_RW, 2, MGE_BASE_OID ".4.8.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
{ "battery.voltage", 0, 0.1, MGE_BASE_OID ".5.5.0", "", SU_FLAG_OK, NULL },
{ "battery.charge", 0, 1, ".1.3.6.1.4.1.705.1.5.2.0", "", SU_FLAG_OK, NULL },
{ "battery.runtime", 0, 1, ".1.3.6.1.4.1.705.1.5.1.0", "", SU_FLAG_OK, NULL },
{ "battery.runtime.low", 0, 1, ".1.3.6.1.4.1.705.1.4.7.0", "", SU_FLAG_OK, NULL },
{ "battery.charge.low", ST_FLAG_STRING | ST_FLAG_RW, 2, ".1.3.6.1.4.1.705.1.4.8.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
{ "battery.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.5.5.0", "", SU_FLAG_OK, NULL },
/* Ambient page: Environment Sensor (ref 66 846) */
{ "ambient.temperature", 0, 0.1, MGE_BASE_OID ".8.1.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
{ "ambient.humidity", 0, 0.1, MGE_BASE_OID ".8.2.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
{ "ambient.temperature", 0, 0.1, ".1.3.6.1.4.1.705.1.8.1.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
{ "ambient.humidity", 0, 0.1, ".1.3.6.1.4.1.705.1.8.2.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
/* Outlet page */
{ "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "Main Outlet", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
/* instant commands. */
{ "test.battery.start", 0, MGE_START_VALUE, MGE_BASE_OID ".10.4.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
/* { "load.off", 0, MGE_START_VALUE, MGE_BASE_OID ".9.1.1.6.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, */
/* { "load.on", 0, MGE_START_VALUE, MGE_BASE_OID ".9.1.1.3.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, */
/* { "shutdown.return", 0, MGE_START_VALUE, MGE_BASE_OID ".9.1.1.9.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, */
{ "test.battery.start", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.10.4.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
/* Also use IETF OIDs
* { "test.battery.stop", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.2", SU_TYPE_CMD, NULL },
* { "test.battery.start", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.3", SU_TYPE_CMD, NULL },
* { "test.battery.start.quick", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.4", SU_TYPE_CMD, NULL },
* { "test.battery.start.deep", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.5", SU_TYPE_CMD, NULL },
*/
/* { "load.off", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.9.1.1.6.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
* { "load.on", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.9.1.1.3.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
* { "shutdown.return", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.9.1.1.9.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
*/
/* IETF MIB fallback */
{ "beeper.disable", 0, 1, "1.3.6.1.2.1.33.1.9.8.0", "", SU_TYPE_CMD, NULL },
{ "beeper.enable", 0, 2, "1.3.6.1.2.1.33.1.9.8.0", "", SU_TYPE_CMD, NULL },
{ "beeper.mute", 0, 3, "1.3.6.1.2.1.33.1.9.8.0", "", SU_TYPE_CMD, NULL },
/* Use ST_FLAG_STRING to get default value from ->dfl instead of info_len */
{ "load.off.delay", 0, DEFAULT_OFFDELAY, "1.3.6.1.2.1.33.1.8.2.0", "", SU_TYPE_CMD, NULL },
{ "load.on.delay", 0, DEFAULT_ONDELAY, "1.3.6.1.2.1.33.1.8.3.0", "", SU_TYPE_CMD, NULL },
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }

View file

@ -1,6 +1,6 @@
/* mge-shut.c - monitor MGE UPS for NUT with SHUT protocol
*
* Copyright (C) 2002 - 2008
* Copyright (C) 2002 - 2012
* Arnaud Quette <arnaud.quette@gmail.com>
*
* Sponsored by MGE UPS SYSTEMS <http://opensource.mgeups.com/>
@ -37,7 +37,7 @@
/* --------------------------------------------------------------- */
#define DRIVER_NAME "Eaton / SHUT driver"
#define DRIVER_VERSION "0.69"
#define DRIVER_VERSION "0.70"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -524,7 +524,7 @@ int shut_wait_ack (void)
upsdebugx (2, "shut_wait_ack(): NACK received");
return -2;
}
else if ((c[0] & SHUT_PKT_LAST) == SHUT_TYPE_NOTIFY) {
else if ((c[0] & 0x0f) == SHUT_TYPE_NOTIFY) {
upsdebugx (2, "shut_wait_ack(): NOTIFY received");
return -3;
}
@ -835,8 +835,11 @@ int shut_packet_recv (u_char *Buf, int datalen)
shut_token_send(SHUT_OK);
if(Start[0]&SHUT_PKT_LAST) {
if ((Start[0]&SHUT_PKT_LAST) == SHUT_TYPE_NOTIFY) {
/* Check if there are more data to receive */
if((Start[0] & 0xf0) == SHUT_PKT_LAST) {
/* Check if it's a notification */
if ((Start[0] & 0x0f) == SHUT_TYPE_NOTIFY) {
/* TODO: process notification (dropped for now) */
upsdebugx (4, "=> notification");
datalen+=Pos;

View file

@ -287,10 +287,9 @@ void upsdrv_initinfo(void)
*p = '\0';
si_data1 = atoi(buf);
v = p+1;
p = strchr(v, ' ');
}
p = strchr(v, ' ');
if ( p != NULL ) {
*p = '\0';
si_data2 = atoi(v);

View file

@ -1,8 +1,9 @@
/* netvision-mib.c - data to monitor Socomec Sicon UPS equipped
* with Netvision WEB/SNMP card/external box with NUT
*
* Copyright (C) 2004
* Thanos Chatziathanassiou <tchatzi@arx.net>
* Copyright (C)
* 2004 Thanos Chatziathanassiou <tchatzi@arx.net>
* 2012 Manuel Bouyer <bouyer@NetBSD.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
@ -23,7 +24,7 @@
#include "netvision-mib.h"
#define NETVISION_MIB_VERSION "0.1"
#define NETVISION_MIB_VERSION "0.3"
#define NETVISION_SYSOID ".1.3.6.1.4.1.4555.1.1.1"
@ -37,11 +38,11 @@
/* UPS Battery */
#define NETVISION_OID_BATTERYSTATUS ".1.3.6.1.4.1.4555.1.1.1.1.2.1.0"
static info_lkp_t netvision_batt_info[] = {
{ 2, "" }, /* battery normal */
{ 3, "LB" }, /* battery low */
{ 4, "LB" }, /* battery depleted */
{ 2, "" }, /* battery normal */
{ 3, "LB" }, /* battery low */
{ 4, "LB" }, /* battery depleted */
{ 5, "DISCHRG" }, /* battery discharging */
{ 6, "RB" }, /* battery failure */
{ 6, "RB" }, /* battery failure */
{ 0, "NULL" }
};
@ -51,8 +52,12 @@ static info_lkp_t netvision_batt_info[] = {
#define NETVISION_OID_BATT_VOLTS ".1.3.6.1.4.1.4555.1.1.1.1.2.5.0"
#define NETVISION_OID_INPUT_NUM_LINES ".1.3.6.1.4.1.4555.1.1.1.1.3.1.0" /* 1phase or 3phase UPS input */
#define NETVISION_OID_INPUT_FREQ ".1.3.6.1.4.1.4555.1.1.1.1.3.2.0"
#define NETVISION_OID_OUTPUT_NUM_LINES ".1.3.6.1.4.1.4555.1.1.1.1.4.3.0" /* 1phase or 3phase UPS output */
#define NETVISION_OID_OUTPUT_FREQ ".1.3.6.1.4.1.4555.1.1.1.1.4.2.0"
#define NETVISION_OID_BYPASS_FREQ ".1.3.6.1.4.1.4555.1.1.1.1.5.1.0"
#define NETVISION_OID_BYPASS_NUM_LINES ".1.3.6.1.4.1.4555.1.1.1.1.5.2.0" /* 1phase or 3phase UPS input */
/*
three phase ups provide input/output/load for each phase
in case of one-phase output, only _P1 should be used
@ -62,29 +67,41 @@ static info_lkp_t netvision_batt_info[] = {
#define NETVISION_OID_OUT_CURRENT_P1 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3.1"
#define NETVISION_OID_OUT_LOAD_PCT_P1 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.4.1"
#define NETVISION_OID_IN_VOLTAGE_P1 ".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.5.1"
#define NETVISION_OID_IN_CURRENT_P1 ".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.3.1"
#define NETVISION_OID_BY_VOLTAGE_P1 ".1.3.6.1.4.1.4555.1.1.1.1.5.3.1.2.1"
#define NETVISION_OID_BY_CURRENT_P1 ".1.3.6.1.4.1.4555.1.1.1.1.5.3.1.3.1"
#define NETVISION_OID_OUT_VOLTAGE_P2 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.2.2"
#define NETVISION_OID_OUT_CURRENT_P2 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3.2"
#define NETVISION_OID_OUT_LOAD_PCT_P2 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.4.2"
#define NETVISION_OID_IN_VOLTAGE_P2 ".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.5.2"
#define NETVISION_OID_IN_CURRENT_P2 ".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.3.2"
#define NETVISION_OID_BY_VOLTAGE_P2 ".1.3.6.1.4.1.4555.1.1.1.1.5.3.1.2.2"
#define NETVISION_OID_BY_CURRENT_P2 ".1.3.6.1.4.1.4555.1.1.1.1.5.3.1.3.2"
#define NETVISION_OID_OUT_VOLTAGE_P3 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.2.3"
#define NETVISION_OID_OUT_CURRENT_P3 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3.3"
#define NETVISION_OID_OUT_LOAD_PCT_P3 ".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.4.3"
#define NETVISION_OID_IN_VOLTAGE_P3 ".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.5.3"
#define NETVISION_OID_IN_CURRENT_P3 ".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.3.3"
#define NETVISION_OID_BY_VOLTAGE_P3 ".1.3.6.1.4.1.4555.1.1.1.1.5.3.1.2.3"
#define NETVISION_OID_BY_CURRENT_P3 ".1.3.6.1.4.1.4555.1.1.1.1.5.3.1.3.3"
#define NETVISION_OID_OUTPUT_SOURCE ".1.3.6.1.4.1.4555.1.1.1.1.4.1.0"
#define NETVISION_OID_CONTROL_STATUS ".1.3.6.1.4.1.4555.1.1.1.1.8.1"
#define NETVISION_OID_CONTROL_SHUTDOWN_DELAY ".1.3.6.1.4.1.4555.1.1.1.1.8.2"
static info_lkp_t netvision_output_info[] = {
{ 1, "" }, /* output source other */
{ 2, "" }, /* output source none */
{ 3, "OL" }, /* output source normal */
{ 1, "" }, /* output source other */
{ 2, "" }, /* output source none */
{ 3, "OL" }, /* output source normal */
{ 4, "OL BYPASS" }, /* output source bypass */
{ 5, "OB" }, /* output source battery */
{ 5, "OB" }, /* output source battery */
{ 6, "OL BOOST" }, /* output source booster */
{ 7, "OL TRIM" }, /* output source reducer */
{ 8, "" }, /* output source standby */
{ 9, "" }, /* output source ecomode */
{ 8, "OL" }, /* output source standby */
{ 9, "" }, /* output source ecomode */
{ 0, "NULL" }
};
@ -104,12 +121,45 @@ static snmp_info_t netvision_mib[] = {
SU_FLAG_OK | SU_STATUS_PWR, &netvision_output_info[0] },
/* ups load */
{ "ups.load", 0, 1, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_FLAG_OK, NULL },
{ "ups.load", 0, 1, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_INPUT_1, NULL },
/*ups input,output voltage, output frquency phase 1 */
{ "input.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, 0, SU_FLAG_OK, NULL },
{ "output.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, 0, SU_FLAG_OK, NULL },
{ "output.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, 0, SU_FLAG_OK, NULL },
{ "input.phases", 0, 1.0, NETVISION_OID_INPUT_NUM_LINES, 0, SU_FLAG_SETINT, NULL, &input_phases },
{ "input.frequency", 0, 0.1, NETVISION_OID_INPUT_FREQ, 0, SU_FLAG_OK, NULL },
{ "input.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, 0, SU_INPUT_1, NULL },
{ "input.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P1, 0, SU_INPUT_1, NULL },
{ "input.L1-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, 0, SU_INPUT_3, NULL },
{ "input.L1.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P1, 0, SU_INPUT_3, NULL },
{ "input.L2-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P2, 0, SU_INPUT_3, NULL },
{ "input.L2.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P2, 0, SU_INPUT_3, NULL },
{ "input.L3-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P3, 0, SU_INPUT_3, NULL },
{ "input.L3.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P3, 0, SU_INPUT_3, NULL },
{ "output.phases", 0, 1.0, NETVISION_OID_OUTPUT_NUM_LINES, 0, SU_FLAG_SETINT, NULL, &output_phases },
{ "output.frequency", 0, 0.1, NETVISION_OID_OUTPUT_FREQ, 0, SU_FLAG_OK, NULL },
{ "output.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, 0, SU_OUTPUT_1, NULL },
{ "output.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, 0, SU_OUTPUT_1, NULL },
{ "output.load", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_OUTPUT_1, NULL },
{ "output.L1-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, 0, SU_OUTPUT_3, NULL },
{ "output.L1.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, 0, SU_OUTPUT_3, NULL },
{ "output.L1.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_OUTPUT_3, NULL },
{ "output.L2-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P2, 0, SU_OUTPUT_3, NULL },
{ "output.L2.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P2, 0, SU_OUTPUT_3, NULL },
{ "output.L2.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P2, 0, SU_OUTPUT_3, NULL },
{ "output.L3-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P3, 0, SU_OUTPUT_3, NULL },
{ "output.L3.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P3, 0, SU_OUTPUT_3, NULL },
{ "output.L3.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P3, 0, SU_OUTPUT_3, NULL },
{ "input.bypass.phases", 0, 1.0, NETVISION_OID_BYPASS_NUM_LINES, 0, SU_FLAG_SETINT, NULL, &bypass_phases },
{ "input.bypass.frequency", 0, 0.1, NETVISION_OID_BYPASS_FREQ, 0, SU_FLAG_OK, NULL },
{ "input.bypass.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P1, 0, SU_BYPASS_1, NULL },
{ "input.bypass.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P1, 0, SU_BYPASS_1, NULL },
{ "input.bypass.L1-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P1, 0, SU_BYPASS_3, NULL },
{ "input.bypass.L1.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P1, 0, SU_BYPASS_3, NULL },
{ "input.bypass.L2-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P2, 0, SU_BYPASS_3, NULL },
{ "input.bypass.L2.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P2, 0, SU_BYPASS_3, NULL },
{ "input.bypass.L3-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P3, 0, SU_BYPASS_3, NULL },
{ "input.bypass.L3.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P3, 0, SU_BYPASS_3, NULL },
/* battery info */
{ "battery.charge", 0, 1, NETVISION_OID_BATT_CHARGE, "", SU_FLAG_OK, NULL },

File diff suppressed because it is too large Load diff

View file

@ -1,19 +1,25 @@
/*
Copyright (C) 2002 Eric Lawson <elawson@inficad.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
/* oneac.h - Driver for Oneac UPS using the Advanced Interface.
*
* Copyright (C)
* 2003 by Eric Lawson <elawson@inficad.com>
* 2012 by Bill Elliot <bill@wreassoc.com>
*
* This program was sponsored by MGE UPS SYSTEMS, and now Eaton
*
* 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
*
*/
/*misc stuff*/
@ -22,22 +28,27 @@ Copyright (C) 2002 Eric Lawson <elawson@inficad.com>
#define COMMAND_END "\r\n"
#define DEFAULT_BAT_TEST_TIME "02"
/*Information requests*/
/*Information requests -- EG level */
#define GET_ALL '%'
#define GET_ALL_EXT_2 '^'
#define GET_ALL_EXT_1 '&'
#define GET_MFR 'M'
#define GET_FAMILY 'F'
#define GET_VERSION 'N'
#define GET_ON_INVERTER 'G'
#define GET_BATLOW 'K'
#define GET_STATUS 'X'
#define GET_LAST_XFER 'W'
#define GET_ALL '%'
#define GETALL_EG_RESP_SIZE 22
#define GETALL_RESP_SIZE 48
#define GET_MFR 'M'
#define GET_FAMILY 'F'
#define GET_VERSION 'N'
#define GET_ON_INVERTER 'G'
#define GET_BATLOW 'K'
#define GET_STATUS 'X'
#define GET_LAST_XFER 'W'
#define GET_INVERTER_RDY 'I'
#define GET_TEST_TIME 'Q'
#define GET_NOM_FREQ 'H'
#define GET_NOM_VOLTAGE 'V'
#define GET_SHUTDOWN 'O'
#define GET_TEST_TIME 'Q'
#define GET_NOM_FREQ 'H'
/*Information requests -- ON level (EG plus these) */
#define GET_NOM_VOLTAGE 'V'
#define GET_DISPLAY_CODE 'D'
#define GET_CONDITION_CODE 'C'
#define GET_PERCENT_LOAD 'P'
@ -45,48 +56,124 @@ Copyright (C) 2002 Eric Lawson <elawson@inficad.com>
#define GET_INPUT_LINE_VOLT 'L'
#define GET_MIN_INPUT_VOLT 'A'
#define GET_MAX_INPUT_VOLT 'E'
#define GET_OUTPUT_VOLT 'S'
#define GET_BOOSTING 'B'
#define GET_OUTPUT_VOLT 'S'
#define GET_BOOSTING 'B'
/*Control functions*/
#define SIM_PWR_FAIL "\x02\x15" /*^B^U 15 second battery test*/
#define SHUTDOWN "\x0f\x06" /*^O^F (a letter O)*/
#define GET_SHUTDOWN_RESP_SIZE 3
/*Information requests -- OZ/OB level (ON plus these) */
#define GETX_ALL_1 '&'
#define GETX_ALL1_RESP_SIZE 79
#define GETX_OUTSOURCE 'a'
#define GETX_FRONTDISP 'b'
#define GETX_INT_TEMP 'g' /* Degrees C */
#define GETX_BATT_STAT 'h' /* Unknown(1), Normal, Low, Depleted */
#define GETX_BATT_CHG_PERC 'i' /* 0 - 100 */
#define GETX_EST_MIN_REM 'j'
#define GETX_ONBATT_TIME 'k' /* In seconds */
#define GETX_BATT_VOLTS 'l' /* Read as xxx.x */
#define GETX_INP_FREQ 'p'
#define GETX_MIN_IN_VOLTS 'q'
#define GETX_MAX_IN_VOLTS 'r'
#define GETX_IN_VOLTS 's'
#define GETX_IN_WATTS 'u'
#define GETX_OUT_VOLTS 'v'
#define GETX_OUT_WATTS 'x'
#define GETX_OUT_LOAD_PERC 'y'
#define GETX_OUT_FREQ 'z'
#define GETX_ALL_2 '^'
#define GETX_ALL2_RESP_SIZE 92
#define GETX_MODEL 'J'
#define GETX_FW_REV 'U' /* Read as xx.x */
#define GETX_SERIAL_NUM 'Y'
#define GETX_MAN_DATE '$' /* yymmdd */
#define GETX_BATT_REPLACED '+' /* yymmdd */
#define GETX_DATE_RESP_SIZE 6
#define GETX_UNIT_KVA '''' /* Read as xxx.xx */
#define GETX_UNIT_WATTS "''" /* 2-character string request */
#define GETX_LOW_OUT_ALLOW '[' /* Tap up or inverter at this point */
#define GETX_HI_OUT_ALLOW ']' /* Tap down or inverter at this point */
#define GETX_NOTIFY_DELAY ',' /* Secs of delay for power fail alert */
#define GETX_ALLOW_RESP_SIZE 3
#define GETX_LOW_BATT_TIME '"' /* Low batt alarm at xx minutes */
#define GETX_RESTART_DLY '_' /* Restart delay */
#define GETX_RESTART_COUNT "_?" /* Returns actual counter value */
#define GETX_RSTRT_RESP_SIZE 4
/*Other requests */
#define GETX_SHUTDOWN '}' /* Shutdown counter (..... for none) */
#define GETX_SHUTDOWN_RESP_SIZE 5
#define GETX_BATT_TEST_DAYS "\x02\x1A" /* Days between battery tests */
#define GETX_BUZZER_WHAT "\x07?" /* What is buzzer state */
#define GETX_AUTO_START "<?" /* Restart type */
#define GETX_ALLOW_RANGE "[=?" /* Responds with min,max,spread */
#define GETX_RANGE_RESP_SIZE 10
/*Control functions (All levels) */
#define SIM_PWR_FAIL "\x02\x15" /*^B^U 15 second battery test*/
#define SHUTDOWN "\x0f\x06" /*^O^F (a letter O)*/
#define RESET_MIN_MAX 'R'
#define BAT_TEST_PREFIX "\x02" /*needs 2 more chars. minutes*/
#define DELAYED_SHUTDOWN_PREFIX 'Z' /*needs 3 more chars. seconds */
#define BAT_TEST_PREFIX "\x02" /*^B needs 2 more chars. minutes*/
#define DELAYED_SHUTDOWN_PREFIX 'Z' /* EG/ON needs 3 more chars. seconds */
/* ON96 needs 1 to 5 chars. of seconds */
/*Control functions (ON96) */
#define TEST_INDICATORS "\x09\x14" /*^I^T flashed LEDs and beeper */
#define TEST_BATT_DEEP "\x02\x04" /*^B^D runs until low batt */
#define TEST_BATT_DEAD "\x02\x12" /*^B^R run until battery dead */
#define TEST_ABORT '\x01' /* Abort any running test */
#define REBOOT_LOAD "\x12@" /*^R@xxx needs 3 chars of secs */
#define SETX_BUZZER_PREFIX '\x07' /*^G needs one more character */
#define SETX_OUT_ALLOW "[=" /* [=lll,hhh */
#define SETX_BUZZER_OFF "\x070" /*^G0 disables buzzer */
#define SETX_BUZZER_ON "\x071" /*^G1 enables buzzer */
#define SETX_BUZZER_MUTE "\x072" /*^G2 mutes current conditions */
#define SETX_BATT_TEST_DAYS "\x02\x1A=" /* Needs 0 - 129 days, 0 is disable */
#define SETX_LOWBATT_AT "\"=" /* Low batt at (max 99) */
#define SETX_RESTART_DELAY "_=" /* _=xxxx, up to 9999 seconds */
#define SETX_AUTO_START '<' /* <0 / <1 for auto / manual */
#define SETX_BATTERY_DATE "+=" /* Set battery replace date */
#define DONT_UNDERSTAND '*'
#define CANT_COMPLY '#'
#define NO_VALUE_YET '.'
#define CANT_COMPLY '#'
#define NO_VALUE_YET '.'
#define HIGH_COUNT '+' /* Shutdown counter > 999 on OZ */
#define MIN_ALLOW_FW "1.9" /* At or above provides output allow range */
/*responses*/
#define MFGR "ONEAC"
#define FAMILY_ON "ON"
#define FAMILY_ON_EXT "OZ"
#define FAMILY_EG "EG"
#define YES 'Y'
#define NO 'N'
#define NORMAL '@'
#define ON_BAT_LOW_LINE 'A'
#define ON_BAT_HI_LINE 'Q'
#define LO_BAT_LOW_LINE 'C'
#define LO_BAT_HI_LINE 'S'
#define TOO_HOT '`'
#define FIX_ME 'D'
#define BAD_BAT 'H'
#define V230AC '2'
#define V120AC '1'
#define XFER_BLACKOUT 'B'
#define XFER_LOW_VOLT 'L'
#define XFER_HI_VOLT 'H'
#define FAMILY_EG "EG" /* 3 tri-color LEDs and big ON/OFF on front */
#define FAMILY_ON "ON" /* Serial port avail only on interface card */
#define FAMILY_OZ "OZ" /* DB-25 std., plus interface slot */
#define FAMILY_OB "OB" /* Lg. cab with removable modules */
#define FAMILY_SIZE 2
#define YES 'Y'
#define NO 'N'
#define V230AC '2'
#define V120AC '1'
#define XFER_BLACKOUT 'B'
#define XFER_LOW_VOLT 'L'
#define XFER_HI_VOLT 'H'
#define BUZZER_ENABLED '1'
#define BUZZER_DISABLED '0'
#define BUZZER_MUTED '2'
/*front panel alarm codes*/
#define CODE_BREAKER_OPEN "c1" /*input circuit breaker open*/
#define CODE_BAT_FUSE_OPEN "c2" /*battery not connected. Open fuse?*/
#define CODE_TOO_HOT "c3" /*UPS too hot*/
#define CODE_CHARGING "c4" /*recharging battery pack*/
#define CODE_LOW_BAT_CAP "c5" /*batteries getting too old*/
#define CODE_OVERLOAD "c8" /*"slight" overload*/
#define CODE_GROSS_OVLE "c9" /*gross overload 1 minute to power off*/
#define CODE_BREAKER_OPEN "c1" /*input circuit breaker open*/
#define CODE_BAT_FUSE_OPEN "c2" /*battery not connected. Open fuse?*/
#define CODE_TOO_HOT "c3" /*UPS too hot*/
#define CODE_CHARGING "c4" /*recharging battery pack*/
#define CODE_LOW_BAT_CAP "c5" /*batteries getting too old*/
#define CODE_OVERLOAD "c8" /*"slight" overload*/
#define CODE_GROSS_OVLE "c9" /*gross overload 1 minute to power off*/
#define CODE_CHRGR_FUSE_OPEN "u1" /*battery charger fuse probably open*/

View file

@ -540,13 +540,12 @@ static void getbaseinfo(void)
unsigned char temp[256];
unsigned char Pacote[37];
int tam, i, j=0;
time_t *tmt;
time_t tmt;
struct tm *now;
const char *Model;
tmt = ( time_t * ) malloc( sizeof( time_t ) );
time( tmt );
now = localtime( tmt );
time( &tmt );
now = localtime( &tmt );
dian = now->tm_mday;
mesn = now->tm_mon+1;
anon = now->tm_year+1900;

View file

@ -3,7 +3,7 @@
* Based on NetSNMP API (Simple Network Management Protocol V1-2)
*
* Copyright (C)
* 2002 - 2011 Arnaud Quette <arnaud.quette@free.fr>
* 2002 - 2012 Arnaud Quette <arnaud.quette@free.fr>
* 2002 - 2006 Dmitry Frolov <frolov@riss-telecom.ru>
* J.W. Hoogervorst <jeroen@hoogervorst.net>
* Niels Baggesen <niels@baggesen.net>
@ -47,6 +47,11 @@
#include "cyberpower-mib.h"
#include "ietf-mib.h"
/* Address API change */
#ifndef usmAESPrivProtocol
#define usmAESPrivProtocol usmAES128PrivProtocol
#endif
static mib2nut_info_t *mib2nut[] = {
&apc,
&mge,
@ -70,6 +75,10 @@ static mib2nut_info_t *mib2nut[] = {
NULL
};
struct snmp_session g_snmp_sess, *g_snmp_sess_p;
const char *OID_pwr_status;
int g_pwr_battery;
int pollfreq; /* polling frequency */
int input_phases, output_phases, bypass_phases;
/* pointer to the Snmp2Nut lookup table */
@ -82,7 +91,7 @@ const char *mibvers;
static void disable_transfer_oids(void);
#define DRIVER_NAME "Generic SNMP UPS driver"
#define DRIVER_VERSION "0.58"
#define DRIVER_VERSION "0.66"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -122,13 +131,18 @@ void upsdrv_initinfo(void)
dstate_setinfo("driver.version.internal", "%s", version);
/* add instant commands to the info database.
* outlet commands are processed during initial walk */
* outlet commands are processed later, during initial walk */
for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ; su_info_p++)
{
su_info_p->flags |= SU_FLAG_OK;
if ((SU_TYPE(su_info_p) == SU_TYPE_CMD)
&& !(su_info_p->flags & SU_OUTLET))
dstate_addcmd(su_info_p->info_type);
&& !(su_info_p->flags & SU_OUTLET)) {
/* first check that this OID actually exists */
if (nut_snmp_get(su_info_p->OID) != NULL) {
dstate_addcmd(su_info_p->info_type);
upsdebugx(1, "upsdrv_initinfo(): adding command '%s'", su_info_p->info_type);
}
}
}
if (testvar("notransferoids"))
@ -150,7 +164,7 @@ void upsdrv_updateinfo(void)
upsdebugx(1,"SNMP UPS driver : entering upsdrv_updateinfo()");
/* only update every pollfreq */
/* FIXME: update status (SU_STATUS_*), à la usbhid-ups, in between */
/* FIXME: only update status (SU_STATUS_*), à la usbhid-ups, in between */
if (time(NULL) > (lastpoll + pollfreq)) {
status_init();
@ -178,7 +192,28 @@ void upsdrv_shutdown(void)
never send this command to the UPS. This is not an error,
but a limitation of the interface used.
*/
fatalx(EXIT_SUCCESS, "SNMP doesn't support shutdown in system halt script");
upsdebugx(1, "upsdrv_shutdown...");
/* Try to shutdown with delay */
if (su_instcmd("shutdown.return", NULL) == STAT_INSTCMD_HANDLED) {
/* Shutdown successful */
return;
}
/* If the above doesn't work, try shutdown.reboot */
if (su_instcmd("shutdown.reboot", NULL) == STAT_INSTCMD_HANDLED) {
/* Shutdown successful */
return;
}
/* If the above doesn't work, try load.off.delay */
if (su_instcmd("load.off.delay", NULL) == STAT_INSTCMD_HANDLED) {
/* Shutdown successful */
return;
}
fatalx(EXIT_FAILURE, "Shutdown failed!");
}
void upsdrv_help(void)
@ -251,6 +286,22 @@ void upsdrv_initups(void)
else
fatalx(EXIT_FAILURE, "%s MIB wasn't found on %s", mibs, g_snmp_sess.peername);
/* FIXME: "No supported device detected" */
if (su_find_info("load.off.delay")) {
/* Adds default with a delay value of '0' (= immediate) */
dstate_addcmd("load.off");
}
if (su_find_info("load.on.delay")) {
/* Adds default with a delay value of '0' (= immediate) */
dstate_addcmd("load.on");
}
if (su_find_info("load.off.delay") && su_find_info("load.on.delay")) {
/* Add composite instcmds (require setting multiple OID values) */
dstate_addcmd("shutdown.return");
dstate_addcmd("shutdown.stayoff");
}
}
void upsdrv_cleanup(void)
@ -811,8 +862,9 @@ mib2nut_info_t *match_sysoid()
}
}
/* Yell all to call for user report */
upslogx(LOG_ERR, "No matching MIB found for sysOID '%s'! " \
"Please report it to NUT developers, with the 'mib' paramater for your devices",
upslogx(LOG_ERR, "No matching MIB found for sysOID '%s'!\n" \
"Please report it to NUT developers, with an 'upsc' output for your device.\n" \
"Going back to the classic MIB detection method.",
sysOID_buf);
}
else
@ -879,7 +931,7 @@ bool_t load_mib2nut(const char *mib)
}
/* find the OID value matching that INFO_* value */
long su_find_valinfo(info_lkp_t *oid2info, char* value)
long su_find_valinfo(info_lkp_t *oid2info, const char* value)
{
info_lkp_t *info_lkp;
@ -1334,6 +1386,7 @@ int su_setvar(const char *varname, const char *val)
snmp_info_t *su_info_p = NULL;
bool_t status;
int retval = STAT_SET_FAILED;
int value = -1;
upsdebugx(2, "entering su_setvar(%s, %s)", varname, val);
@ -1410,7 +1463,15 @@ int su_setvar(const char *varname, const char *val)
if (su_info_p->info_flags & ST_FLAG_STRING) {
status = nut_snmp_set_str(su_info_p->OID, val);
} else {
status = nut_snmp_set_int(su_info_p->OID, strtol(val, NULL, 0));
/* non string data may imply a value lookup */
if (su_info_p->oid2info) {
value = su_find_valinfo(su_info_p->oid2info, val);
}
else {
value = strtol(val, NULL, 0);
}
/* Actually apply the new value */
status = nut_snmp_set_int(su_info_p->OID, value);
}
if (status == FALSE)
@ -1486,7 +1547,50 @@ int su_instcmd(const char *cmdname, const char *extradata)
}
}
/* Sanity check */
if (!su_info_p || !su_info_p->info_type || !(su_info_p->flags & SU_FLAG_OK)) {
/* Check for composite commands */
if (!strcasecmp(cmdname, "load.on")) {
return su_instcmd("load.on.delay", "0");
}
if (!strcasecmp(cmdname, "load.off")) {
return su_instcmd("load.off.delay", "0");
}
if (!strcasecmp(cmdname, "shutdown.return")) {
int ret;
/* Ensure "ups.start.auto" is set to "yes", if supported */
if (dstate_getinfo("ups.start.auto")) {
su_setvar("ups.start.auto", "yes");
}
ret = su_instcmd("load.on.delay", dstate_getinfo("ups.delay.start"));
if (ret != STAT_INSTCMD_HANDLED) {
return ret;
}
return su_instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown"));
}
if (!strcasecmp(cmdname, "shutdown.stayoff")) {
int ret;
/* Ensure "ups.start.auto" is set to "no", if supported */
if (dstate_getinfo("ups.start.auto")) {
su_setvar("ups.start.auto", "no");
}
ret = su_instcmd("load.on.delay", "-1");
if (ret != STAT_INSTCMD_HANDLED) {
return ret;
}
return su_instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown"));
}
upsdebugx(2, "su_instcmd: %s unavailable", cmdname);
if (!strncmp(cmdname, "outlet", 6))
@ -1495,7 +1599,7 @@ int su_instcmd(const char *cmdname, const char *extradata)
return STAT_INSTCMD_UNKNOWN;
}
/* set value. */
/* set value, using the provided one, or the default one otherwise */
if (su_info_p->info_flags & ST_FLAG_STRING) {
status = nut_snmp_set_str(su_info_p->OID, extradata ? extradata : su_info_p->dfl);
} else {
@ -1515,54 +1619,6 @@ int su_instcmd(const char *cmdname, const char *extradata)
return retval;
}
/* TODO: complete rewrite */
void su_shutdown_ups(void)
{
int sdtype = 0;
long pwr_status;
if (nut_snmp_get_int(OID_pwr_status, &pwr_status) == FALSE)
fatalx(EXIT_FAILURE, "cannot determine UPS status");
if (testvar(SU_VAR_SDTYPE))
sdtype = atoi(getval(SU_VAR_SDTYPE));
/* logic from newapc.c */
switch (sdtype) {
case 3: /* shutdown with grace period */
upslogx(LOG_INFO, "sending delayed power off command to UPS");
su_instcmd("shutdown.stayoff", "0");
break;
case 2: /* instant shutdown */
upslogx(LOG_INFO, "sending power off command to UPS");
su_instcmd("load.off", "0");
break;
case 1:
/* Send a combined set of shutdown commands which can work better */
/* if the UPS gets power during shutdown process */
/* Specifically it sends both the soft shutdown 'S' */
/* and the powerdown after grace period - '@000' commands */
/* upslogx(LOG_INFO, "UPS - sending shutdown/powerdown");
if (pwr_status == g_pwr_battery)
su_ups_instcmd(CMD_SOFTDOWN, 0, 0);
su_ups_instcmd(CMD_SDRET, 0, 0);
break;
*/
default:
/* if on battery... */
/* if (pwr_status == su_find_valinfo(info_lkp_t *oid2info, "OB")) {
upslogx(LOG_INFO,
"UPS is on battery, sending shutdown command...");
su_ups_instcmd(CMD_SOFTDOWN, 0, 0);
} else {
upslogx(LOG_INFO, "UPS is online, sending shutdown+return command...");
su_ups_instcmd(CMD_SDRET, 0, 0);
}
*/
break;
}
}
/* FIXME: the below functions can be removed since these were for loading
* the mib2nut information from a file instead of the .h definitions... */
/* return 1 if usable, 0 if not */

View file

@ -78,7 +78,7 @@ for each OID request we made), instead of sending many small packets
/* Force numeric OIDs by disabling MIB loading */
#define DISABLE_MIB_LOADING 1
/* Parameters default values */
#define DEFAULT_POLLFREQ 30 /* in seconds */
/* use explicit booleans */
@ -171,7 +171,6 @@ typedef struct {
#define SU_VAR_VERSION "snmp_version"
#define SU_VAR_MIBS "mibs"
#define SU_VAR_POLLFREQ "pollfreq"
#define SU_VAR_SDTYPE "sdtype"
/* SNMP v3 related parameters */
#define SU_VAR_SECLEVEL "secLevel"
#define SU_VAR_SECNAME "secName"
@ -234,7 +233,7 @@ bool_t su_ups_get(snmp_info_t *su_info_p);
bool_t load_mib2nut(const char *mib);
const char *su_find_infoval(info_lkp_t *oid2info, long value);
long su_find_valinfo(info_lkp_t *oid2info, char* value);
long su_find_valinfo(info_lkp_t *oid2info, const char* value);
int su_setvar(const char *varname, const char *val);
int su_instcmd(const char *cmdname, const char *extradata);
@ -242,10 +241,10 @@ void su_shutdown_ups(void);
void read_mibconf(char *mib);
struct snmp_session g_snmp_sess, *g_snmp_sess_p;
const char *OID_pwr_status;
int g_pwr_battery;
int pollfreq; /* polling frequency */
extern struct snmp_session g_snmp_sess, *g_snmp_sess_p;
extern const char *OID_pwr_status;
extern int g_pwr_battery;
extern int pollfreq; /* polling frequency */
extern int input_phases, output_phases, bypass_phases;
#endif /* SNMP_UPS_H */

View file

@ -792,11 +792,10 @@ static void getbaseinfo(void)
unsigned char Pacote[25];
int i, i1=0, i2=0, j=0, tam, tpac=25;
time_t *tmt;
time_t tmt;
struct tm *now;
tmt = ( time_t * ) malloc( sizeof( time_t ) );
time( tmt );
now = localtime( tmt );
time( &tmt );
now = localtime( &tmt );
dian = now->tm_mday;
mesn = now->tm_mon+1;
anon = now->tm_year+1900;
@ -956,11 +955,10 @@ static void getupdateinfo(void)
int tam, isday, hourn, minn;
/* time update and programable shutdown block */
time_t *tmt;
time_t tmt;
struct tm *now;
tmt = ( time_t * ) malloc( sizeof( time_t ) );
time( tmt );
now = localtime( tmt );
time( &tmt );
now = localtime( &tmt );
hourn = now->tm_hour;
minn = now->tm_min;
weekn = now->tm_wday;

View file

@ -1,7 +1,7 @@
/* tripplite-hid.c - data to monitor Tripp Lite USB/HID devices with NUT
*
* Copyright (C)
* 2003 - 2005 Arnaud Quette <arnaud.quette@free.fr>
* 2003 - 2012 Arnaud Quette <arnaud.quette@free.fr>
* 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net>
* 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
*
@ -29,7 +29,7 @@
#include "tripplite-hid.h"
#include "usb-common.h"
#define TRIPPLITE_HID_VERSION "TrippLite HID 0.6"
#define TRIPPLITE_HID_VERSION "TrippLite HID 0.8"
/* FIXME: experimental flag to be put in upsdrv_info */
@ -109,6 +109,16 @@ static usb_device_id_t tripplite_usb_device_table[] = {
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4007), battery_scale_1dot0 },
{ USB_DEVICE(TRIPPLITE_VENDORID, 0x4008), battery_scale_1dot0 },
/* e.g. ? */
{ USB_DEVICE(HP_VENDORID, 0x0001), battery_scale_1dot0 },
/* HP R1500 G2 and G3 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1fe0), battery_scale_1dot0 },
/* HP T750 G2 */
{ USB_DEVICE(HP_VENDORID, 0x1fe1), battery_scale_1dot0 },
/* e.g. ? */
{ USB_DEVICE(HP_VENDORID, 0x1fe2), battery_scale_1dot0 },
/* HP T1500 G3 */
{ USB_DEVICE(HP_VENDORID, 0x1fe3), battery_scale_1dot0 },
/* HP T750 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1f06), battery_scale_1dot0 },
/* HP T1000 INTL */
@ -117,10 +127,6 @@ static usb_device_id_t tripplite_usb_device_table[] = {
{ USB_DEVICE(HP_VENDORID, 0x1f09), battery_scale_1dot0 },
/* HP R/T 2200 INTL (like SMART2200RMXL2U) */
{ USB_DEVICE(HP_VENDORID, 0x1f0a), battery_scale_1dot0 },
/* HP R1500 G2 INTL */
{ USB_DEVICE(HP_VENDORID, 0x1fe0), battery_scale_1dot0 },
/* HP T750 G2 */
{ USB_DEVICE(HP_VENDORID, 0x1fe1), battery_scale_1dot0 },
/* Terminating entry */
{ -1, -1, NULL }
@ -174,19 +180,41 @@ static info_lkp_t tripplite_battvolt[] = {
/* TRIPPLITE usage table */
static usage_lkp_t tripplite_usage_lkp[] = {
/* currently unknown:
ffff0010, 00ff0001, ffff007d, ffff00c0, ffff00c1, ffff00c2,
00ff0001, ffff007d, ffff00c0, ffff00c1, ffff00c2,
ffff00c3, ffff00c4, ffff00c5, ffff00d2, ffff0091, ffff00c7 */
{ "TLCustom", 0xffff0010 },
{ "TLDelayBeforeStartup", 0xffff0056 }, /* in minutes */
{ "TLLowVoltageTransferMax", 0xffff0057 },
{ "TLLowVoltageTransferMin", 0xffff0058 },
{ "TLHighVoltageTransferMax", 0xffff0059 },
{ "TLHighVoltageTransferMin", 0xffff005a },
/* Outlet state:
* 1- On/Closed
* 2- Off/Open
* 3- On with pending off
* 4- Off with pending on
* 5- Unknown
* 6- Resolved/Unknown
* 7- Failed and Closed
* 8- Failed and Open */
{ "OutletState", 0xffff007a },
{ "OutletCount", 0xffff007b }, /* Number of load segments */
{ "UPSFirmwareVersion", 0xffff007c },
{ "CommunicationProtocolVersion", 0xffff007d }, /* HID protocol version */
{ "CommunicationVersion", 0xffff007e }, /* USB firmware version */
{ "iUPSPartNumber", 0xffff007f }, /* String index to Part Number */
{ "AutoOnDelay", 0xffff0080 }, /* '0' (no delay) to 'n' (delay in seconds) */
{ "TLWatchdog", 0xffff0092 },
{ "TLOutletsAvailableMask", 0xffff0095 },
{ "TLOutletsStatusMask", 0xffff0096 },
/* it looks like Tripp Lite confused pages 0x84 and 0x85 for the
following 4 items, on some OMNI1000LCD devices. */
{ "TLCharging", 0x00840044 }, /* conflicts with HID spec! */
{ "TLDischarging", 0x00840045 }, /* conflicts with HID spec! */
/* conflicts with HID spec (and HP implementation) for TrippLite!
* Refer to tripplite_discharging_info */
{ "TLDischarging", 0x00840045 },
{ "TLNeedReplacement", 0x0084004b },
{ "TLACPresent", 0x008400d0 },
{ NULL, 0 }
@ -209,19 +237,19 @@ static hid_info_t tripplite_hid2nut[] = {
/* unmapped variables - meaning unknown */
{ "UPS.Flow.0xffff0097", 0, 0, "UPS.Flow.0xffff0097", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff0075", 0, 0, "UPS.0xffff0010.[1].0xffff0075", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff0076", 0, 0, "UPS.0xffff0010.[1].0xffff0076", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff007c", 0, 0, "UPS.0xffff0010.[1].0xffff007c", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff007d", 0, 0, "UPS.0xffff0010.[1].0xffff007d", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e0", 0, 0, "UPS.0xffff0010.[1].0xffff00e0", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e1", 0, 0, "UPS.0xffff0010.[1].0xffff00e1", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e2", 0, 0, "UPS.0xffff0010.[1].0xffff00e2", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e3", 0, 0, "UPS.0xffff0010.[1].0xffff00e3", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e4", 0, 0, "UPS.0xffff0010.[1].0xffff00e4", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e5", 0, 0, "UPS.0xffff0010.[1].0xffff00e5", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e6", 0, 0, "UPS.0xffff0010.[1].0xffff00e6", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e7", 0, 0, "UPS.0xffff0010.[1].0xffff00e7", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0010.[1].0xffff00e8", 0, 0, "UPS.0xffff0010.[1].0xffff00e8", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff0075", 0, 0, "UPS.TLCustom.[1].0xffff0075", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff0076", 0, 0, "UPS.TLCustom.[1].0xffff0076", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff007c", 0, 0, "UPS.TLCustom.[1].0xffff007c", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff007d", 0, 0, "UPS.TLCustom.[1].0xffff007d", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e0", 0, 0, "UPS.TLCustom.[1].0xffff00e0", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e1", 0, 0, "UPS.TLCustom.[1].0xffff00e1", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e2", 0, 0, "UPS.TLCustom.[1].0xffff00e2", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e3", 0, 0, "UPS.TLCustom.[1].0xffff00e3", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e4", 0, 0, "UPS.TLCustom.[1].0xffff00e4", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e5", 0, 0, "UPS.TLCustom.[1].0xffff00e5", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e6", 0, 0, "UPS.TLCustom.[1].0xffff00e6", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e7", 0, 0, "UPS.TLCustom.[1].0xffff00e7", NULL, "%.0f", 0, NULL },
{ "UPS.TLCustom.[1].0xffff00e8", 0, 0, "UPS.TLCustom.[1].0xffff00e8", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0015.[1].0xffff00c0", 0, 0, "UPS.0xffff0015.[1].0xffff00c0", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0015.[1].0xffff00c1", 0, 0, "UPS.0xffff0015.[1].0xffff00c1", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0015.[1].0xffff00c2", 0, 0, "UPS.0xffff0015.[1].0xffff00c2", NULL, "%.0f", 0, NULL },
@ -231,7 +259,6 @@ static hid_info_t tripplite_hid2nut[] = {
{ "UPS.0xffff0015.[1].0xffff00d2", 0, 0, "UPS.0xffff0015.[1].0xffff00d2", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0015.[1].0xffff00d3", 0, 0, "UPS.0xffff0015.[1].0xffff00d3", NULL, "%.0f", 0, NULL },
{ "UPS.0xffff0015.[1].0xffff00d6", 0, 0, "UPS.0xffff0015.[1].0xffff00d6", NULL, "%.0f", 0, NULL },
{ "UPS.OutletSystem.Outlet.0xffff0056", 0, 0, "UPS.OutletSystem.Outlet.0xffff0056", NULL, "%.0f", 0, NULL },
{ "UPS.OutletSystem.Outlet.0xffff0081", 0, 0, "UPS.OutletSystem.Outlet.0xffff0081", NULL, "%.0f", 0, NULL },
{ "UPS.OutletSystem.Outlet.0xffff0091", 0, 0, "UPS.OutletSystem.Outlet.0xffff0091", NULL, "%.0f", 0, NULL },
{ "UPS.OutletSystem.Outlet.0xffff0093", 0, 0, "UPS.OutletSystem.Outlet.0xffff0093", NULL, "%.0f", 0, NULL },
@ -249,6 +276,9 @@ static hid_info_t tripplite_hid2nut[] = {
#endif /* USBHID_UPS_TRIPPLITE_DEBUG */
/* Device page */
{ "device.part", 0, 0, "UPS.TLCustom.[1].iUPSPartNumber", NULL, "%.0f", 0, stringid_conversion },
/* Battery page */
{ "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL },
{ "battery.charge", 0, 0, "UPS.BatterySystem.Battery.RemainingCapacity", NULL, "%.0f", 0, NULL },
@ -262,8 +292,16 @@ static hid_info_t tripplite_hid2nut[] = {
/* UPS page */
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.OutletSystem.Outlet.TLDelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
/* FIXME
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 6, "UPS.TLCustom.[1].TLDelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.timer.start", 0, 0, "UPS.TLCustom.[1].DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
- what's the right notion behind this one?
{ "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 6, "UPS.TLCustom.[1].AutoOnDelay", NULL, DEFAULT_ONDELAY, 0, NULL},
*/
{ "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_FLAG_ABSENT, NULL},
{ "ups.timer.start", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.start", 0, 0, "UPS.OutletSystem.Outlet.TLDelayBeforeStartup", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.shutdown", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
{ "ups.timer.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL },
{ "ups.test.result", 0, 0, "UPS.BatterySystem.Test", NULL, "%s", 0, test_read_info },
@ -272,6 +310,10 @@ static hid_info_t tripplite_hid2nut[] = {
{ "ups.power", 0, 0, "UPS.OutletSystem.Outlet.ActivePower", NULL, "%.1f", 0, NULL },
{ "ups.power", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.1f", 0, NULL },
{ "ups.load", 0, 0, "UPS.OutletSystem.Outlet.PercentLoad", NULL, "%.0f", 0, NULL },
/* FIXME: what is the conversion format for this one?
* Example on HP T1500 G3
* UPS.TLCustom.[1].UPSFirmwareVersion, Type: Feature, ReportID: 0x0f, Offset: 0, Size: 16, Value: 262 */
{ "ups.firmware", 0, 0, "UPS.TLCustom.[1].UPSFirmwareVersion", NULL, "%.0f", HU_FLAG_STATIC, NULL },
/* Number of seconds left before the watchdog reboots the UPS (0 = disabled) */
{ "ups.watchdog.status", 0, 0, "UPS.OutletSystem.Outlet.TLWatchdog", NULL, "%.0f", 0, NULL },
@ -288,10 +330,16 @@ static hid_info_t tripplite_hid2nut[] = {
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info },
/* repeat some of the above for faulty usage codes (seen on OMNI1000LCD, untested) */
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.TLACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info },
/* "Redundant" definition to deal with the conflict between
* TrippLite units, wrongly defining 0x00840045 as "TLDischarging"
* and HP which uses the standard 0x00840045 (as ConfigPercentLoad).
* Note that this path should not exist on HP devices. */
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.TLDischarging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info },
/* Otherwise, define the version for HP devices */
{ "ups.load.nominal", 0, 0, "UPS.Flow.ConfigPercentLoad", NULL, "%.0f", 0, NULL },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.TLCharging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info },
{ "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.TLNeedReplacement", NULL, NULL, 0, replacebatt_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.VoltageOutOfRange", NULL, NULL, 0, vrange_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Buck", NULL, NULL, 0, trim_info },
{ "BOOL", 0, 0, "UPS.PowerConverter.PresentStatus.Boost", NULL, NULL, 0, boost_info },
@ -338,6 +386,7 @@ static hid_info_t tripplite_hid2nut[] = {
{ "load.off.delay", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL },
{ "load.on.delay", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL },
{ "load.on.delay", 0, 0, "UPS.OutletSystem.Outlet.TLDelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL },
{ "shutdown.stop", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL },
{ "shutdown.reboot", 0, 0, "UPS.OutletSystem.Outlet.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL },
@ -354,6 +403,18 @@ static hid_info_t tripplite_hid2nut[] = {
{ "beeper.enable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL },
{ "beeper.mute", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL },
/* FIXME (to be tested): HP specific (may conflict or differ from TL implementation!)
* { "outlet.count", 0, 0, "UPS.TLCustom.[1].OutletCount", NULL, "%.0f", HU_FLAG_STATIC, NULL },
* { "outlet.status", 0, 0, "UPS.TLCustom.[1].OutletState", NULL, "%.0f", HU_FLAG_STATIC, NULL },
0.284486 Path: UPS.TLCustom.[1].ffff00ff, Type: Feature, ReportID: 0xff, Offset: 0, Size: 8, Value: 255
0.285276 Path: UPS.TLCustom.[1].OutletCount, Type: Feature, ReportID: 0x6d, Offset: 0, Size: 8, Value: 1
0.286260 Path: UPS.TLCustom.[1].OutletState, Type: Feature, ReportID: 0x70, Offset: 0, Size: 8, Value: 1
0.287248 Path: UPS.TLCustom.[1].CommunicationVersion, Type: Feature, ReportID: 0x0e, Offset: 0, Size: 16, Value: 262
0.288901 Path: UPS.TLCustom.[1].CommunicationProtocolVersion, Type: Feature, ReportID: 0x6c, Offset: 0, Size: 16, Value: 2560
0.289903 Path: UPS.TLCustom.[1].TLDelayBeforeStartup, Type: Feature, ReportID: 0x71, Offset: 0, Size: 16, Value: 65535
0.290854 Path: UPS.TLCustom.[1].AutoOnDelay, Type: Feature, ReportID: 0x72, Offset: 0, Size: 16, Value: 65535
*/
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};

View file

@ -130,7 +130,7 @@
POD ("Plain Old Documentation") - run through pod2html or perldoc. See
perlpod(1) for more information.
pod2man --name='TRIPPLITE_USB' --section=8 --release='$Rev: 2598 $' --center='Network UPS Tools (NUT)' tripplite_usb.c
pod2man --name='TRIPPLITE_USB' --section=8 --release='$Rev: 3555 $' --center='Network UPS Tools (NUT)' tripplite_usb.c
=head1 NAME
@ -504,24 +504,30 @@ static int hex2d(const unsigned char *start, unsigned int len)
static const char *hexascdump(unsigned char *msg, size_t len)
{
size_t i;
static unsigned char buf[256], *bufp;
static unsigned char buf[256];
unsigned char *bufp, *end;
bufp = buf;
end = bufp + sizeof(buf);
buf[0] = 0;
/* Dump each byte in hex: */
for(i=0; i<len; i++) {
for(i=0; i<len && end-bufp>=3; i++) {
bufp += sprintf((char *)bufp, "%02x ", msg[i]);
}
/* Dump single-quoted string with printable version of each byte: */
*bufp++ = '\'';
for(i=0; i<len; i++) {
if (end-bufp > 0) *bufp++ = '\'';
for(i=0; i<len && end-bufp>0; i++) {
*bufp++ = toprint(msg[i]);
}
*bufp++ = '\'';
if (end-bufp > 0) *bufp++ = '\'';
*bufp++ = '\0';
if (end-bufp > 0)
*bufp = '\0';
else
*--end='\0';
return (char *)buf;
}

View file

@ -20,7 +20,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: upscode2.c 2391 2010-03-04 15:35:09Z adkorte-guest $
$Id: upscode2.c 3597 2012-05-15 11:22:06Z aquette $
*/
/*
@ -45,7 +45,7 @@
#include <math.h>
#define DRIVER_NAME "UPScode II UPS driver"
#define DRIVER_VERSION "0.87"
#define DRIVER_VERSION "0.88"
/* driver description structure */
upsdrv_info_t upsdrv_info = {
@ -309,9 +309,9 @@ static simple_t simple[] = {
{ "MOIL1", t_value, "output.current" },
{ "MOIL2", t_value, "output.L2.current" },
{ "MOIL3", t_value, "output.L3.current" },
{ "MOIP1", t_value, "output.peakcurrent" },
{ "MOIP2", t_value, "output.L2.peakcurrent" },
{ "MOIP3", t_value, "output.L3.peakcurrent" },
{ "MOIP1", t_value, "output.current.peak" },
{ "MOIP2", t_value, "output.L2.current.peak" },
{ "MOIP3", t_value, "output.L3.current.peak" },
{ "MOPL1", t_value, "output.realpower", 0, &kilo_to_unity },
{ "MOPL2", t_value, "output.L2.realpower", 0, &kilo_to_unity },
{ "MOPL3", t_value, "output.L3.realpower", 0, &kilo_to_unity },
@ -780,7 +780,7 @@ void upsdrv_updateinfo(void)
change_name(simple,
"output.current", "output.L1.current");
change_name(simple,
"output.peakcurrent", "output.L1.peakcurrent");
"output.current.peak", "output.L1.current.peak");
change_name(simple,
"output.realpower", "output.L1.realpower");
change_name(simple,

View file

@ -25,12 +25,12 @@ enum {
STAT_INSTCMD_HANDLED = 0, /* completed successfully */
STAT_INSTCMD_UNKNOWN, /* unspecified error */
STAT_INSTCMD_INVALID, /* invalid command */
STAT_INSTCMD_FAILED /* command failed */
STAT_INSTCMD_FAILED /* command failed */
};
/* return values for setvar */
enum {
STAT_SET_HANDLED = 0, /* completed successfully */
STAT_SET_HANDLED = 0, /* completed successfully */
STAT_SET_UNKNOWN, /* unspecified error */
STAT_SET_INVALID, /* not writeable */
STAT_SET_FAILED /* writing failed */

View file

@ -1,7 +1,7 @@
/* usbhid-ups.c - Driver for USB and serial (MGE SHUT) HID UPS units
*
* Copyright (C)
* 2003-2009 Arnaud Quette <arnaud.quette@gmail.com>
* 2003-2012 Arnaud Quette <arnaud.quette@gmail.com>
* 2005 John Stamp <kinsayder@hotmail.com>
* 2005-2006 Peter Selinger <selinger@users.sourceforge.net>
* 2007-2009 Arjen de Korte <adkorte-guest@alioth.debian.org>
@ -27,7 +27,7 @@
*/
#define DRIVER_NAME "Generic HID driver"
#define DRIVER_VERSION "0.35"
#define DRIVER_VERSION "0.37"
#include "main.h"
#include "libhid.h"
@ -480,7 +480,17 @@ static const char *kelvin_celsius_conversion_fun(double value)
{
static char buf[20];
snprintf(buf, sizeof(buf), "%.1f", value - 273.15);
/* check if the value is in the Kelvin range, to
* detect buggy value (already expressed in °C), as found
* on some HP implementation */
if ((value >= 273) && (value <= 373)) {
/* the value is indeed in °K */
snprintf(buf, sizeof(buf), "%.1f", value - 273.15);
}
else {
/* else, this is actually °C, not °K! */
snprintf(buf, sizeof(buf), "%.1f", value);
}
return buf;
}
@ -556,6 +566,11 @@ int instcmd(const char *cmdname, const char *extradata)
if (!strcasecmp(cmdname, "shutdown.return")) {
int ret;
/* Ensure "ups.start.auto" is set to "yes", if supported */
if (dstate_getinfo("ups.start.auto")) {
setvar("ups.start.auto", "yes");
}
ret = instcmd("load.on.delay", dstate_getinfo("ups.delay.start"));
if (ret != STAT_INSTCMD_HANDLED) {
return ret;
@ -567,6 +582,11 @@ int instcmd(const char *cmdname, const char *extradata)
if (!strcasecmp(cmdname, "shutdown.stayoff")) {
int ret;
/* Ensure "ups.start.auto" is set to "no", if supported */
if (dstate_getinfo("ups.start.auto")) {
setvar("ups.start.auto", "no");
}
ret = instcmd("load.on.delay", "-1");
if (ret != STAT_INSTCMD_HANDLED) {
return ret;