[Nut-upsdev] newhidups (2.03-pre2) not working with APC Back-UPS
Peter Selinger
selinger at mathstat.dal.ca
Fri Jan 27 20:21:47 UTC 2006
OK, so there are four new variables:
battery.date: 4045/00/02
battery.voltage.nominal: 12.0
ups.mfr.date: 2002/10/22
ups.status: OL CHRG LB
Three of them look reasonable, battery.date looks unreasonable.
The raw value is 0x102202 hexadecimal, which I guess encodes the
American date 10/22/02, the same as the UPS manufacture date. Could
you try the attached patch? I have also changed this variable to
battery.mfr.date, which is probably the more accurate interpretation.
Thanks, -- Peter
Charlie Brady wrote:
>
>
> On Fri, 27 Jan 2006, Peter Selinger wrote:
>
> > Excellent. Can you again post the output of 'upsc UPS at localhost'?
> > There should be some additional variables recognized.
>
> battery.charge: 4
> battery.charge.low: 10
> battery.charge.warning: 50
> battery.date: 4045/00/02
> battery.runtime: 0
> battery.voltage: 12.0
> battery.voltage.nominal: 12.0
> driver.name: newhidups
> driver.version: 2.0.3-pre2
> driver.version.data: APC HID 0.8
> driver.version.internal: 0.28
> ups.firmware: 6.5.D
> ups.firmware.aux: c1
> ups.mfr: American Power Conversion
> ups.mfr.date: 2002/10/22
> ups.model: Back-UPS 500
> ups.serial: JB0243006965
> ups.status: OL CHRG LB
>
> > The other error you reported (double free or corruption) is not
> > connected to this patch, but is worrisome nonetheless.
>
> It has happened again, without any previous version having run since
> reboot. Platform is CentOS 4.2 based.
>
> [root at test7 ~]# newhidups -DD hiddev0 2>&1 | less
> *** glibc detected *** double free or corruption (fasttop): 0x0805c450 ***
> [root at test7 ~]#
>
> --
> Charlie
>
-------------- next part --------------
Index: drivers/apc-hid.c
===================================================================
RCS file: /cvsroot/nut/nut/drivers/Attic/apc-hid.c,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 apc-hid.c
--- drivers/apc-hid.c 27 Jan 2006 15:04:53 -0000 1.1.2.10
+++ drivers/apc-hid.c 27 Jan 2006 20:22:27 -0000
@@ -50,6 +50,37 @@
{ 0, NULL, watts_to_av_conversion_fun }
};
+/* returns statically allocated string - must not use it again before
+ done with result! */
+static char *apc_date_conversion_fun(long value) {
+ static char buf[20];
+ int year, month, day;
+
+ if (value == 0) {
+ return "not set";
+ }
+
+ /* APC apparently uses a hexadecimal-as-decimal format, e.g.,
+ 0x102202 = October 22, 2002 */
+ year = (value & 0x00000f) + 10 * (value & 0x0000f0);
+ month = (value & 0x0f0000) + 10 * (value & 0xf00000);
+ day = (value & 0x000f00) + 10 * (value & 0x00f000);
+
+ /* Y2K conversion - hope that this format will be retired before 2070 :) */
+ if (year >= 70) {
+ year += 1900;
+ } else {
+ year += 2000;
+ }
+
+ sprintf(buf, "%04d/%02d/%02d", year, month, day);
+ return buf;
+}
+
+info_lkp_t apc_date_conversion[] = {
+ { 0, NULL, apc_date_conversion_fun }
+};
+
/* APC has two non-NUT-standard status items: "time limit expired" and
"battery present". The newhidups driver currently ignores
batterypresent, and maps timelimitexp to LB. CyberPower has the
@@ -162,8 +193,8 @@
{ "battery.temperature", 0, 0, "UPS.Battery.Temperature", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_OK, stringid_conversion },
{ "battery.mfr.date", 0, 0, "UPS.Battery.ManufacturerDate", NULL, "%s", HU_FLAG_OK, &date_conversion[0] },
- { "battery.date", 0, 0, "UPS.Battery.APCBattReplaceDate", NULL, "%s", HU_FLAG_OK, &date_conversion[0] },
- { "battery.date", 0, 0, "UPS.PowerSummary.APCBattReplaceDate", NULL, "%s", HU_FLAG_OK, &date_conversion[0] }, /* Back-UPS 500 */
+ { "battery.date", 0, 0, "UPS.Battery.APCBattReplaceDate", NULL, "%s", HU_FLAG_OK, &date_conversion[0] }, /* FIXME: should we use apc_date_conversion? Should this be battery.mfr.date? */
+ { "battery.mfr.date", 0, 0, "UPS.PowerSummary.APCBattReplaceDate", NULL, "%s", HU_FLAG_OK, &apc_date_conversion[0] }, /* Back-UPS 500 */
/* UPS page */
{ "ups.load", 0, 1, "UPS.Output.PercentLoad", NULL, "%.1f", HU_FLAG_OK, NULL },
More information about the Nut-upsdev
mailing list