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@openbsd.org> 04/26/06 12:19 AM A arnaud.quette@mgeups.com cc bernd@cvs.openbsd.org, Henning Brauer <henning@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@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@paploo:61>$ upsc UPS-3@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
Henning Brauer
2006-Apr-29 22:04 UTC
[Nut-upsdev] Re: RE nut 2.0 fentonups and Xanto S3000R
* Arnaud QUETTE <Arnaud.QUETTE@mgeups.com> [2006-04-26 10:18]:> you should get in touch with Carlos, who his developing a generic > megatec driversince 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. 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. another thing as I write to you anyway, apcsmart and APC SUDP8000XL: Network UPS Tools (version 2.0.0) - APC Smart protocol driver Driver version 1.99.6, command table version 2.0 dstate_setflags: base variable (input.transfer.high) does not exist dstate_addenum: base variable (input.transfer.high) does not exist dstate_setflags: base variable (input.transfer.low) does not exist dstate_addenum: base variable (input.transfer.low) does not exist dstate_setflags: base variable (input.sensitivity) does not exist dstate_addenum: base variable (input.sensitivity) does not exist dstate_setflags: base variable (battery.charge.restart) does not exist dstate_addenum: base variable (battery.charge.restart) does not exist Detected Smart-UPS DP 8000 XL [GS0144110071 ] on /dev/ttyj7 and I cannot get load. well manually, by doing output.current * output.voltage / 8000 <brahe@paploo:7>$ upsc UPS-4@localhost battery.alarm.threshold: L battery.charge: 100.0 battery.date: 11/6/03 battery.packs: 001 battery.packs.bad: 000 battery.runtime: 1620 battery.runtime.low: 120 driver.name: apcsmart driver.parameter.port: /dev/ttyj7 driver.version: 2.0.0 driver.version.internal: 1.99.6 input.frequency: 51.20 input.quality: FF input.transfer.reason: T input.voltage: 229.0 input.voltage.maximum: 229.0 input.voltage.minimum: 229.0 output.current: 17.10 output.voltage: 230.0 output.voltage.target.battery: 230 ups.delay.shutdown: 180 ups.delay.start: 060 ups.firmware: 381.5.I ups.id: UPS_IDEN ups.mfr: APC ups.mfr.date: 11/06/01 ups.model: Smart-UPS DP 8000 XL ups.serial: GS0144110071 ups.status: OL ups.temperature: 025.0 ups.test.interval: 1209600 ups.test.result: NO> Henning Brauer <henning@openbsd.org> > 04/26/06 12:19 AM > > A > arnaud.quette@mgeups.com > cc > bernd@cvs.openbsd.org, Henning Brauer <henning@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@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@paploo:61>$ upsc UPS-3@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 } > }; > >