Hi All,

There were other byte swap issues with the driver, making all the bit field flags wrong. Have swapped them and can confirm the OL, OB and CHRG flags work. CHaRGing is not the inverse of Liebert's BATTERY_CHARGED flag as that means CHRG is set when the UPS is on battery. Is it reasonable to correct for this by ANDing with the OL flag?

Byte swapping patch attached.


Richard

+--                               --+
|  Biological Sciences, Room 231    |
|  http://www.csc.liv.ac.uk/~greg   |
+--                               --+

Arjen de Korte wrote:
Citeren Robert Jobbagy <[email protected]>:

The trouble  was in the command reply buffer use.
You compute the value that value = reply[6]*256+reply[5]  <- it's wrong

The right solution: value = reply[5] * 256 + reply[6];

Thanks for this patch. I just committed it to the development version. But please note that this is an experimental driver. Most of the functions are untested (since nobody took the time to try it out and post the results back to the mailing list).

And other bug,

battery.runtime compute, you divide this value 60 <- it's wrong

right value: divide 1.0

Probably not. Per the NUT standard, the 'battery.runtime' value is reported in seconds. As far as I understand, the UPS reports runtime remaining in minutes, so we need to multiply by 60 here. See 'docs/new-names.txt' for a listing of (almost) all variables supported in NUT.

I continue the work on this driver,and I will write if I make a something
new.

Please do. It should be trivial to add additional commands and variables to the existing ones.

Best regards, Arjen
--- drivers/liebertgxt2.c_orig	2010-04-05 13:36:35.000000000 +0100
+++ drivers/liebertgxt2.c	2010-04-05 13:53:56.000000000 +0100
@@ -23,7 +23,7 @@
 #include "timehead.h"
 
 #define DRIVER_NAME	"Liebert GXT2 serial UPS driver"
-#define DRIVER_VERSION	"0.01"
+#define DRIVER_VERSION	"0.02"
 
 static int instcmd(const char *cmdname, const char *extra);
 static int setvar(const char *varname, const char *val);
@@ -40,7 +40,7 @@
 static const unsigned char
 	/* Bit field information provided by Spiros Ioannou */
 	/* Ordered on MSB to LSB. Shown as DESCRIPTION (bit number), starting at 0. */
-	cmd_bitfield1[]		= { 1,148,2,1,1,153 },	/* INPUT_OVERVOLTAGE, BATTERY_TEST_STATE, OVERTEMP_WARNING, INRUSH_LIMIT_ON, UTILITY_STATE, ON_INVERTER, DC_DC_CONVERTER_STATE, PFC_ON */
+	cmd_bitfield1[]		= { 1,148,2,1,1,153 },	/* ON_BATTERY(8), INPUT_OVERVOLTAGE(7), BATTERY_TEST_STATE(6), OVERTEMP_WARNING(5), INRUSH_LIMIT_ON(4), UTILITY_STATE(3), ON_INVERTER(2), DC_DC_CONVERTER_STATE(1), PFC_ON(0) */
 	cmd_bitfield2[]		= { 1,148,2,1,2,154 },	/* BUCK_ON (9), DIAG_LINK_SET(7), BOOST_ON(6), REPLACE_BATTERY(5), BATTERY_LIFE_ENHANCER_ON(4), BATTERY_CHARGED (1), ON_BYPASS (0) */
 	cmd_bitfield3[]		= { 1,148,2,1,3,155 },	/* CHECK_AIR_FILTER (10), BAD_BYPASS_PWR (8), OUTPUT_OVERVOLTAGE (7), OUTPUT_UNDERVOLTAGE (6), LOW_BATTERY (5), CHARGER_FAIL (3), SHUTDOWN_PENDING (2), BAD_INPUT_FREQ (1), UPS_OVERLOAD (0) */
 	cmd_bitfield7[]		= { 1,148,2,1,7,159 },	/* AMBIENT_OVERTEMP (2) */
@@ -187,7 +187,7 @@
 		return;
 	}
 
-	if (reply[6] & (1<<0)) {	/* ON_BATTERY */
+	if (reply[5] & (1<<0)) {	/* ON_BATTERY */
 		status_set("OB");
 	} else {
 		status_set("OL");
@@ -200,23 +200,23 @@
 		return;
 	}
 
-	if (reply[5] & (1<<0)) {	/* ON_BYPASS */
+	if (reply[6] & (1<<0)) {	/* ON_BYPASS */
 		status_set("BYPASS");
 	}
 
-	if (reply[5] & (1<<5)) {	/* REPLACE_BATTERY */
+	if (reply[6] & (1<<5)) {	/* REPLACE_BATTERY */
 		status_set("RB");
 	}
 
-	if (!(reply[5] & (1<<1))) {	/* not BATTERY_CHARGED */
+	if (!(reply[6] & (1<<1))) {	/* not BATTERY_CHARGED */
 		status_set("CHRG");
 	}
 
-	if (reply[5] & (1<<6)) {	/* BOOST_ON */
+	if (reply[6] & (1<<6)) {	/* BOOST_ON */
 		status_set("BOOST");
 	}
 
-	if (reply[6] & (1<<1)) {	/* BUCK_ON */
+	if (reply[5] & (1<<1)) {	/* BUCK_ON */
 		status_set("TRIM");
 	}
 
@@ -227,11 +227,11 @@
 		return;
 	}
 
-	if (reply[5] & (1<<0) ) {	/* UPS_OVERLOAD */
+	if (reply[6] & (1<<0) ) {	/* UPS_OVERLOAD */
 		status_set("OVER");
 	}
 
-	if (reply[5] & (1<<5) ) {	/* LOW_BATTERY */
+	if (reply[6] & (1<<5) ) {	/* LOW_BATTERY */
 		status_set("LB");
 	}
 
_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to