[Nut-upsuser] Newpoint 200897 UPS
Daniel Gimpelevich
daniel at gimpelevich.san-francisco.ca.us
Sat Dec 30 17:57:04 CET 2006
I got sick & tired of constant power outages with no warning, so when I
saw various UPSes at the store, I decided to get one, and the one I got
was a model 200897 from Newpoint (a.k.a. Power Sentry). A couple of days
later the power went out and I decided to use the opportunity to hook up
the UPS. I added up the wattages of the equipment I would be connecting,
and found that the only way I would not overload the device would be not
to connect the monitor to it (it's a CRT). Furthermore, I had no real
choice but to go against the very stern warning for UL compliance on the
Newpoint website against daisy-chaining surge-suppression devices by
plugging the UPS into the Woods Industries model 5187 Surge Protector that
I had been using for many years. The UPS came with UPSMON software for
Windows, NetWare, and Linux-i386, but nothing for Mac OS 10.3.9, so I
started searching the web for something I could use instead. The only
suitable thing I found was NUT. After finding that there is no NUT package
for Fink (on Panther), I thought I'd perhaps create one, but first get the
software actually working. I downloaded version 2.0.5-pre1 and installed
it, following the instructions on the NUT website, adjusting the *nix-isms
for OS X as I went along. Then, I found that I also had to follow the
instructions in the hid-subdrivers.txt file, and the source file
generated, as modified per instructions, is pasted in its entirety at the
end of this message. When I typed "upsc newpoint at localhost" afterwards, I
got output that was not particularly useful, and I'm not sure where to go
from here. Here is all the output:
driver.name: newhidups
driver.parameter.port: auto
driver.parameter.vendorid: 0d9f
driver.version: 2.0.5-pre1
ups.delay.shutdown: 0
ups.delay.start: 0
ups.mfr: Powercom
UPS.PowerConverter.ShutdownRequested: 2
ups.serial:
ups.test.result: Done and passed
Here is the source file:
/* 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[] = {
{ "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 }
};
static usage_tables_t powercom_utab[] = {
powercom_usage_lkp,
hid_usage_lkp,
NULL,
};
/* --------------------------------------------------------------- */
/* HID2NUT lookup table */
/* --------------------------------------------------------------- */
static hid_info_t powercom_hid2nut[] = {
{ "ups.serial", 0, 0, "PowercomUPS.PowercomSerialNumber", NULL, "%s", HU_FLAG_OK, stringid_conversion },
{ "ups.mfr", 0, 0, "PowercomUPS.PowercomManufacturerName", NULL, "%s", HU_FLAG_OK, stringid_conversion },
{ "UPS.DesignCapacity", 0, 0, "PowercomUPS.PowercomDesignCapacity", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "ups.mfr.date", 0, 0, "PowercomUPS.PowercomManufacturerDate", NULL, "%s", HU_FLAG_OK, date_conversion },
{ "battery.temperature", 0, 0, "PowercomUPS.PowercomBatterySystem.PowercomTemperature", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "battery.voltage", 0, 0, "PowercomUPS.PowercomBatterySystem.PowercomVoltage", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "UPS.BatterySystem.SpecificationInfo", 0, 0, "PowercomUPS.PowercomBatterySystem.PowercomSpecificationInfo", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "input.frequency", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomInput.PowercomFrequency", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "input.voltage", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomInput.PowercomVoltage", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "output.voltage", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomOutput.PowercomVoltage", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "ups.load", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomOutput.PowercomPercentLoad", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "UPS.PowerConverter.Output.InternalChargeController", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomOutput.PowercomInternalChargeController", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "UPS.PowerConverter.Output.PrimaryBatterySupport", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomOutput.PowercomPrimaryBatterySupport", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "output.frequency", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomOutput.PowercomFrequency", NULL, "%.1f", HU_FLAG_OK, NULL },
{ "ups.test.result", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomTest", NULL, "%s", HU_FLAG_OK, test_read_info },
{ "UPS.PowerConverter.ShutdownRequested", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomShutdownRequested", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "ups.delay.shutdown", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomDelayBeforeShutdown", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "ups.delay.start", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomDelayBeforeStartup", NULL, "%.0f", HU_FLAG_OK, NULL },
{ "load.off", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomDelayBeforeShutdown", NULL, "0", HU_TYPE_CMD | 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) {
char delay[7];
/* 1) set DelayBeforeStartup */
sprintf(delay, "%i", ondelay);
if (setvar("ups.delay.start", delay) != STAT_SET_HANDLED) {
upsdebugx(2, "Shutoff command failed (setting ondelay)");
return 0;
}
/* 2) set DelayBeforeShutdown */
sprintf(delay, "%i", offdelay);
if (setvar("ups.delay.shutdown", delay) == STAT_SET_HANDLED) {
return 1;
}
upsdebugx(2, "Shutoff command failed (setting 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