Branch oldpackages for 14.07
[14.07/packages.git] / utils / nut / patches / 002-minibox-openups-driver.patch
1 From f8546df4c18c087eac829d3dfc097c919abb6d1c Mon Sep 17 00:00:00 2001
2 From: aquette <aquette@72a954d1-e00c-0410-aa02-d9c7bb700a61>
3 Date: Wed, 28 Nov 2012 21:44:21 +0000
4 Subject: [PATCH] Official support for Minibox openUPS Intelligent UPS
5
6 Add a new usbhid-ups subdriver to handle Minibox openUPS Intelligent UPS
7 (USB ID 0x04d8:0xd004) (patch from Nicu Pavel, Mini-Box.Com)
8
9 git-svn-id: svn://anonscm.debian.org/nut/trunk@3791 72a954d1-e00c-0410-aa02-d9c7bb700a61
10 ---
11  data/driver.list.in                |   2 +
12  drivers/Makefile.am                |   5 +-
13  drivers/openups-hid.c              | 360 +++++++++++++++++++++++++++++++++++++
14  drivers/openups-hid.h              |  38 ++++
15  drivers/usbhid-ups.c               |   5 +-
16  scripts/upower/95-upower-hid.rules |   4 +
17  6 files changed, 411 insertions(+), 3 deletions(-)
18  create mode 100644 drivers/openups-hid.c
19  create mode 100644 drivers/openups-hid.h
20
21 diff --git a/data/driver.list.in b/data/driver.list.in
22 index 11014d6..70b5e0f 100644
23 --- a/data/driver.list.in
24 +++ b/data/driver.list.in
25 @@ -645,6 +645,8 @@
26  "Microsol"     "ups"   "5"     "Rhino 10.0"    "10000VA"       "rhino"
27  "Microsol"     "ups"   "5"     "Rhino 20.0"    "20000VA"       "rhino"
28  
29 +"Minibox"      "ups"   "5"     "openUPS Intelligent UPS"       "USB port"      "usbhid-ups"
30 +
31  "Mustek"       "ups"   "2"     "Powermust"     "400VA Plus"    "blazer_ser"
32  "Mustek"       "ups"   "2"     "Powermust"     "600VA Plus"    "blazer_ser"
33  "Mustek"       "ups"   "2"     "Powermust"     "800VA Pro"     "blazer_ser"
34 diff --git a/drivers/Makefile.am b/drivers/Makefile.am
35 index cd900cf..ad30874 100644
36 --- a/drivers/Makefile.am
37 +++ b/drivers/Makefile.am
38 @@ -162,7 +162,8 @@ skel_LDADD = $(LDADD_DRIVERS)
39  
40  # USB
41  USBHID_UPS_SUBDRIVERS = apc-hid.c belkin-hid.c cps-hid.c explore-hid.c \
42 - liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c
43 + liebert-hid.c mge-hid.c powercom-hid.c tripplite-hid.c idowell-hid.c \
44 + openups-hid.c
45  usbhid_ups_SOURCES = usbhid-ups.c libhid.c libusb.c hidparser.c        \
46   usb-common.c $(USBHID_UPS_SUBDRIVERS)
47  usbhid_ups_LDADD = $(LDADD_DRIVERS) $(LIBUSB_LIBS)
48 @@ -245,7 +246,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h baytech-mib.h bcmxcp.h    \
49   powercom.h powerpanel.h powerp-bin.h powerp-txt.h powerware-mib.h raritan-pdu-mib.h   \
50   safenet.h serial.h snmp-ups.h solis.h tripplite.h tripplite-hid.h                     \
51   upshandler.h usb-common.h usbhid-ups.h powercom-hid.h compaq-mib.h idowell-hid.h \
52 - apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h
53 + apcsmart.h apcsmart_tabs.h apcsmart-old.h cyberpower-mib.h openups-hid.h
54  
55  # Define a dummy library so that Automake builds rules for the
56  # corresponding object files.  This library is not actually built,
57 diff --git a/drivers/openups-hid.c b/drivers/openups-hid.c
58 new file mode 100644
59 index 0000000..69a4a61
60 --- /dev/null
61 +++ b/drivers/openups-hid.c
62 @@ -0,0 +1,360 @@
63 +/* openups-hid.c - subdriver to monitor Minibox openUPS USB/HID devices with NUT
64 + *
65 + *  Copyright (C)
66 + *  2003 - 2012        Arnaud Quette <ArnaudQuette@Eaton.com>
67 + *  2005 - 2006        Peter Selinger <selinger@users.sourceforge.net>
68 + *  2008 - 2009        Arjen de Korte <adkorte-guest@alioth.debian.org>
69 + *         2012        Nicu Pavel <npavel@mini-box.com>
70 + *
71 + *  This program is free software; you can redistribute it and/or modify
72 + *  it under the terms of the GNU General Public License as published by
73 + *  the Free Software Foundation; either version 2 of the License, or
74 + *  (at your option) any later version.
75 + *
76 + *  This program is distributed in the hope that it will be useful,
77 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
78 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
79 + *  GNU General Public License for more details.
80 + *
81 + *  You should have received a copy of the GNU General Public License
82 + *  along with this program; if not, write to the Free Software
83 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
84 + */
85 +
86 +#include "usbhid-ups.h"
87 +#include "openups-hid.h"
88 +#include "main.h"              /* for getval() */
89 +#include "usb-common.h"
90 +
91 +#define OPENUPS_HID_VERSION    "openUPS HID 0.1"
92 +
93 +/* Minibox */
94 +#define OPENUPS_VENDORID       0x04d8
95 +
96 +static char openups_scratch_buf[20];
97 +
98 +/* USB IDs device table */
99 +static usb_device_id_t openups_usb_device_table[] = {
100 +       /* openUPS Intelligent UPS (minimum required firmware 1.4) */
101 +       {USB_DEVICE(OPENUPS_VENDORID, 0xd004), NULL},
102 +
103 +       /* Terminating entry */
104 +       {-1, -1, NULL}
105 +};
106 +
107 +/* Thermistor table used for temperature lookups 
108 + * taken from the windows monitoring application
109 + */
110 +static unsigned int therm_tbl[] = 
111 +{ 
112 +       (unsigned int)0x31,
113 +       (unsigned int)0x40,
114 +       (unsigned int)0x53,
115 +       (unsigned int)0x68,
116 +       (unsigned int)0x82,
117 +       (unsigned int)0xA0,
118 +       (unsigned int)0xC3,
119 +       (unsigned int)0xE9,
120 +       (unsigned int)0x113,
121 +       (unsigned int)0x13F,
122 +       (unsigned int)0x16E,
123 +       (unsigned int)0x19F,
124 +       (unsigned int)0x1CF,
125 +       (unsigned int)0x200,
126 +       (unsigned int)0x22F,
127 +       (unsigned int)0x25C,
128 +       (unsigned int)0x286,
129 +       (unsigned int)0x2AE,
130 +       (unsigned int)0x2D3,
131 +       (unsigned int)0x2F4,
132 +       (unsigned int)0x312,
133 +       (unsigned int)0x32D,
134 +       (unsigned int)0x345,
135 +       (unsigned int)0x35A,
136 +       (unsigned int)0x36D,
137 +       (unsigned int)0x37E,
138 +       (unsigned int)0x38C,
139 +       (unsigned int)0x399,
140 +       (unsigned int)0x3A5,
141 +       (unsigned int)0x3AF,
142 +       (unsigned int)0x3B7,
143 +       (unsigned int)0x3BF,
144 +       (unsigned int)0x3C6,
145 +       (unsigned int)0x3CC
146 +};
147 +
148 +static unsigned int therm_tbl_size = sizeof(therm_tbl)/sizeof(therm_tbl[0]);
149 +
150 +static const char *openups_charging_fun(double value);
151 +static const char *openups_discharging_fun(double value);
152 +static const char *openups_online_fun(double value);
153 +static const char *openups_nobattery_fun(double value);
154 +static const char *openups_off_fun(double value);
155 +
156 +static const char *openups_scale_vin_fun(double value);
157 +static const char *openups_scale_vout_fun(double value);
158 +/* static const char *openups_scale_vbat_fun(double value); */
159 +static const char *openups_scale_ccharge_fun(double value);
160 +static const char *openups_scale_cdischarge_fun(double value);
161 +static const char *openups_temperature_fun(double value);
162 +
163 +static info_lkp_t openups_charging_info[] = {
164 +       {0, NULL, openups_charging_fun}
165 +};
166 +
167 +static info_lkp_t openups_discharging_info[] = {
168 +       {0, NULL, openups_discharging_fun}
169 +};
170 +
171 +static info_lkp_t openups_online_info[] = {
172 +       {0, NULL, openups_online_fun}
173 +};
174 +
175 +static info_lkp_t openups_nobattery_info[] = {
176 +       {0, NULL, openups_nobattery_fun}
177 +};
178 +
179 +static info_lkp_t openups_off_info[] = {
180 +       {0, NULL, openups_off_fun}
181 +};
182 +
183 +static info_lkp_t openups_vin_info[] = {
184 +       {0, NULL, openups_scale_vin_fun}
185 +};
186 +
187 +static info_lkp_t openups_vout_info[] = {
188 +       {0, NULL, openups_scale_vout_fun}
189 +};
190 +
191 +/* static info_lkp_t openups_vbat_info[] = {
192 +       {0, NULL, openups_scale_vbat_fun}
193 +};*/
194 +
195 +static info_lkp_t openups_ccharge_info[] = {
196 +       {0, NULL, openups_scale_ccharge_fun}
197 +};
198 +
199 +static info_lkp_t openups_cdischarge_info[] = {
200 +       {0, NULL, openups_scale_cdischarge_fun}
201 +};
202 +
203 +static info_lkp_t openups_temperature_info[] = {
204 +       {0, NULL, openups_temperature_fun}
205 +};
206 +
207 +static const char *openups_charging_fun(double value)
208 +{
209 +       return value ? "chrg" : "!chrg";
210 +}
211 +
212 +static const char *openups_discharging_fun(double value)
213 +{
214 +       return value ? "dischrg" : "!dischrg";
215 +}
216 +
217 +static const char *openups_online_fun(double value)
218 +{
219 +       return value ? "online" : "!online";
220 +}
221 +
222 +static const char *openups_nobattery_fun(double value)
223 +{
224 +       return value ? "nobattery" : "!nobattery";
225 +}
226 +
227 +static const char *openups_off_fun(double value)
228 +{
229 +       return value ? "!off" : "off";
230 +}
231 +
232 +static const char *openups_scale_vin_fun(double value)
233 +{
234 +       snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vin_scale);
235 +       return openups_scratch_buf;
236 +}
237 +
238 +static const char *openups_scale_vout_fun(double value)
239 +{
240 +       snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vout_scale);
241 +       return openups_scratch_buf;
242 +}
243 +
244 +/* static const char *openups_scale_vbat_fun(double value)
245 +{
246 +       snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", value * vbat_scale);
247 +       return openups_scratch_buf;
248 +}*/
249 +
250 +static const char *openups_scale_ccharge_fun(double value)
251 +{
252 +       snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.3f", value * ccharge_scale);
253 +       return openups_scratch_buf;
254 +}
255 +
256 +static const char *openups_scale_cdischarge_fun(double value)
257 +{
258 +       snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.3f", value * cdischarge_scale);
259 +       return openups_scratch_buf;
260 +}
261 +
262 +static const char *openups_temperature_fun(double value)
263 +{
264 +       int i;
265 +       int pos = -1;
266 +       unsigned int thermistor = value * 100;
267 +
268 +       if (thermistor <= therm_tbl[0]) {
269 +               snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", -40);
270 +       } else {
271 +               if (thermistor >= therm_tbl[therm_tbl_size - 1]) {
272 +                       snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", 125);
273 +               } else {
274 +                       for (i = therm_tbl_size - 1; i >= 0; i--) {
275 +                               if (thermistor >= therm_tbl[i]) {
276 +                                       pos = i;
277 +                                       break;
278 +                               }
279 +                       }
280 +
281 +                       if (thermistor == therm_tbl[pos]) {
282 +                               snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%d", pos * 5 - 40);
283 +                       } else {
284 +                               int t1 = pos * 5 - 40;
285 +                               int t2 = (pos + 1) * 5 - 40;
286 +
287 +                               unsigned int d1 = therm_tbl[pos];
288 +                               unsigned int d2 = therm_tbl[pos + 1];
289 +
290 +                               float temp = (float) (thermistor - d1) * (t2 - t1) / (d2 - d1) + t1;
291 +                               snprintf(openups_scratch_buf, sizeof(openups_scratch_buf), "%.2f", temp);
292 +                       }
293 +               }
294 +       }
295 +
296 +       return openups_scratch_buf;
297 +}
298 +
299 +/* --------------------------------------------------------------- */
300 +/*      Vendor-specific usage table */
301 +/* --------------------------------------------------------------- */
302 +
303 +/* OPENUPS usage table */
304 +static usage_lkp_t openups_usage_lkp[] = {
305 +       {"Cell1", 0x00000001},  /* Battery cell 1 on J6 pin 1 */
306 +       {"Cell2", 0x00000002},  /* Battery cell 2 on J6 pin 2 */
307 +       {"Cell3", 0x00000003},  /* Battery cell 3 on J6 pin 3 */
308 +       {"Cell4", 0x00000004},  /* Battery cell 4 on J6 pin 4 */
309 +       {"Cell5", 0x00000005},  /* Battery cell 5 on J6 pin 5 */
310 +       {"Cell6", 0x00000006},  /* Battery cell 6 on J4 pin 1 */
311 +       /* Usage table for windows monitoring app only updates when 
312 +        * certain request codes are written to USB endpoint */
313 +       /*{ "OpenUPSExtra", 0xff000001 }, */
314 +       {NULL, 0}
315 +};
316 +
317 +static usage_tables_t openups_utab[] = {
318 +       openups_usage_lkp,
319 +       hid_usage_lkp,
320 +       NULL,
321 +};
322 +
323 +/* --------------------------------------------------------------- */
324 +/* HID2NUT lookup table                                            */
325 +/* --------------------------------------------------------------- */
326 +
327 +static hid_info_t openups_hid2nut[] = {
328 +       {"ups.serial", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%s", 0, stringid_conversion},
329 +
330 +       /* Battery */
331 +       {"battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion},
332 +       {"battery.mfr.date", 0, 0, "UPS.PowerSummary.iOEMInformation", NULL, "%s", 0, stringid_conversion},
333 +       {"battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.2f", HU_FLAG_QUICK_POLL, NULL},
334 +       /* { "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info }, */
335 +       {"battery.current", 0, 0, "UPS.PowerSummary.Current", NULL, "%.3f", HU_FLAG_QUICK_POLL, NULL},
336 +       {"battery.capacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", HU_FLAG_STATIC, NULL},
337 +       {"battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
338 +       {"battery.charge.low", 0, 0, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
339 +       {"battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL},
340 +       {"battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL},
341 +       {"battery.temperature", 0, 0, "UPS.PowerSummary.Temperature", NULL, NULL, HU_FLAG_QUICK_POLL, openups_temperature_info},
342 +/*     {"battery.cell1.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell1", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
343 +       {"battery.cell2.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell2", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
344 +       {"battery.cell3.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell3", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
345 +       {"battery.cell4.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell4", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
346 +       {"battery.cell5.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell5", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
347 +       {"battery.cell6.voltage", 0, 0, "UPS.PowerSummary.Battery.Cell6", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info},
348 +*/
349 +       /* Output */
350 +       {"output.voltage", 0, 0, "UPS.PowerSummary.Output.Voltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vout_info},
351 +       {"output.current", 0, 0, "UPS.PowerSummary.Output.Current", NULL, NULL, HU_FLAG_QUICK_POLL, openups_cdischarge_info},
352 +
353 +       /* Input */
354 +       {"input.voltage", 0, 0, "UPS.PowerSummary.Input.Voltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vin_info},
355 +       {"input.current", 0, 0, "UPS.PowerSummary.Input.Current", NULL, NULL, HU_FLAG_QUICK_POLL, openups_ccharge_info},
356 +
357 +       /* Status */
358 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, HU_FLAG_QUICK_POLL, openups_off_info},
359 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, HU_FLAG_QUICK_POLL, commfault_info},
360 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, HU_FLAG_QUICK_POLL, overload_info},
361 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, HU_FLAG_QUICK_POLL, overheat_info},
362 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, HU_FLAG_QUICK_POLL, shutdownimm_info},
363 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info},
364 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, HU_FLAG_QUICK_POLL, timelimitexpired_info},
365 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, openups_charging_info},
366 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, openups_discharging_info},
367 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info},
368 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, openups_online_info},
369 +       {"BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BatteryPresent", NULL, NULL, HU_FLAG_QUICK_POLL, openups_nobattery_info},
370 +
371 +       /* end of structure. */
372 +       {NULL, 0, 0, NULL, NULL, NULL, 0, NULL}
373 +};
374 +
375 +static const char *openups_format_model(HIDDevice_t * hd)
376 +{
377 +       return hd->Product;
378 +}
379 +
380 +static const char *openups_format_mfr(HIDDevice_t * hd)
381 +{
382 +       return hd->Vendor ? hd->Vendor : "openUPS";
383 +}
384 +
385 +static const char *openups_format_serial(HIDDevice_t * hd)
386 +{
387 +       return hd->Serial;
388 +}
389 +
390 +/* this function allows the subdriver to "claim" a device: return 1 if
391 + * the device is supported by this subdriver, else 0. */
392 +static int openups_claim(HIDDevice_t * hd)
393 +{
394 +       int status = is_usb_device_supported(openups_usb_device_table, hd);
395 +
396 +       switch (status) {
397 +       case POSSIBLY_SUPPORTED:
398 +               /* by default, reject, unless the productid option is given */
399 +               if (getval("productid")) {
400 +                       return 1;
401 +               }
402 +               possibly_supported("openUPS", hd);
403 +               return 0;
404 +
405 +       case SUPPORTED:
406 +               return 1;
407 +
408 +       case NOT_SUPPORTED:
409 +       default:
410 +               return 0;
411 +       }
412 +}
413 +
414 +subdriver_t openups_subdriver = {
415 +       OPENUPS_HID_VERSION,
416 +       openups_claim,
417 +       openups_utab,
418 +       openups_hid2nut,
419 +       openups_format_model,
420 +       openups_format_mfr,
421 +       openups_format_serial,
422 +};
423 diff --git a/drivers/openups-hid.h b/drivers/openups-hid.h
424 new file mode 100644
425 index 0000000..c87b3d1
426 --- /dev/null
427 +++ b/drivers/openups-hid.h
428 @@ -0,0 +1,38 @@
429 +/* openups-hid.h - subdriver to monitor Minibox openUPS USB/HID devices with NUT
430 + *
431 + *  Copyright (C)
432 + *  2003 - 2009        Arnaud Quette <ArnaudQuette@Eaton.com>
433 + *  2005 - 2006        Peter Selinger <selinger@users.sourceforge.net>
434 + *  2008 - 2009        Arjen de Korte <adkorte-guest@alioth.debian.org>
435 + *         2012        Nicu Pavel <npavel@mini-box.com>
436 + *
437 + *  This program is free software; you can redistribute it and/or modify
438 + *  it under the terms of the GNU General Public License as published by
439 + *  the Free Software Foundation; either version 2 of the License, or
440 + *  (at your option) any later version.
441 + *
442 + *  This program is distributed in the hope that it will be useful,
443 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
444 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
445 + *  GNU General Public License for more details.
446 + *
447 + *  You should have received a copy of the GNU General Public License
448 + *  along with this program; if not, write to the Free Software
449 + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
450 + */
451 +
452 +#ifndef OPENUPS_HID_H
453 +#define OPENUPS_HID_H
454 +
455 +#include "usbhid-ups.h"
456 +
457 +/* constants for converting HID read values to real values */
458 +static const float vin_scale = 0.03545 * 100;
459 +static const float vout_scale = 0.02571 * 100;
460 +static const float vbat_scale = 0.00857 * 100;
461 +static const float ccharge_scale = 0.8274 / 10;
462 +static const float cdischarge_scale = 16.113 / 10;
463 +
464 +extern subdriver_t openups_subdriver;
465 +
466 +#endif /* OPENUPS_HID_H */
467 diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c
468 index 2d254c4..fcf628d 100644
469 --- a/drivers/usbhid-ups.c
470 +++ b/drivers/usbhid-ups.c
471 @@ -27,7 +27,7 @@
472   */
473  
474  #define DRIVER_NAME    "Generic HID driver"
475 -#define DRIVER_VERSION         "0.37"
476 +#define DRIVER_VERSION         "0.38"
477  
478  #include "main.h"
479  #include "libhid.h"
480 @@ -37,6 +37,7 @@
481  
482  /* include all known subdrivers */
483  #include "mge-hid.h"
484 +
485  #ifndef SHUT_MODE
486         #include "explore-hid.h"
487         #include "apc-hid.h"
488 @@ -46,6 +47,7 @@
489         #include "powercom-hid.h"
490         #include "tripplite-hid.h"
491         #include "idowell-hid.h"
492 +       #include "openups-hid.h"
493  #endif
494  
495  /* master list of avaiable subdrivers */
496 @@ -62,6 +64,7 @@ static subdriver_t *subdriver_list[] = {
497         &powercom_subdriver,
498         &tripplite_subdriver,
499         &idowell_subdriver,
500 +       &openups_subdriver,
501  #endif
502         NULL
503  };
504 diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules
505 index a9e18fe..c57ef75 100644
506 --- a/scripts/upower/95-upower-hid.rules
507 +++ b/scripts/upower/95-upower-hid.rules
508 @@ -15,6 +15,7 @@ ENV{DEVTYPE}=="usb_interface", GOTO="up_hid_end"
509  ATTRS{idVendor}=="03f0", ENV{UPOWER_VENDOR}="Hewlett Packard"
510  ATTRS{idVendor}=="0463", ENV{UPOWER_VENDOR}="Eaton"
511  ATTRS{idVendor}=="047c", ENV{UPOWER_VENDOR}="Dell"
512 +ATTRS{idVendor}=="04d8", ENV{UPOWER_VENDOR}="Minibox"
513  ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin"
514  ATTRS{idVendor}=="051d", ENV{UPOWER_VENDOR}="APC"
515  ATTRS{idVendor}=="0592", ENV{UPOWER_VENDOR}="Powerware"
516 @@ -47,6 +48,9 @@ ATTRS{idVendor}=="0463", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups
517  # Dell
518  ATTRS{idVendor}=="047c", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups"
519  
520 +# Minibox
521 +ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="d004", ENV{UPOWER_BATTERY_TYPE}="ups"
522 +
523  # Belkin
524  ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0375", ENV{UPOWER_BATTERY_TYPE}="ups"
525  ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0551", ENV{UPOWER_BATTERY_TYPE}="ups"
526 -- 
527 1.8.0
528