[Nut-upsuser] Re: Newpoint 200897 UPS

Peter Selinger selinger at mathstat.dal.ca
Sun Dec 31 07:47:03 CET 2006


Daniel Gimpelevich wrote:
> 
> On Sat, 30 Dec 2006 15:15:45 -0400, Peter Selinger wrote:
> 
> > Hi Daniel,
> > 
> > we have seen device 0d9f/0001 before (possibly under a different name,
> > but this is common), and as far as I remember we could not get it to
> > work. See the thread named "Gentoo Ultra USB UPS" on nut-upsuser in
> > July/August 2006.
> 
> Thank you for pointing me to that thread. I did not see it before.
> 
> >> /* POWERCOM usage table */
> >> static usage_lkp_t powercom_usage_lkp[] = {
> >> 	{ "PowercomUPS",			0x00020004 },
> >> 	{ "PowercomBatterySystem",		0x00020010 },
> >> 	{ "PowercomPowerConverter",		0x00020016 },
> >> 	{ "PowercomInput",			0x0002001a },
> >> 	{ "PowercomOutput",			0x0002001c },
> >> 	{ "PowercomVoltage",			0x00020030 },
> >> 	{ "PowercomFrequency",			0x00020032 },
> >> 	{ "PowercomPercentLoad",		0x00020035 },
> >> 	{ "PowercomTemperature",		0x00020036 },
> >> 	{ "PowercomDelayBeforeStartup",		0x00020056 },
> >> 	{ "PowercomDelayBeforeShutdown",	0x00020057 },
> >> 	{ "PowercomTest",			0x00020058 },
> >> 	{ "PowercomShutdownRequested",		0x00020068 },
> >> 	{ "PowercomInternalChargeController",	0x00020081 },
> >> 	{ "PowercomPrimaryBatterySupport",	0x00020082 },
> >> 	{ "PowercomDesignCapacity",		0x00020083 },
> >> 	{ "PowercomSpecificationInfo",		0x00020084 },
> >> 	{ "PowercomManufacturerDate",		0x00020085 },
> >> 	{ "PowercomSerialNumber",		0x00020086 },
> >> 	{ "PowercomManufacturerName",		0x00020087 },
> >> 	{  "\0", 0x0 }
> >> };
> > 
> > Wow, we didn't have this information before. Is it reliable? Did you
> > get this experimentally, or by matching the similar codes in
> > drivers/libhid.c?
> 
> I got this information using the instructions in hid-subdrivers.txt
> exclusively, particularly the part that says where to find usage tables.

Then these names are probably not accurate. The USB standard defines
usages for pages 0084 and 0085; this manufacturer uses a private page
0002, so the usages are likely not the same. 

> >> What was the output that you got from 
> >> drivers/newhidups -DD -u root -x explore -x vendorid=XXXX auto
> >>
> >> Would be useful to know if it is indeed similar to the device we saw
> >> in July/August. The tree back then was:
> >> 
> >> Path: 00020004.00020086, Type: Feature, Value: 130.000000
> >> Path: 00020004.00020087, Type: Feature, Value: 4.000000
> >> Path: 00020004.00020083, Type: Input
> >> Path: 00020004.00020085, Type: Input
> >> Path: 00020004.00020010.00020036, Type: Input
> >> Path: 00020004.00020010.00020030, Type: Input
> >> Path: 00020004.00020010.00020084, Type: Input
> >> Path: 00020004.00020016.0002001a.00020032, Type: Input
> >> Path: 00020004.00020016.0002001a.00020030, Type: Input
> >> Path: 00020004.00020016.0002001c.00020030, Type: Input
> >> Path: 00020004.00020016.0002001c.00020035, Type: Input
> >> Path: 00020004.00020016.0002001c.00020081, Type: Input
> >> Path: 00020004.00020016.0002001c.00020082, Type: Input
> >> Path: 00020004.00020016.0002001c.00020032, Type: Input
> >> Path: 00020004.00020016.00020058, Type: Feature, Value: 1.000000
> >> Path: 00020004.00020016.00020068, Type: Feature, Value: 2.000000
> >> Path: 00020004.00020016.00020057, Type: Feature, Value: 0.000000
> >> Path: 00020004.00020016.00020056, Type: Feature, Value: 0.000000
> >> 
> >> Note that NUT was unable to read values of any of the "Inputs"; only
> >> the "Features" have readable values. Also note that 130 is an unlikely
> >> value for "SerialNumber". 
> > 
> > Well, I don't know what to say about that. The serial number printed on
> > the box it came in is 20096230603, and as you could see, upsc reported an
> > empty string for it.
> 
> Well, i decided to run that line again, but mind you that upsd and
> the powercom-hid driver were already running this time. Here are the
> guts of the output:

Cleaning this up a little, here's what you have got:

Path: 00020004.00020086, Type: Feature, Value: 128.000000
Path: 00020004.00020087, Type: Feature, Value: 180.000000
Path: 00020004.00020083, Type: Input
Path: 00020004.00020085, Type: Input
Path: 00020004.00020010.00020036, Type: Input
Path: 00020004.00020010.00020030, Type: Input
Path: 00020004.00020010.00020084, Type: Input
Path: 00020004.00020016.0002001a.00020032, Type: Input
Path: 00020004.00020016.0002001a.00020030, Type: Input
Path: 00020004.00020016.0002001c.00020030, Type: Input
Path: 00020004.00020016.0002001c.00020035, Type: Input
Path: 00020004.00020016.0002001c.00020081, Type: Input
Path: 00020004.00020016.0002001c.00020082, Type: Input
Path: 00020004.00020016.0002001c.00020032, Type: Input
Path: 00020004.00020016.00020058, Type: Feature, Value: 1.000000
Path: 00020004.00020016.00020068, Type: Feature, Value: 2.000000
Path: 00020004.00020016.00020057, Type: Feature, Value: 0.000000
Path: 00020004.00020016.00020056, Type: Feature, Value: 0.000000

