/* usbhid-ups.h - Driver for serial/USB HID UPS units * * Copyright (C) * 2003-2009 Arnaud Quette * 2005-2006 Peter Selinger * 2007-2009 Arjen de Korte * * This program was sponsored by MGE UPS SYSTEMS, and now Eaton * * 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 USBHID_UPS_H #define USBHID_UPS_H #include #include #include #include #include "config.h" #include "libhid.h" extern hid_dev_handle_t udev; extern bool_t use_interrupt_pipe; /* Set to FALSE if interrupt reports should not be used */ /* Driver's parameters */ #define HU_VAR_LOWBATT "lowbatt" #define HU_VAR_ONDELAY "ondelay" #define HU_VAR_OFFDELAY "offdelay" #define HU_VAR_POLLFREQ "pollfreq" /* Parameters default values */ #define DEFAULT_LOWBATT "30" /* percentage of battery charge to consider the UPS in low battery state */ #define DEFAULT_ONDELAY "30" /* Delay between return of utility power */ /* and powering up of load, in seconds */ /* CAUTION: ondelay > offdelay */ #define DEFAULT_OFFDELAY "20" /* Delay before power off, in seconds */ #define DEFAULT_POLLFREQ 30 /* Polling interval, in seconds */ /* The driver will wait for Interrupt */ /* and do "light poll" in the meantime */ #ifndef MAX_STRING_SIZE #define MAX_STRING_SIZE 128 #endif /* --------------------------------------------------------------- */ /* Struct & data for lookup between HID and NUT values */ /* (From USB/HID, Power Devices Class standard) */ /* --------------------------------------------------------------- */ typedef struct { const long hid_value; /* HID value */ const char *nut_value; /* NUT value */ const char *(*fun)(double hid_value); /* optional HID to NUT mapping */ double (*nuf)(const char *nut_value); /* optional NUT to HID mapping */ } info_lkp_t; /* accessor on the status */ extern unsigned ups_status_get(void); /* declarations of public lookup tables */ /* boolean status values from UPS */ extern info_lkp_t online_info[]; extern info_lkp_t discharging_info[]; extern info_lkp_t charging_info[]; extern info_lkp_t lowbatt_info[]; extern info_lkp_t overload_info[]; extern info_lkp_t replacebatt_info[]; extern info_lkp_t trim_info[]; extern info_lkp_t boost_info[]; extern info_lkp_t bypass_auto_info[]; extern info_lkp_t bypass_manual_info[]; extern info_lkp_t off_info[]; extern info_lkp_t calibration_info[]; extern info_lkp_t nobattery_info[]; extern info_lkp_t fanfail_info[]; extern info_lkp_t shutdownimm_info[]; extern info_lkp_t overheat_info[]; extern info_lkp_t awaitingpower_info[]; extern info_lkp_t commfault_info[]; extern info_lkp_t timelimitexpired_info[]; extern info_lkp_t battvoltlo_info[]; extern info_lkp_t battvolthi_info[]; extern info_lkp_t chargerfail_info[]; extern info_lkp_t emergency_stop_info[]; extern info_lkp_t fullycharged_info[]; extern info_lkp_t depleted_info[]; /* input.transfer.reason */ extern info_lkp_t vrange_info[]; extern info_lkp_t frange_info[]; /* non specific */ extern info_lkp_t test_write_info[]; extern info_lkp_t test_read_info[]; extern info_lkp_t beeper_info[]; extern info_lkp_t yes_no_info[]; extern info_lkp_t on_off_info[]; extern info_lkp_t date_conversion[]; extern info_lkp_t hex_conversion[]; extern info_lkp_t stringid_conversion[]; extern info_lkp_t divide_by_10_conversion[]; extern info_lkp_t kelvin_celsius_conversion[]; /* ---------------------------------------------------------------------- */ /* data for processing boolean values from UPS */ #define STATUS(x) ((unsigned)1<