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

@ -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;