This really seems identical to the August device. 00020004.00020086
seems to me to be a voltage. I am not sure what 00020004.00020087
might be, but it could be a flag set (180 = 128 + 32 + 16 + 4).

It doesn't look like newhidups is able to get any useful info from
this device, unless we can somehow read the "on battery" and "low
battery" status flags from 00020004.00020087 and
00020004.00020016.00020058...00020056. It might be worthwhile to
monitor these variables through some UPS status changes (on battery,
low battery).  You might have better luck with the unmodified
powercom-hid.[ch] (attached) generated by path-to-subdriver.sh, as
your modifications convert some of these values to strings and/or
other specialized datatypes that may not be appropriate for them.

-- Peter
-------------- next part --------------
/* powercom-hid.h - subdriver to monitor Powercom 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 POWERCOM_HID_H
#define POWERCOM_HID_H

#include "newhidups.h"

#define POWERCOM_HID_VERSION	"Powercom HID 0.1"

extern subdriver_t powercom_subdriver;

#endif /* POWERCOM_HID_H */
-------------- next part --------------
/* powercom-hid.c - subdriver to monitor Powercom 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 "powercom-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 POWERCOM_HID_VERSION      "Powercom HID 0.1"

#define POWERCOM_VENDORID 0x0d9f

/* --------------------------------------------------------------- */
/*      Vendor-specific usage table */
/* --------------------------------------------------------------- */

/* POWERCOM usage table */
static usage_lkp_t powercom_usage_lkp[] = {
	{ "POWERCOM1",	0x00020004 },
	{ "POWERCOM2",	0x00020010 },
	{ "POWERCOM3",	0x00020016 },
	{ "POWERCOM4",	0x0002001a },
	{ "POWERCOM5",	0x0002001c },
	{ "POWERCOM6",	0x00020030 },
	{ "POWERCOM7",	0x00020032 },
	{ "POWERCOM8",	0x00020035 },
	{ "POWERCOM9",	0x00020036 },
	{ "POWERCOM10",	0x00020056 },
	{ "POWERCOM11",	0x00020057 },
	{ "POWERCOM12",	0x00020058 },
	{ "POWERCOM13",	0x00020068 },
	{ "POWERCOM14",	0x00020081 },
	{ "POWERCOM15",	0x00020082 },
	{ "POWERCOM16",	0x00020083 },
	{ "POWERCOM17",	0x00020084 },
	{ "POWERCOM18",	0x00020085 },
	{ "POWERCOM19",	0x00020086 },
	{ "POWERCOM20",	0x00020087 },
	{  "\0", 0x0 }
};

static usage_tables_t powercom_utab[] = {
	powercom_usage_lkp,
	hid_usage_lkp,
	NULL,
};

/* --------------------------------------------------------------- */
/* HID2NUT lookup table                                            */
/* --------------------------------------------------------------- */

static hid_info_t powercom_hid2nut[] = {

  { "unmapped.powercom1.powercom19", 0, 0, "POWERCOM1.POWERCOM19", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom20", 0, 0, "POWERCOM1.POWERCOM20", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom16", 0, 0, "POWERCOM1.POWERCOM16", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom18", 0, 0, "POWERCOM1.POWERCOM18", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom2.powercom9", 0, 0, "POWERCOM1.POWERCOM2.POWERCOM9", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom2.powercom6", 0, 0, "POWERCOM1.POWERCOM2.POWERCOM6", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom2.powercom17", 0, 0, "POWERCOM1.POWERCOM2.POWERCOM17", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom4.powercom7", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM4.POWERCOM7", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom4.powercom6", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM4.POWERCOM6", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom5.powercom6", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM5.POWERCOM6", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom5.powercom8", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM5.POWERCOM8", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom5.powercom14", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM5.POWERCOM14", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom5.powercom15", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM5.POWERCOM15", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom5.powercom7", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM5.POWERCOM7", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom12", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM12", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom13", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM13", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom11", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM11", NULL, "%.0f", HU_FLAG_OK, NULL },
  { "unmapped.powercom1.powercom3.powercom10", 0, 0, "POWERCOM1.POWERCOM3.POWERCOM10", NULL, "%.0f", HU_FLAG_OK, NULL },

  /* end of structure. */
  { NULL, 0, 0, NULL, NULL, NULL, 0, NULL }
};

/* shutdown method for Powercom */
static int powercom_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 *powercom_format_model(HIDDevice *hd) {
	return hd->Product;
}

static char *powercom_format_mfr(HIDDevice *hd) {
	return hd->Vendor ? hd->Vendor : "Powercom";
}

static char *powercom_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 powercom_claim(HIDDevice *hd) {
	if (hd->VendorID != POWERCOM_VENDORID) {
		return 0;
	}
	switch (hd->ProductID) {

	/* accept any known UPS - add devices here as needed */
	case 0001:
		return 1;

	/* by default, reject, unless the productid option is given */
	default:
		if (getval("productid")) {
			return 1;
		} else {
			upsdebugx(1,
"This particular powercom 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 powercom_subdriver = {
	POWERCOM_HID_VERSION,
	powercom_claim,
	powercom_utab,
	powercom_hid2nut,
	powercom_shutdown,
	powercom_format_model,
	powercom_format_mfr,
	powercom_format_serial,
};


More information about the Nut-upsuser mailing list