[Nut-upsuser] Ablerex 625L USB version
Peter Selinger
selinger at mathstat.dal.ca
Sat Sep 23 18:21:35 UTC 2006
Lau Kim Ping wrote:
>
> Peter,
>
> I played with option -DDDD & newhidups revealed more info:
The -DDDD info is not useful; it is for debugging the driver, and not
for discovering information about the UPS.
> With the above new info, can you give some hints to get me started
> in writing a subdriver for it? What info should I ask the
> manufacturer?
The attached patch contains an initial "stub" subdriver that I just
created for you. It differs from a fully functional NUT subdriver in
that all the variables are named "unmapped.*", so the driver will not
work with upsmon. It should, however, work with upsd and upsc, and you
can use it as a basis for further customization.
Please compile this subdriver, see if you get it to run, and post the
output of "upsc". Thanks, -- Peter
> *****
>
> >On Fri, 22 Sep 2006 22:47:40 -0300 (ADT)
> >selinger at mathstat.dal.ca (Peter Selinger) wrote:
>
> >That device is not currently supported (we have never seen it before).
> >It looks like a HID device, so it should be possible to write a
> >subdriver for it, see docs/hid-subdrivers.txt.
> >
> >However, the data returned by the device looks strange; all the values
> >are "0". I am not sure if this will work out.
> >
> >-- Peter
> >
> >Lau Kim Ping wrote:
> >>
> >> Has anyone managed to get this UPS to work? I am using the laster development nuts. My /proc/bus/usb/devices content:
> >>
> >> ==== cut ====
> >> T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0
> >> D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
> >> P: Vendor=ffff ProdID=0000 Rev= 1.00
> >> S: Manufacturer=UIS Ablerex
> >> S: Product=Ablerex USB Interface 049e
> >> C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
> >> I: If#= 0 Alt= 0 #EPs= 0 Cls=03(HID ) Sub=00 Prot=00 Driver=(none)
> >> ==== cut ====
> >>
> >> "newhidups -DD -u root -x generic -x vendorid=ffff auto" gave me this:
> >>
> >> debug level is '2'
> >> Checking device (FFFF/0000) (001/002)
> >> - VendorID: ffff
> >> - ProductID: 0000
> >> - Manufacturer: UIS Ablerex
> >> - Product: Ablerex USB Interface 049e
> >> - Serial Number: unknown
> >> - Bus: 001
> >> Trying to match device
> >> Device matches
> >> HID descriptor retrieved (Reportlen = 632)
> >> Report descriptor retrieved (Reportlen = 632)
> >> Found HID device
> >> Report Descriptor size = 632
> >> Detected a UPS: UIS Ablerex/Ablerex USB Interface 049e
> >> Using subdriver: GENERIC HID 0.1
> >> Network UPS Tools: 0.28 USB communication driver 0.28 - core 0.30
> >> (2.1.0)
> >>
> >> Path: 00860004.Flow.FlowID, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.ConfigVoltage, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.ConfigFrequency, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.LowVoltageTransfer, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.HighVoltageTransfer, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.iManufacturer, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.iProduct, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.iSerialNumber, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.FlowID, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.ConfigVoltage, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.ConfigFrequency, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.ConfigApparentPower, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.ConfigActivePower, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.DelayBeforeStartup, Type: Feature, Value: 0.000000
> >> Path: 00860004.Flow.DelayBeforeShutdown, Type: Feature, Value: 0.000000
> >> Path: 00860004.BatterySystem.BatterySystemID, Type: Feature, Value:
> >> 0.000000
> >> Path: 00860004.BatterySystem.PresentStatus.Used, Type: Feature, Value:
> >> 0.000000
> >> Path: 00860004.BatterySystem.PresentStatus.Good, Type: Feature, Value:
> >> 0.000000
> >> Path: 00860004.BatterySystem.Voltage, Type: Feature, Value: 0.000000
> >> Path: 00860004.BatterySystem.Temperature, Type: Feature, Value: 0.000000
> >> Path: 00860004.BatterySystem.Test, Type: Input, Value: 0.000000
> >> Path: 00860004.BatterySystem.Test, Type: Feature, Value: 0.000000
> >> Can't find object 00860004.PowerConverter.PowerConverterID
> >> Path: 00860004.PowerConverter.PowerConverterID, Type: Input
> >> Can't find object 00860004.PowerConverter.Input.InputID
> >> Path: 00860004.PowerConverter.Input.InputID, Type: Input
> >> Can't find object 00860004.PowerConverter.Input.FlowID
> >> Path: 00860004.PowerConverter.Input.FlowID, Type: Input
> >> Can't find object 00860004.PowerConverter.Input.PresentStatus.Good
> >> Path: 00860004.PowerConverter.Input.PresentStatus.Good, Type: Input
> >> Can't find object 00860004.PowerConverter.Input.Voltage
> >> Path: 00860004.PowerConverter.Input.Voltage, Type: Input
> >> Can't find object 00860004.PowerConverter.Input.Frequency
> >> Path: 00860004.PowerConverter.Input.Frequency, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.OutputID
> >> Path: 00860004.PowerConverter.Output.OutputID, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.FlowID
> >> Path: 00860004.PowerConverter.Output.FlowID, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.Voltage
> >> Path: 00860004.PowerConverter.Output.Voltage, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.Frequency
> >> Path: 00860004.PowerConverter.Output.Frequency, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.PercentLoad
> >> Path: 00860004.PowerConverter.Output.PercentLoad, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.PresentStatus.Overload
> >> Path: 00860004.PowerConverter.Output.PresentStatus.Overload, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.PresentStatus.Boost
> >> Path: 00860004.PowerConverter.Output.PresentStatus.Boost, Type: Input
> >> Can't find object 00860004.PowerConverter.Output.PresentStatus.Buck
> >> Path: 00860004.PowerConverter.Output.PresentStatus.Buck, Type: Input
> >> Path: 00860004.PowerConverter.Output.PresentStatus.00840039, Type:
> >> Feature, Value: 0.000000
> >> upsdrv_updateinfo...
> >> dstate_init: sock /var/state/ups/newhidups-auto open on fd 5
> >> upsdrv_updateinfo...
> >> Waiting for notifications...
> >>
> >> Signal 2: exiting
> >> Closing device
> >>
> >>
> >> _______________________________________________
> >> Nut-upsuser mailing list
> >> Nut-upsuser at lists.alioth.debian.org
> >> http://lists.alioth.debian.org/mailman/listinfo/nut-upsuser
> >>
> >
>
-------------- next part --------------
Index: drivers/ablerex-hid.c
===================================================================
--- drivers/ablerex-hid.c (revision 0)
+++ drivers/ablerex-hid.c (revision 0)
@@ -0,0 +1,163 @@
+/* ablerex-hid.c - subdriver to monitor Ablerex USB/HID devices with NUT
+ *
+ * Copyright (C)
+ * 2003 - 2005 Arnaud Quette <arnaud.quette at free.fr>
+ * 2005 - 2006 Peter Selinger <selinger at users.sourceforge.net>
+ *
+ * Note: this subdriver was initially generated as a "stub" by the
+ * path-to-subdriver script. It must be customized.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "newhidups.h"
+#include "ablerex-hid.h"
+#include "extstate.h" /* for ST_FLAG_STRING */
+#include "dstate.h" /* for STAT_INSTCMD_HANDLED */
+#include "main.h" /* for getval() */
+#include "common.h"
+
+#define ABLEREX_HID_VERSION "Ablerex HID 0.1"
+
+#define ABLEREX_VENDORID 0xffff
+
+/* --------------------------------------------------------------- */
+/* Vendor-specific usage table */
+/* --------------------------------------------------------------- */
+
+/* ABLEREX usage table */
+static usage_lkp_t ablerex_usage_lkp[] = {
+ { "ABLEREX1", 0x00840039 },
+ { "UPS", 0x00860004 },
+ { "\0", 0x0 }
+};
+
+static usage_tables_t ablerex_utab[] = {
+ ablerex_usage_lkp,
+ hid_usage_lkp,
+ NULL,
+};
+
+/* --------------------------------------------------------------- */
+/* HID2NUT lookup table */
+/* --------------------------------------------------------------- */
+
+static hid_info_t ablerex_hid2nut[] = {
+
+ { "unmapped.ups.flow.flowid", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.configvoltage", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.configfrequency", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.lowvoltagetransfer", 0, 0, "UPS.Flow.LowVoltageTransfer", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.highvoltagetransfer", 0, 0, "UPS.Flow.HighVoltageTransfer", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.imanufacturer", 0, 0, "UPS.Flow.iManufacturer", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.iproduct", 0, 0, "UPS.Flow.iProduct", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.iserialnumber", 0, 0, "UPS.Flow.iSerialNumber", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.flowid", 0, 0, "UPS.Flow.FlowID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.configvoltage", 0, 0, "UPS.Flow.ConfigVoltage", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.configfrequency", 0, 0, "UPS.Flow.ConfigFrequency", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.configapparentpower", 0, 0, "UPS.Flow.ConfigApparentPower", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.configactivepower", 0, 0, "UPS.Flow.ConfigActivePower", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.delaybeforestartup", 0, 0, "UPS.Flow.DelayBeforeStartup", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.flow.delaybeforeshutdown", 0, 0, "UPS.Flow.DelayBeforeShutdown", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.batterysystemid", 0, 0, "UPS.BatterySystem.BatterySystemID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.presentstatus.used", 0, 0, "UPS.BatterySystem.PresentStatus.Used", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.presentstatus.good", 0, 0, "UPS.BatterySystem.PresentStatus.Good", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.voltage", 0, 0, "UPS.BatterySystem.Voltage", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.temperature", 0, 0, "UPS.BatterySystem.Temperature", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.test", 0, 0, "UPS.BatterySystem.Test", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.batterysystem.test", 0, 0, "UPS.BatterySystem.Test", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.powerconverterid", 0, 0, "UPS.PowerConverter.PowerConverterID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.input.inputid", 0, 0, "UPS.PowerConverter.Input.InputID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.input.flowid", 0, 0, "UPS.PowerConverter.Input.FlowID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.input.presentstatus.good", 0, 0, "UPS.PowerConverter.Input.PresentStatus.Good", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.input.voltage", 0, 0, "UPS.PowerConverter.Input.Voltage", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.input.frequency", 0, 0, "UPS.PowerConverter.Input.Frequency", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.outputid", 0, 0, "UPS.PowerConverter.Output.OutputID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.flowid", 0, 0, "UPS.PowerConverter.Output.FlowID", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.percentload", 0, 0, "UPS.PowerConverter.Output.PercentLoad", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.presentstatus.overload", 0, 0, "UPS.PowerConverter.Output.PresentStatus.Overload", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.presentstatus.boost", 0, 0, "UPS.PowerConverter.Output.PresentStatus.Boost", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.presentstatus.buck", 0, 0, "UPS.PowerConverter.Output.PresentStatus.Buck", NULL, "%.0f", HU_FLAG_OK, NULL },
+ { "unmapped.ups.powerconverter.output.presentstatus.ablerex1", 0, 0, "UPS.PowerConverter.Output.PresentStatus.ABLEREX1", NULL, "%.0f", HU_FLAG_OK, NULL },
+
+ /* end of structure. */
+ { NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
+};
+
+/* shutdown method for Ablerex */
+static int ablerex_shutdown(int ondelay, int offdelay) {
+ /* FIXME: ondelay, offdelay currently not used */
+
+ /* Default method */
+ upsdebugx(2, "Trying load.off.");
+ if (instcmd("load.off", NULL) == STAT_INSTCMD_HANDLED) {
+ return 1;
+ }
+ upsdebugx(2, "Shutdown failed.");
+ return 0;
+}
+
+static char *ablerex_format_model(HIDDevice *hd) {
+ return hd->Product;
+}
+
+static char *ablerex_format_mfr(HIDDevice *hd) {
+ return hd->Vendor ? hd->Vendor : "Ablerex";
+}
+
+static char *ablerex_format_serial(HIDDevice *hd) {
+ return hd->Serial;
+}
+
+/* this function allows the subdriver to "claim" a device: return 1 if
+ * the device is supported by this subdriver, else 0. */
+static int ablerex_claim(HIDDevice *hd) {
+ if (hd->VendorID != ABLEREX_VENDORID) {
+ return 0;
+ }
+ switch (hd->ProductID) {
+
+ /* accept any known UPS - add devices here as needed */
+ case 0000:
+ return 1;
+
+ /* by default, reject, unless the productid option is given */
+ default:
+ if (getval("productid")) {
+ return 1;
+ } else {
+ upsdebugx(1,
+"This particular ablerex device (%04x/%04x) is not (or perhaps not yet)\n"
+"supported by newhidups. Try running the driver with the '-x productid=%04x'\n"
+"option. Please report your results to the NUT developer's mailing list.\n",
+ hd->VendorID, hd->ProductID, hd->ProductID);
+ return 0;
+ }
+ }
+}
+
+subdriver_t ablerex_subdriver = {
+ ABLEREX_HID_VERSION,
+ ablerex_claim,
+ ablerex_utab,
+ ablerex_hid2nut,
+ ablerex_shutdown,
+ ablerex_format_model,
+ ablerex_format_mfr,
+ ablerex_format_serial,
+};
Index: drivers/ablerex-hid.h
===================================================================
--- drivers/ablerex-hid.h (revision 0)
+++ drivers/ablerex-hid.h (revision 0)
@@ -0,0 +1,32 @@
+/* ablerex-hid.h - subdriver to monitor Ablerex USB/HID devices with NUT
+ *
+ * Copyright (C)
+ * 2003 - 2005 Arnaud Quette <arnaud.quette at free.fr>
+ * 2005 - 2006 Peter Selinger <selinger at users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef ABLEREX_HID_H
+#define ABLEREX_HID_H
+
+#include "newhidups.h"
+
+#define ABLEREX_HID_VERSION "Ablerex HID 0.1"
+
+extern subdriver_t ablerex_subdriver;
+
+#endif /* ABLEREX_HID_H */
Index: drivers/newhidups.c
===================================================================
--- drivers/newhidups.c (revision 528)
+++ drivers/newhidups.c (working copy)
@@ -37,6 +37,7 @@
#include "apc-hid.h"
#include "belkin-hid.h"
#include "tripplite-hid.h"
+ #include "ablerex-hid.h"
#endif
/* master list of avaiable subdrivers */
@@ -49,6 +50,7 @@
&apc_subdriver,
&belkin_subdriver,
&tripplite_subdriver,
+ &ablerex_subdriver,
NULL
#endif
};
Index: drivers/Makefile.in
===================================================================
--- drivers/Makefile.in (revision 525)
+++ drivers/Makefile.in (working copy)
@@ -92,7 +92,7 @@
# Special case: newhidups driver - development version
NEWHIDUPS_SUBDRIVERS = generic-hid.o mge-hid.o apc-hid.o belkin-hid.o \
- tripplite-hid.o
+ tripplite-hid.o ablerex-hid.o
newhidups: newhidups.o main.o dstate.o ../common/state.o \
../common/upsconf.o ../common/parseconf.o $(LIBDEP) \
More information about the Nut-upsuser
mailing list