[Nut-upsdev] Re: RE nut 2.0 fentonups and Xanto S3000R

Henning Brauer henning at openbsd.org
Wed Aug 16 13:32:20 UTC 2006


* Carlos Rodrigues <carlos.efr at mail.telepac.pt> [2006-04-30 18:59]:
> On 4/29/06, Henning Brauer <henning at openbsd.org> wrote:
> >* Arnaud QUETTE <Arnaud.QUETTE at mgeups.com> [2006-04-26 10:18]:
> >> you should get in touch with Carlos, who his developing a generic
> >> megatec driver
> 
> Sorry about not replying earlier, didn't have time to examine the
> patch until now.
> 
> >since that'll happen who-knows-when I have put these changes in the
> >openbsd port in the meantime.
> >
> >for the record, and the magic new megatec driver:
> >-the online-usv.de UPSes have no way to identify themselves
> >-they do not respond to "I"
> >-thus you need a way to force a model.
> 
> That's not a problem for the "megatec" driver. My own UPS doesn't
> identify itself either.
> 
> >the data for the S3000R is in the patch, I refrained from buying more
> >UPSes from them after I saw this divergence in the protocol (well, and
> >other stuff). maintaing an inhouse version of the fentonups driver for
> >3 or 4 years (hmm, maybe we even bought these in 2001... anyway) was
> >painful enough, so please include this in future versions.
> 
> The patch looks like it is only modifying fentonups to accept that
> model, without making any other changes (to correct calculations,
> etc). Am I wrong?
> 
> Then megatec (and powermust on the stable branch, for that matter)
> should aready drive that UPS. If it doesn't - check if battery.charge
> ever reaches 100% -, care to send me the output from "upsc"? (It can
> be the output just using powermust, it doesn't need to be megatec).

so, the megatec driver does not work with this UPS without some hackery 
either, it does not respond to 'F'. patch below.
since it doesn't respond to 'F', you have to specify the nominal 
battery voltage manually. It is a 96V unit. However, the max and min 
battvolt values don't match. I had 2.25V max and 1.81V in the hack for 
the fentonups driver. Looks like 2.26V might be the true max. My unit 
never reaches 2.29 as megatec has it as of now. I admit the batteries 
are pretty pretty dated (must be anno 2001 or 2002) tho, but AFAICR the 
battery voltage was always 2.26 .. 2.27V. I cannot test what the low 
battery voltage is since that unit is in production.

on a related note, bcmxcp is not very reliable in attaching to the UPS, 
and the battery.charge it reports is extremely bogus (driver from 
nut-2.0.4, if there have been improvements pls let me know).

paploo # ./megatec -DDD -x battvolt=96 /dev/ttym1 
Network UPS Tools - Megatec protocol driver 1.4 (2.0.4)
Carlos Rodrigues (c) 2003-2006

debug level is '3'
Starting UPS detection process...
Attempting to detect the UPS...
Sending "F" command...
Wrong answer to "F" command: "".
Sending "Q1" command...
"Q1" command successful: "225.4 225.4 230.0 061 49.9 2.25 31.0 00000000".
Attempting to detect the UPS...
Sending "F" command...
Wrong answer to "F" command: "".
Sending "Q1" command...
"Q1" command successful: "225.4 225.4 230.0 061 49.9 2.26 30.5 00000000".
Attempting to detect the UPS...
Sending "F" command...
Wrong answer to "F" command: "".
Sending "Q1" command...
"Q1" command successful: "224.2 224.2 230.0 061 49.9 2.26 30.5 00000000".
Attempting to detect the UPS...
Sending "F" command...
Wrong answer to "F" command: "".
Sending "Q1" command...
"Q1" command successful: "224.2 224.2 230.0 061 49.9 2.26 30.5 00000000".
Attempting to detect the UPS...
Sending "F" command...
Wrong answer to "F" command: "".
Sending "Q1" command...
"Q1" command successful: "224.2 224.2 230.0 061 49.9 2.26 31.0 00000000".
0 out of 5 detection attempts failed (minimum failures: 2).
Asking for UPS information ("I" command)...
UPS doesn't return any information about itself.
Megatec protocol UPS detected.
Asking for UPS power ratings ("F" command)...
UPS doesn't return any information about its power ratings.
Asking for UPS status ("Q1" command)...
UPS status: 224.2 224.2 230.0 061 49.9 2.26 30.5 00000000
This looks like a 96V UPS.
Done setting up the UPS.
Asking for UPS status ("Q1" command)...
UPS status: 224.2 224.2 230.0 061 49.9 2.26 30.5 00000000
dstate_init: sock /var/db/nut/megatec-ttym1 open on fd 5
Asking for UPS status ("Q1" command)...
UPS status: 224.2 224.2 230.0 061 49.9 2.26 30.5 00000000
Asking for UPS status ("Q1" command)...
UPS status: 224.2 224.2 230.0 061 49.9 2.26 30.5 00000000
[...]


diff:

$OpenBSD$
--- drivers/megatec.c.orig	Wed Aug 16 14:35:08 2006
+++ drivers/megatec.c	Wed Aug 16 15:15:44 2006
@@ -88,7 +88,7 @@
 
 /* Values obtained from a "Ablerex MS3000RT" (96V). */
 #define BATT_MIN_96V 1.63  /* Estimate from LB at 1.8V with 25% charge */
-#define BATT_MAX_96V 2.29
+#define BATT_MAX_96V 2.26
 
 /*
  * For each UPS type, we define an upper bound (battery)
@@ -187,22 +187,20 @@ static int check_ups(void)
 	upsdebugx(2, "Sending \"F\" command...");
 	ser_send_pace(upsfd, SEND_PACE, "F%c", ENDCHAR);
 	ret = ser_get_line(upsfd, buffer, RECV_BUFFER_LEN, ENDCHAR, IGNCHARS, READ_TIMEOUT, 0);
-	if (ret < F_CMD_REPLY_LEN) {
-		upsdebugx(2, "Wrong answer to \"F\" command.");
+	if (ret < F_CMD_REPLY_LEN)
+		upsdebugx(2, "Wrong answer to \"F\" command: \"%s\".", buffer);
+	else
+		upsdebugx(2, "\"F\" command successful.");
 
-		return -1;
-	}
-	upsdebugx(2, "\"F\" command successful.");
-
 	upsdebugx(2, "Sending \"Q1\" command...");
 	ser_send_pace(upsfd, SEND_PACE, "Q1%c", ENDCHAR);
 	ret = ser_get_line(upsfd, buffer, RECV_BUFFER_LEN, ENDCHAR, IGNCHARS, READ_TIMEOUT, 0);
 	if (ret < Q1_CMD_REPLY_LEN) {
-		upsdebugx(2, "Wrong answer to \"Q1\" command.");
+		upsdebugx(2, "Wrong answer to \"Q1\" command: %s.", buffer);
 
 		return -1;
 	}
-	upsdebugx(2, "\"Q1\" command successful.");
+	upsdebugx(2, "\"Q1\" command successful: \"%s\".", buffer);
 
 	return 0;
 }
@@ -275,14 +273,11 @@ static int get_firmware_values(FirmwareV
 	upsdebugx(1, "Asking for UPS power ratings (\"F\" command)...");
 	ser_send_pace(upsfd, SEND_PACE, "F%c", ENDCHAR);
 	ret = ser_get_line(upsfd, buffer, RECV_BUFFER_LEN, ENDCHAR, IGNCHARS, READ_TIMEOUT, 0);
-	if (ret < F_CMD_REPLY_LEN) {
+	if (ret < F_CMD_REPLY_LEN)
 		upsdebugx(1, "UPS doesn't return any information about its power ratings.");
-		
-		return -1;
-	}
+	else
+		upsdebugx(3, "UPS power ratings: %s", buffer);
 
-	upsdebugx(3, "UPS power ratings: %s", buffer);
-
 	sscanf(buffer, "%f %f %f %f", &values->volt, &values->current,
 	       &values->battvolt, &values->freq);
 
@@ -371,7 +366,8 @@ static void set_battery_params(float vol
 	battvolt_max = INT_MAX;
 
 	upslogx(LOG_WARNING, "This UPS has an unsupported combination of battery voltage/number of batteries."
-	                     " The \"battery.charge\" value will be bogus.");
+	                     " The \"battery.charge\" value will be bogus."
+			     " Battery voltage: %0.2f", volt_nominal);
 }
 
 
@@ -424,6 +420,9 @@ void upsdrv_initinfo(void)
 
 	dstate_setinfo("ups.serial", "%s", getval("serial") ? getval("serial") : "unknown");
 
+	if (getval("battvolt"))
+		sscanf(getval("battvolt"), "%f", &values.battvolt);
+
 	if (get_firmware_values(&values) < 0) {
 		fatalx("Error reading firmware values from UPS!");
 	}
@@ -681,6 +680,7 @@ void upsdrv_makevartable(void)
 	addvar(VAR_VALUE, "model", "Model name");
 	addvar(VAR_VALUE, "serial", "UPS serial number");
 	addvar(VAR_VALUE, "lowbatt", "Low battery level (%)");
+	addvar(VAR_VALUE, "battvolt", "Nominal battery voltage");
 }
 
 



More information about the Nut-upsdev mailing list