[Nut-upsdev] Small patch to apcsmart driver
Michael Haardt
michael at moria.de
Tue Feb 2 12:51:59 UTC 2010
Hello,
the appended patch converts the reason of transfer to be human readable.
How about adding this variable to the usbmon message when it detects
being on battery?
Michael
----------------------------------------------------------------------
--- ./drivers/apcsmart.h.orig 2009-12-09 16:52:56.000000000 +0100
+++ ./drivers/apcsmart.h 2009-12-09 16:54:34.000000000 +0100
@@ -98,6 +98,7 @@
#define APC_F_SECONDS 0x100000 /* Time in seconds */
#define APC_F_MINUTES 0x110000 /* Time in minutes */
#define APC_F_HOURS 0x120000 /* Time in hours */
+#define APC_F_REASON 0x130000 /* Reason of transfer */
#define APC_F_LEAVE 0 /* Just pass this through */
struct apc_vartab_t {
@@ -143,7 +144,7 @@
{ "input.transfer.high",
APC_F_VOLT, 'u' },
{ "input.transfer.reason",
- APC_POLL, 'G' },
+ APC_POLL|APC_F_REASON, 'G' },
{ "input.voltage.maximum",
APC_POLL|APC_F_VOLT, 'M' },
--- ./drivers/apcsmart.c.orig 2009-12-09 16:39:46.000000000 +0100
+++ ./drivers/apcsmart.c 2010-02-02 13:46:48.000000000 +0100
@@ -106,6 +106,17 @@
snprintf(tmp, sizeof(tmp), "%d", tval);
return tmp;
+ case APC_F_REASON:
+ switch (upsval[0]) {
+ case 'R': return "unacceptable utility voltage rate of change";
+ case 'H': return "high utility voltage";
+ case 'L': return "low utility voltage";
+ case 'T': return "line voltage notch or spike";
+ case 'O': return "no transfers yet since turnon";
+ case 'S': return "simulated power failure or UPS test";
+ default: return upsval;
+ }
+
default:
upslogx(LOG_NOTICE, "Unable to handle conversion of %s",
cmd_entry->name);
More information about the Nut-upsdev
mailing list