[Nut-upsdev] RE nut 2.0 fentonups and Xanto S3000R
Arnaud QUETTE
Arnaud.QUETTE at mgeups.com
Wed Apr 26 06:34:08 UTC 2006
Hi Henning,
you should get in touch with Carlos, who his developing a generic
megatec driver (available from svn:
http://eu1.networkupstools.org/source.html)
Arnaud
--
Linux / Unix Expert - MGE UPS SYSTEMS - R&D Dpt
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://people.debian.org/~aquette/
OpenSource Developer - http://arnaud.quette.free.fr/
Henning Brauer <henning at openbsd.org>
04/26/06 12:19 AM
A
arnaud.quette at mgeups.com
cc
bernd at cvs.openbsd.org, Henning Brauer <henning at cvs.openbsd.org>
Objet
nut 2.0 fentonups
this allows the model to be forced for the fentonups driver. I have a
UPS that does not respond to I, but otherwise perfectly follows the
fenton protocol. this makes it work.
the Xanto S3000R is a rackmount 2U UPS, online, 3000VA, which requires
and external 2U battery pack. The manufacturer is www.online-usv.de
<brahe at paploo:59>$ sudo ./fentonups -x model=XS3000R /dev/ttym1
Network UPS Tools - Fenton UPS driver 1.21 (2.0.0)
Detected Xanto S3000R on /dev/ttym1
<brahe at paploo:61>$ upsc UPS-3 at localhost
battery.charge: 100.0
battery.voltage: 2.26
driver.name: fentonups
driver.parameter.model: XS3000R
driver.version: 2.0.0
driver.version.internal: 1.21
input.frequency: 50.0
input.transfer.high: 275
input.transfer.low: 165
input.voltage: 228.8
output.voltage: 230.0
ups.load: 052
ups.mfr: Online
ups.model: Xanto S3000R
ups.status: OL
ups.temperature: 28.0
$OpenBSD$
--- drivers/fentonups.c.orig Tue Apr 25 23:33:03 2006
+++ drivers/fentonups.c Wed Apr 26 00:11:06 2006
@@ -33,14 +33,17 @@ static float lowvolt = 0,
voltrange;
static int lownorm, highnorm;
/* handle devices which don't give a properly formatted I string */
-static int check_mtab2(const char *raw)
+static int check_mtab2(const char *raw, int israw)
{
int i;
char *cooked;
- /* trim off the leading # and any trailing spaces */
- cooked = xstrdup(&raw[1]);
- rtrim(cooked, ' ');
+ if (israw) {
+ /* trim off the leading # and any
trailing spaces */
+ cooked = xstrdup(&raw[1]);
+ rtrim(cooked, ' ');
+ } else
+ cooked = xstrdup(raw);
for (i = 0; mtab2[i].id != NULL; i++) {
if (!strcmp(cooked, mtab2[i].id)) {
@@ -74,7 +77,7 @@ static void guessmodel(const char *raw)
char mch, *mstr;
/* first see if it's in the mtab2 */
- if (check_mtab2(raw))
+ if (check_mtab2(raw, 1))
return;
mch = raw[17];
@@ -175,28 +178,36 @@ static char *get_id(void)
void upsdrv_initinfo(void)
{
int modelnum, i, ret;
- char temp[256], model[32], *raw;
+ char temp[256], qmodel[32], *model, *raw =
NULL;
- raw = get_id();
+ model = getval("model");
- if (!raw)
- fatalx("Unable to detect a Fenton or
Megatec protocol UPS");
+ if (!model) {
+ raw = get_id();
- snprintf(temp, sizeof(temp), "%s", raw);
+ if (!raw)
+ fatalx("Unable to detect
a Fenton or Megatec protocol UPS");
- temp[11] = 0;
- temp[27] = 0;
+ snprintf(temp, sizeof(temp), "%s", raw);
- /* manufacturer */
- rtrim(&temp[1], ' ');
- dstate_setinfo("ups.mfr", &temp[1], 0, 0);
+ temp[11] = 0;
+ temp[27] = 0;
- /* L660A = PowerPal (L) @ 660 VA, American (A) version
(115V) */
+ /* manufacturer */
+ rtrim(&temp[1], ' ');
+ dstate_setinfo("ups.mfr", &temp[1], 0,
0);
- /* grab full model string */
- rtrim(&temp[17], ' ');
- snprintf(model, sizeof(model), "%s", &temp[17]);
+ /* L660A = PowerPal (L) @ 660 VA,
American (A) version (115V) */
+ /* grab full model string */
+ rtrim(&temp[17], ' ');
+ snprintf(qmodel, sizeof(qmodel), "%s",
&temp[17]);
+ model = qmodel;
+ }
+
+ if (!model)
+ fatalx("unable to determine model");
+
modelnum = -1;
/* figure out official model name and voltage info from
table */
@@ -210,20 +221,27 @@ void upsdrv_initinfo(void)
}
}
- /* table lookup fails -> guess */
- if (modelnum == -1)
- guessmodel(raw);
- else {
- dstate_setinfo("ups.model", "%s",
modeltab[modelnum].desc);
+ if (model && modelnum == -1)
+ if (check_mtab2(model, 0) == 0)
+ fatalx("no such model:
%s", model);
- dstate_setinfo("input.transfer.low",
"%d",
- modeltab[modelnum].lowxfer);
+ if (raw) {
+ /* table lookup fails -> guess */
+ if (modelnum == -1)
+ guessmodel(raw);
+ else {
+ dstate_setinfo("ups.model", "%s",
+ modeltab[modelnum].desc);
- dstate_setinfo("input.transfer.high",
"%d",
- modeltab[modelnum].highxfer);
+ dstate_setinfo("input.transfer.low", "%d",
+ modeltab[modelnum].lowxfer);
- lownorm = modeltab[modelnum].lownorm;
- highnorm = modeltab[modelnum].highnorm;
+ dstate_setinfo("input.transfer.high", "%d",
+ modeltab[modelnum].highxfer);
+
+ lownorm =
modeltab[modelnum].lownorm;
+ highnorm =
modeltab[modelnum].highnorm;
+ }
}
/* now add instant command support info */
@@ -231,7 +249,8 @@ void upsdrv_initinfo(void)
dstate_addcmd("test.battery.stop");
printf("Detected %s on %s\n",
dstate_getinfo("ups.model"), device_path);
- free(raw);
+ if (raw)
+ free(raw);
/* paranoia - cancel any shutdown that might already be
running */
ret = ser_send(upsfd, "C\r");
@@ -406,6 +425,7 @@ void upsdrv_help(void)
void upsdrv_makevartable(void)
{
+ addvar(VAR_VALUE, "model", "force model");
}
void upsdrv_banner(void)
$OpenBSD$
--- drivers/fentonups.h.orig Tue Apr 25 23:32:16 2006
+++ drivers/fentonups.h Wed Apr 26 00:09:19 2006
@@ -81,5 +81,6 @@ struct {
{ "WELI 500 1.0", "Giant Power", "MT650", 10.6, 3.7, 170,
180, 270, 280, 0 },
{ "SMART-UPS 1800VA T18Q16AG", "Effekta", "MT
2000 RM",
50.0, 19.5, 171, 200, 260, 278, 1 },
+ { "XS3000R", "Online", "Xanto S3000R", 1.81, 0.44, 165,
200, 240, 275, 1 },
{ NULL, NULL, NULL, 0,
0, 0, 0, 0, 0, 0 }
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20060426/85ae4fd2/attachment.html
More information about the Nut-upsdev
mailing list