~ubuntu-branches/ubuntu/saucy/nut/saucy

« back to all changes in this revision

Viewing changes to drivers/apcsmart.h

  • Committer: Chuck Short
  • Date: 2013-05-13 12:57:25 UTC
  • Revision ID: zulcss@ubuntu.com-20130513125725-llq8wsohyhq9idsy
* Merge from Debian.  Remaining changes:
  - debian/control:
    + remove Build-Depends on libpowerman0-dev
    + remove nut-powerman-pdu
  - debian/nut-powerman-pdu.{install,manpages}: dropped for now
  - debian/{nut-cgi,nut-server}.postinst: add nut to the dialout and nut
    groups unconditonally to handle the upgrade from hardy release.
  - debian/source_nut.py, debian/{nut,nut-server,nut-client}.install,
    debian/rules: Install apport hooks for all top-level nut packages.
  - debian/rules: Use udev version for Ubuntu
  - debian/series, debian/patches/backport-fix-lp753661.patch: re-enabled
* Non-maintainer upload with fixes for wheezy.
* debian/nut-client.preinst: also revert /etc/nut/nut.conf mangling done
  by postinst during upgrade from lenny to squeeze (Really closes: #677054)
  Thanks to Andreas Beckmann for the review.
* Merge from Debian.  Remaining changes:
  - debian/control:
    + remove Build-Depends on libpowerman0-dev
    + remove nut-powerman-pdu
  - debian/nut-powerman-pdu.{install,manpages}: dropped for now
  - debian/{nut-cgi,nut-server}.postinst: add nut to the dialout and nut
    groups unconditonally to handle the upgrade from hardy release.
  - debian/source_nut.py, debian/{nut,nut-server,nut-client}.install,
    debian/rules: Install apport hooks for all top-level nut packages.
  - debian/rules: Use udev version for Ubuntu
  - debian/series, debian/patches/backport-fix-lp753661.patch: re-enabled
* Dropped the following patches, no longer required:
  - debian/patches/CVE-2012-2944.patch (included upstream)
* Non-maintainer upload with fixes for wheezy.
* Only remove /etc/init.d/nut from previous versions of nut in nut-server
  postinst if there are no local changes.
* Also remove /etc/init.d/nut in nut-client postinst. Thanks to 
  Laurent Bigonville for the hint.
* Only fix permissions of configfiles on first install.
* debian/control: Fix typo in package description. Thanks to Julien Cristau
  for spotting this.
* Non-maintainer upload.
* debian/nut-client.preinst: revert /etc/nut/nut.conf mangling done by older
  versions of the postinst (Closes: #677054)
* debian/rules: Stop the nut-client before nut-server on systems using
  static
  boot ordering (Closes: #679451)
* debian/nut-server.postinst: Remove /etc/init.d/nut on upgrade
  (Closes: #677822)
* Rename nut-server.lintian-overrides to nut-client.lintian-overrides and
  adjust overrides now that ups-monitor is shipped in nut-client package
  (Closes: #677947)
* Add debian/patches/0001-fix-upsmon-regression.patch: Fix upsmon/upssched
  regression (Taken from upstream) (Closes: #679513)
* Move nut metapackage to Section: metapackages
* Also create nut user when installing nut-client package and do not delete
  it on purge anymore (Closes: #682000)
* Drop /etc/default/nut → /etc/nut/nut.conf migration code, migration
  happends before squeeze release and this was against policy to have a
  maintainer script modifying a conffile in the first place (Closes: #684392)
* Add dependency against adduser and lsb-base on nut-client package
* Be sure that client is stopped before the server also when using
  dependencies based boot
* Fix package descriptions (Closes: #678068)
* Also install /bin/upssched-cmd in nut-client package as this script is
  referenced in default upssched.conf config file
* debian/watch: Update watch file
* Be sure that all maintainer scripts are returning 0 at their end
* New upstream release (Closes: #671444)
* acknowledges NMU (Closes: #613643)
* debian/nut-client.init: fix action "start" and use of log_*_*msg
  LSB log functions (Closes: #675619)
* debian/nut-server.preinst: remove obsolete file(s) left in
  /etc/udev/rules.d and related processing: udev files are now located
  in /lib/udev/rules, and there is no reason to modify the dedicated
  USB UPS rules (52-nut-usbups.rules) (Closes: #660072)
* debian/nut-server.init: rewrite to match upsd / drivers startup scope
* debian/nut-client.init: created to match upsmon startup scope
  (Closes: #634858)
* debian/nut.TODO.Debian, debian/Makefile.am: updated to reflect the above
* debian/rules: install nut-client.init, and update to reflect the above
* debian/control, debian/Makefile.am: updated to reflect the above
* debian/control:
  - add Breaks on nut-server (<< 2.6.3-1~)
  - bump Standards-Version to 3.9.3
* debian/nut-client.links: renamed from debian/nut-server.links, since
  ups-monitor is now provided by nut-client initscript
* debian/nut.README.Debian: renamed from nut-server.README.Debian,
  to provide it with both client and server packages
* debian/nut-server.install: add missing drivers (clone-outlet,
  liebert-esp2 and microdowell)
* debian/nut-server.manpages: add missing manual pages (apcsmart-old,
  ivtscd, liebert-esp2 and microdowell)
* SECURITY UPDATE: remote denial of service
 - debian/CVE-2012-2944.patch: limit the set of parsed characters to ' '
   through '~'
 - CVE-2012-2944
* Merge from Debian testing.  Remaining changes:
  - debian/control: Drop Build-Depends on libpowerman0-dev (currently in 
    universe)
  - debian/{nut-cgi,nut-server}.postinst: add nut to the dialout and nut 
    groups unconditonally to handle the upgrade from hardy release.
  - debian/nut-powerman-pdu.{install,manpages}: dropped for now.
  - debian/source_nut.py, debian/{nut,nut-server,nut-client}.install, 
    debian/rules: Install apport hooks for all top-level nut packages.
  - debian/rules: Use udev version for Ubuntu.
  - debian/series, debian/patches/backport-fix-lp753661.patch: re-enabled.
* New upstream release (Closes: #635186, #598741, #633756, #638221)
* debian/nut-server.{install,manpages}: add richcomm_usb
* debian/nut-server.install, debian/rules: install Avahi service file
* debian/rules, nut-client.install: install Augeas lenses
* debian/nut-server.README.Debian: clarify udev explanation (Closes: #529664)
* debian/patches/0001-fix_spelling_and_typo.patch,
  debian/patches/0003-libupsclient-version.patch: removed since these are now
  fixed upstream
* debian/patches/series: updated
* Merge from debian unstable.  Remaining changes:
  - debian/control: Drop Build-Depends on libpowerman0-dev (currently in 
    universe)
  - debian/{nut-cgi,nut-server}.postinst: add nut to the dialout and nut 
    groups unconditonally to handle the upgrade from hardy release.
  - debian/nut-powerman-pdu.{install,manpages}: dropped for now.
  - debian/source_nut.py, debian/{nut,nut-server,nut-client}.install, 
    debian/rules: Install apport hooks for all top-level nut packages.
  - debian/rules: Use udev version for Ubuntu.
  - debian/series, debian/patches/backport-fix-lp753661.patch: re-enabled.
* New upstream release (Closes: #594989)
* debian/control:
  - remove legacy Build-Depends for nut-hal-drivers on libdbus and libglib
  - Build-Depends-Indep on docbook-xsl for offline document
    generation (Closes: #635347)
* debian/nut-server.install: add apcsmart-old
* debian/nut-server.init:
  - add udev as Required-Start/Stop (Closes: #642412)
  - remove legacy support for /etc/default/nut (Closes: #638021)
* debian/patches/0003-libupsclient-version.patch: added to fix the missing
  libupsclient version info bump
* debian/libupsclient1-dev.links: update link name
* debian/libupsclient1.symbols: add with upscli_tryconnect
* debian/nut.TODO.Debian: update and complete the TODO list
* Fix FTBFS for Ubuntu (LP: #815760):
  - debian/control: Build-Depends-Indep on docbook-xsl for offline 
    document generation.
* Merge from Debian unstable (LP: #811976). Remaining changes:
  - debian/control: Drop Build-Depends on libpowerman0-dev (currently in 
    universe)
  - debian/{nut-cgi,nut-server}.postinst: add nut to the dialout and nut 
    groups unconditonally to handle the upgrade from hardy release.
  - debian/nut-powerman-pdu.{install,manpages}: dropped for now.
  - debian/source_nut.py, debian/{nut,nut-server,nut-client}.install, 
    debian/rules: Install apport hooks for all top-level nut packages.
  - debian/rules: Use udev version for Ubuntu.
  - debian/series, debian/patches/backport-fix-lp753661.patch: re-enabled.
* debian/nut.README.Debian: Adjust udev rules naming for permissions override
  (Closes: #529664)
* Re-add and refresh debian/patches/0001-fix_spelling_and_typo.patch:
  Some typos and spelling errors remain.
* Split nut package into nut-client and nut-server, keep nut package as
  metapackage
* Generate PDF and html doc and install it in nut-doc package
* debian/rules:
  - List non-installed files
  - Includes python-module.mk
  - Add flags to build documentation and install it
* debian/control:
  - Add python-nut package and add python build-dependency
  - Set nut-powerman-pdu priority to extras
  - Add nut-monitor package
  - Add nut-doc package and add required C/R/P
  - Add libups-nut-perl package
* debian/nut-server.prerm: Remove /var/run/nut during removal
* Merge from debian unstable.  Remaining changes:
  - debian/control:
    + Drop Build-Depends on libpowerman0-dev (currently in universe)
  - debian/{nut-cgi,nut}.postinst: add nut to the dialout and nut groups
    unconditonally to handle the upgrade from hardy release.
  - debian/nut-powerman-pdu.{install,manpages}: dropped for now.
  - debian/source_nut.py, debian/nut.install, debian/rules: Install apport hook.
  - debian/rules: Use udev version for Ubuntu.
* debian/patches/backport-fix-lp753661.patch: Refreshed.
* Drop changes due to .pc being not clean.
* New upstream release (Closes: #595953, #614842, #595773)
* debian/patches/*.patch: removed since these are now fixed upstream
* Drop HAL package and build-dependencies (Closes: #613197)
* debian/control:
  - Bump Standards-Version to 3.9.2 (no further changes)
  - Drop autotools build-dependencies (not needed anymore)
  - Drop non-existing build-dependencies
* debian/rules:
  - Correctly pass flags to configure
* Merge from debian unstable (LP: #789323).  Remaining changes:
  + debian/control:
    - Update maintainer as per spec.
    - Add Breaks on nut-hal-drivers to ensure we have correct udev version.
    - Drop libpowerman0-dev from the Build-Depends (currently in universe)
  + debian/{nut-cgi,nut}.postinst: add nut to the dialout and nut groups
    unconditonally to handle the upgrade from hardy release.
  + debian/nut-powerman-pdu.install, debian/nut-powerman-pdu.manpages: dropped for now.
  + debian/nul-hal-drivers.{docs,install,postinst,preinst}: Dropped since hal is in universe now
  + debian/nut.links: must create the init script link, used if the upse needs to be powered down
    (LP: #357583)
  + debian/source_nut.py, debian/nut.install, debian/rules: Install apport hook.
  + debian/patches/backport-fix-lp753661.patch
  + Dropped:
    - debian/patches/fix_pc_file.patch: replaced by debian's 0002-fix_libupsclient_pc.patch
* debian/patches/fix_pc_file.patch: add DEP3 patch header
* debian/patches/debian-changes-2.6.0-1: remove that accidental file
* debian/nut-snmp.docs: Distribute snmp.txt doc file (Closes: #548295)
* d/p/0001-fix_spelling_and_typo.patch: Update and refresh
* debian/nut.lintian-overrides: Fix typo
* debian/patch/0002-fix_libupsclient_pc.patch: Fix libupsclient.pc (Closes:
  #624255)
* debian/rules:
  - Switch to cdbs
  - Remove not existing configure options (Closes: #611813)
  - Drop Phony rules (Closes: #613699)
* debian/control:
  - Add cdbs build-dependency
* debian/patches/backport-fix-lp753661.patch: Backport fix 
  to trim extraneous end-of-line, in buggy HID string tables, 
  which results in upsc breaking the communication pipe.
  (LP: #753661)
* fix_pc_file.patch: fix .pc source files by using LIBSSL_LIBS instead of
  LIBSSL_LDFLAGS to avoid a FTBFS in packages that uses libupsclient.pc
  (LP: #743484)
* Merge from Debian unstable, remaining changes:
  + debian/control:
    - Update maintainer as per spec.
    - Add Breaks on nut-hal-drivers to ensure we have correct udev version.
    - Drop libpowerman0-dev from the Build-Depends (currently in universe)
  + debian/{nut-cgi,nut}.postinst: add nut to the dialout and nut groups
    unconditonally to hanle the upgrade from hardy release.
  + debian/nut-powerman-pdu.install, debian/nut-powerman-pdu.manpages: dropped for now.
  + debian/nul-hal-drivers.{docs,install,postinst,preinst}: Dropped since hal is in universe now
  + debian/nut.links: must create the init script link, used if the upse needs to be powered down
    (LP: #357583)
  + debian/source_nut.py, debian/nut.install, debian/rules: Install apport hook.
  + Dropped:
    - debian/patches/0002-fix_udev_action.patch: Accepted upstream.
    - debian/patches/0004-netvision-improvements-lp-600950: no longer needed.
    - debian/patches/0005-fix-nut-m4.patch: no longer needed.
    - debian/patches/9999-autoconf.patch: no longer needed.
* New upstream release (Closes: #575176, #588648, #609597, #687985)
* debian/patches/*.patch: removed since these are now fixed upstream
* debian/patches/0001-fix_spelling_and_typo.patch,
  debian/patches/series: reworked to match the new upstream release
* debian/nut.install, debian/nut.manpages: remove obsolete reference to
  megatec and megatec_usb, now respectively replaced by blazer_ser and
  blazer_usb
* debian/nut.docs: limit distributed documentation
* debian/control:
  - Wrap build-dependencies
  - Change nut-cgi Recommends to apache2 | httpd-cgi
* debian/nut.postinst: Only trigger USB subsystem, should Closes: #574769
* debian/patches/0002-fix_udev_action.patch: Use SUBSYSTEM instead of BUS
* debian/control, debian/rules, 
  debian/nut-hal-drivers.{docs,install,postinst,preinst}: Drop
  nut-hal-drivers since Nut doesnt go into universe.
* Split patches/debian-changes-2.4.3-2ubuntu1 into
  patches/0005-fix-nut-m4.patch and patches/9999-autoconf.patch
* Readd lost debian/patches0004-netvision-improvements-lp-600950.patch patch
  (LP: #707050)
* debian/patches/0002-fix_udev_action.patch:
  Change BUS to SUBSYSTEMS, since the former is deprecated. (LP: #692171)
* debian/nut.postinst: Uncomment missing call to adduser
* debian/control: Drop hal build dependency, we don't need the daemon to
  build the package. Add a hal dependency to nut-hal-drivers, which is the
  only thing that actually needs it.
* Merge from debian unstable.  Remaining changes:
  + debian/control:
    - Update maintainer as per spec.
    - Add Breaks on nut-hal-drivers to ensure we have correct udev version.
    - Drop libpowerman0-dev from the Build-Depends (currently in universe)
  + debian/{nut-cgi,nut}.postinst: add nut to the dialout and nut groups
    unconditonally to hanle the upgrade from hardy release.
  + debian/nut-powerman-pdu.install, debian/nut-powerman-pdu.manpages: dropped for now.
  + debian/nut.links: must create the init script link, used if the upse needs to be powered down
    (LP: #357583)
  + debian/nut.postinst: Update udevadm trigger.
    "libusb_get_report: error sending control message: 
     Operation not permitted" error on some UPS devices. (LP: #572262)
  + debian/source_nut.py, debian/nut.install, debian/rules: Install apport hook.
  + debian/patches/netvision-improvements-lp-600950.patch: Add improvements
    for netvision UPSes
  + Fix FTBFS with ld --as-needed.
  + Dropped:
    - debian/patches/03_udev_rules_change.dpatch: Use debian's instead.
    - debian/patches/04_nut_small-buffers.dpatch: Use debian's instead.
* debian/control:
  - Bump Standards-Version to 3.9.1
  - Update Vcs-* fields to new GIT repository
  - Add myself as Uploaders
* Switch to dpkg-source 3.0 (quilt) format (Closes: #573601)
* debian/patches/0001-low_speed_usb_ups.patch: Use patch system for changes
  that were applied directly in the source
* Add debian/gbp.conf file
* debian/watch: Bump version to 3
* Add debian/patches/0002-fix_udev_action.patch: Also set permission for
  "change" udev ACTION (Closes: #557178)
* debian/nut.postrm: Do not try to remove nut user is deluser is not
  installed anymore
* debian/nut.manpages: Install manpage nut.conf.5 (Closes: #528222)
* debian/copyright: Fix copyright-with-old-dh-make-debian-copyright
* Remove nut-snmp.lintian-overrides, not needed anymore
* debian/patches/0003-fix_spelling_and_typo.patch: Fix some spelling errors
* Add debian/libupsclient1.symbols file
* Add debian/nut.links: Re-add /etc/init.d/ups-monitor that was lost for
  some reasons (Closes: #592351)
* debian/nut.lintian-overrides: Add override for
  init.d-script-does-not-provide-itself /etc/init.d/ups-monitor
* Drop libupsclient1.post{inst,rm}: ldconfig call is added automatically by
  debhelper
* debian/libupsclient1-dev.install: Do not ship /lib/libupsclient.la anymore
* debian/rules: Remove dpatch logic as we are using package source version
  '3.0 (quilt)'
* debian/compat: Bump debhelper compatibility to 8
* Non-maintainer upload.
* drivers/libhid.c: Apply r2407 from upstream to fix bug with some
  low speed UPS devices. (Closes: #583371)
* Fix FTBFS with ld --as-needed.
* debian/patches/netvision-improvements-lp-600950.patch: Add improvements for netvision UPSes 
  (LP: #600950) 
* debian/source_nut.py, debian/nut.install, debian/rules: Install apport hook. 
* debian/patches/04_nut-small-buffers.dpatch: Fix "libusb_get_report: error sending control message: 
  Operation not permitted" error on some UPS devices. (LP: #572262)
* debian/nut.postinst: Revert dropping of --action=change. "add" events must
  not ever be triggered automatically.
* Add 03_udev_rules_change.dpatch: Run udev rules on change events, too.
* debian/control: grr...fix ftbfs. 
* Merge from debian testing.  Remaining changes (LP: #535152):
  + debian/control:
    - Update maintainer as per spec.
    - Add Breaks on nut-hal-drivers to ensure we have correct udev version.
    - Drop libpowerman0-dev from the Build-Depends (currently in universe)
  + debian/{nut-cgi,nut}.postinst: add nut to the dialout and nut groups
    unconditonally to hanle the upgrade from hardy release.
  + debian/nut-powerman-pdu.install, debian/nut-powerman-pdu.manpages: dropped for now.
  + debian/nut.links: must create the init script link, used if the upse needs to be powered down
    (LP: #357583)
  + debian/nut.postinst: Update udevadm trigger.
  + Dropped:
    - debian/patches/02-fix-trust-pw4130m.dpatch: No longer needed.
* New upstream release (Closes: #544390, #528222, #539747, #526811,
  #562064)
* debian/nut.install, debian/nut.manpages:
  - remove cyberpower driver and manpage
  - add bestfortress, clone and ivtscd drivers and manpages
* debian/rules:
  - change udev dir to /lib/udev (Closes: #522327)
  - replace deprecated calls to 'dh_clean -k' by dh_prep (Closes: #536599)
* debian/rules, debian/nut.install, debian/nut.install,
  debian/nut.README.Debian: install configuration files, without the
  sample suffix (Closes: #528641)
* debian/nut.links: restored (Closes: #522506)
* debian/nut.init:
  - source nut.conf instead of default/nut for POWEROFF_WAIT(Closes:
    #538173)
  - fix status checking (Closes: #538785)
  - improve detection of non configured system and beautify related
    output (Closes: #563112)
  - use 'invoke-rc.d' instead of calling the reboot script directly
  - add $remote_fs to Required-Start and Required-Stop
* debian/nut.postrm: remove udev files and simplify cleanup (Closes:
  #541629)
* debian/control:
  - remove Luca Filipozzi from the Uploaders list (Closes: #568987)
  - update Standards-Version to 3.8.4
  - remove the debconf dependency
  - bump debhelper version to (>= 7) in Build-Depends, for dh_prep
  - add Breaks on nut-hal-drivers to ensure we have correct udev version
* Remove debconf support since it was related to really old nut
  version (Closes: #518056):
  - remove nut-cgi.config, nut.config, nut-cgi.templates, nut.templates,
    and po/ directory
  - update nut-cgi.postinst
* debian/nut.dirs: remove /var/run/nut to conform to Debian Policy
* debian/nut.postint:
  - create /var/run/nut if needed
  - improve security checks
* debian/nut.README.Debian: add a security note for ups.conf
* debian/watch: URL update
* debian/patches/02-fix-trust-pw4130m.dpatch: Fix issues with Trust
  PW-4130M UPS. (LP: #447586) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* apcsmart.h - command table for APC smart protocol units
2
 
 
3
 
   Copyright (C) 1999  Russell Kroll <rkroll@exploits.org>
4
 
             (C) 2000  Nigel Metheringham <Nigel.Metheringham@Intechnology.co.uk>
5
 
 
6
 
   This program is free software; you can redistribute it and/or modify
7
 
   it under the terms of the GNU General Public License as published by
8
 
   the Free Software Foundation; either version 2 of the License, or
9
 
   (at your option) any later version.
10
 
 
11
 
   This program is distributed in the hope that it will be useful,
12
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
   GNU General Public License for more details.
15
 
 
16
 
   You should have received a copy of the GNU General Public License
17
 
   along with this program; if not, write to the Free Software
18
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
 
*/
20
 
 
21
 
#include <ctype.h>
22
 
#include <sys/ioctl.h>
23
 
#include "serial.h"
24
 
#include "timehead.h"
25
 
 
26
 
#define APC_TABLE_VERSION       "version 2.0"
 
1
/*
 
2
 * apcsmart.h - common defines for apcsmart driver
 
3
 *
 
4
 * Copyright (C) 1999  Russell Kroll <rkroll@exploits.org>
 
5
 *           (C) 2000  Nigel Metheringham <Nigel.Metheringham@Intechnology.co.uk>
 
6
 *           (C) 2011  Michal Soltys <soltys@ziu.info>
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
21
 */
 
22
 
 
23
#ifndef __apcsmart_h__
 
24
#define __apcsmart_h__
 
25
 
 
26
#define DRIVER_NAME     "APC Smart protocol driver"
 
27
#define DRIVER_VERSION  "3.04"
 
28
 
 
29
#define ALT_CABLE_1 "940-0095B"
 
30
 
 
31
/*
 
32
 * alerts and other stuff for quick reference:
 
33
 *
 
34
 * $ OL
 
35
 * ! OB
 
36
 * % LB
 
37
 * + not LB anymore
 
38
 * # RB
 
39
 * ? OVER
 
40
 * = not OVER anymore
 
41
 * * powering down now (only older models ?), handled by upsread()
 
42
 *      otherwise ignored (it doesn't have to be in ignore sets)
 
43
 *
 
44
 * | eeprom change
 
45
 * & check alarm register for fail
 
46
 * ~ ???
 
47
 */
 
48
 
 
49
/*
 
50
 * old ones for reference:
 
51
 *      #define IGNCHARS "\015+$|!~%?=#&"
 
52
 *      #define POLL_IGNORE "\015&|"
 
53
 *      #define POLL_ALERT "$!%+#?="
 
54
 *      #define MINIGNCHARS "\015+$|!"
 
55
 * notice ~ that was present in IGNCHARS, but not in POLL_IGNORE - this kinda
 
56
 * didn't make sense (?); new versions doesn't filter ~, but keep that in mind
 
57
 * in case something obscure surfaces
 
58
 * due to switch to ICANON tty mode, we removed \015 from ignored characters,
 
59
 * as it's handled by IGNCR at read() level
 
60
 */
27
61
 
28
62
/* Basic UPS reply line structure */
29
 
#define ENDCHAR 10              /* APC ends responses with LF */
30
 
 
31
 
/* these two are only used during startup */
32
 
#define IGNCHARS "\015+$|!~%?=*#&"      /* special characters to ignore */
33
 
#define MINIGNCHARS "\015+$|!"  /* minimum set of special characters to ignore */
34
 
 
35
 
/* normal polls: characters we don't want to parse (including a few alerts) */
36
 
#define POLL_IGNORE "\015?=*&|"
37
 
 
38
 
/* alert characters we care about - OL, OB, LB, not LB, RB */
39
 
#define POLL_ALERT "$!%+#"
40
 
 
41
 
#define UPSDELAY          50000 /* slow down multicharacter commands        */
42
 
#define CMDLONGDELAY    1500000 /* some commands need a 1.5s gap for safety */
43
 
 
44
 
#define SER_WAIT_SEC    3       /* wait up to 3.0 sec for ser_get calls */
45
 
#define SER_WAIT_USEC   0
 
63
#define ENDCHAR 10              /* APC ends responses with LF (and CR, but it's IGNCRed) */
 
64
 
 
65
/* what to ignore during alert aware serial reads */
 
66
#define IGN_AACHARS "|&"
 
67
 
 
68
/* what alert_handler() should care about */
 
69
#define ALERT_CHARS "$!%+#?="
 
70
 
 
71
/* characters ignored by alertless reads */
 
72
#define IGN_CHARS IGN_AACHARS ALERT_CHARS
 
73
 
 
74
/*
 
75
 * these ones are used only during capability read, due to ^Z sending certain
 
76
 * characters such as #; it seems it could be equal to just IGN_CHARS w/o #
 
77
 * old: #define IGN_CCCHARS "|$!+"
 
78
 */
 
79
#define IGN_CCCHARS "|&$!%+?="  /* capability check ignore set */
 
80
 
 
81
/*
 
82
 * command set 'a' command reports everything - protocol number, alerts and
 
83
 * supported commands
 
84
 */
 
85
#define IGN_CSCHARS ""  /* command set ignore set */
46
86
 
47
87
/* dangerous instant commands must be reconfirmed within a 12 second window */
48
88
#define MINCMDTIME      3
51
91
/* it only does two strings, and they're both the same length */
52
92
#define APC_STRLEN      8
53
93
 
 
94
#define SER_D0  0x001   /* 0 sec., for flushes */
 
95
#define SER_DX  0x002   /* 200 ms for long/repeated cmds, in case of unexpected NAs */
 
96
#define SER_D1  0x004   /* 1.5 sec. */
 
97
#define SER_D3  0x008   /* 3 sec. (default) */
 
98
#define SER_AA  0x010   /* alert aware set */
 
99
#define SER_CC  0x020   /* capability check ign set */
 
100
#define SER_CS  0x040   /* command set ign set */
 
101
#define SER_TO  0x080   /* timeout allowed */
 
102
#define SER_HA  0x100   /* handle asterisk */
 
103
 
 
104
 
 
105
/* sets of the above (don't test against them, obviously */
 
106
 
 
107
/*
 
108
 * Some cmd codes to ignore (nut doesn't expose those, though the driver might
 
109
 * use them internally (e.g. [a]). If you decide to support them at some
 
110
 * point, remember about removing them from here !
 
111
 */
 
112
#define APC_UNR_CMDS "\032\177~')-+8QRYayz"
 
113
 
54
114
/* --------------- */
55
115
 
56
116
/* status bits */
57
117
 
58
 
#define APC_STAT_CAL    1       /* calibration */
59
 
#define APC_STAT_TRIM   2       /* SmartTrim */
60
 
#define APC_STAT_BOOST  4       /* SmartBoost */
61
 
#define APC_STAT_OL     8       /* on line */
62
 
#define APC_STAT_OB     16      /* on battery */
63
 
#define APC_STAT_OVER   32      /* overload */
64
 
#define APC_STAT_LB     64      /* low battery */
65
 
#define APC_STAT_RB     128     /* replace battery */
 
118
#define APC_STAT_CAL   (1 << 0)        /* calibration */
 
119
#define APC_STAT_TRIM  (1 << 1)        /* SmartTrim */
 
120
#define APC_STAT_BOOST (1 << 2)        /* SmartBoost */
 
121
#define APC_STAT_OL    (1 << 3)        /* on line */
 
122
#define APC_STAT_OB    (1 << 4)        /* on battery */
 
123
#define APC_STAT_OVER  (1 << 5)        /* overload */
 
124
#define APC_STAT_LB    (1 << 6)        /* low battery */
 
125
#define APC_STAT_RB    (1 << 7)        /* replace battery */
66
126
 
67
 
/* serial protocol: special commands - initialization and such */
 
127
/*
 
128
 * serial protocol: special commands - initialization and such
 
129
 * these are not exposed as instant commands
 
130
 */
68
131
#define APC_STATUS      'Q'
69
132
#define APC_GOSMART     'Y'
70
133
#define APC_GODUMB      'R'
71
134
#define APC_CMDSET      'a'
72
 
#define APC_CAPABILITY  26      /* ^Z */
 
135
#define APC_CAPS        '\032'  /* ^Z */
73
136
#define APC_NEXTVAL     '-'
74
 
 
75
 
/* --------------- */
76
 
 
77
 
/* Driver command table flag values */
78
 
 
79
 
#define APC_POLL        0x0001  /* Poll this variable regularly         */
80
 
#define APC_IGNORE      0x0002  /* Never poll this                      */
81
 
#define APC_PRESENT     0x0004  /* Capability seen on this UPS          */
82
 
 
83
 
#define APC_RW          0x0010  /* read-write variable                  */
84
 
#define APC_ENUM        0x0020  /* enumerated type                      */
85
 
#define APC_STRING      0x0040  /* string                               */
86
 
 
87
 
#define APC_NASTY       0x0100  /* Nasty command - take care            */
88
 
#define APC_REPEAT      0x0200  /* Command needs sending twice          */
89
 
 
90
 
#define APC_FORMATMASK  0xFF0000 /* Mask for apc data formats */
91
 
 
92
 
#define APC_F_PERCENT   0x020000 /* Data in a percent format */
93
 
#define APC_F_VOLT      0x030000 /* Data in a voltage format */
94
 
#define APC_F_AMP       0x040000 /* Data in a current/amp format */
95
 
#define APC_F_CELSIUS   0x050000 /* Data in a temp/C format */
96
 
#define APC_F_HEX       0x060000 /* Data in a hex number format */
97
 
#define APC_F_DEC       0x070000 /* Data in a decimal format */
98
 
#define APC_F_SECONDS   0x100000 /* Time in seconds */
99
 
#define APC_F_MINUTES   0x110000 /* Time in minutes */
100
 
#define APC_F_HOURS     0x120000 /* Time in hours */
101
 
#define APC_F_LEAVE     0       /* Just pass this through */
102
 
 
103
 
struct apc_vartab_t {
104
 
        const   char    *name;          /* the variable name */
105
 
        unsigned int    flags;          /* various flags                */
106
 
        char            cmd;            /* command character */
107
 
 
108
 
} apc_vartab[] = {
109
 
 
110
 
        { "ups.firmware",       0,                      'b' },
111
 
        { "ups.firmware.aux",   0,                      'v' },
112
 
        { "ups.model",          0,                      0x01 },
113
 
 
114
 
/* FUTURE: depends on variable naming scheme */
115
 
#if 0
116
 
        { "ups.model.code",     0,                      'V' },
 
137
#define APC_FW_OLD      'V'
 
138
#define APC_FW_NEW      'b'
 
139
 
 
140
#define APC_LBUF        512
 
141
#define APC_SBUF        32
 
142
 
 
143
/* default a.w.d. value / regex format for command '@' */
 
144
#define APC_AWDDEF      "000"
 
145
#define APC_AWDFMT      "^[0-9]{1,3}$"
 
146
 
 
147
/* maximum number of supported sdtype methods + regex format*/
 
148
#define APC_SDMAX       "5"
 
149
#define APC_SDFMT       "^[0-5]$"
 
150
 
117
151
#endif
118
 
 
119
 
        { "ups.serial",         0,                      'n' },
120
 
        { "ups.mfr.date",       0,                      'm' },
121
 
 
122
 
        { "ups.temperature",    APC_POLL|APC_F_CELSIUS, 'C' },
123
 
        { "ups.load",           APC_POLL|APC_F_PERCENT, 'P' },
124
 
 
125
 
        { "ups.test.interval",  APC_F_HOURS,            'E' },
126
 
        { "ups.test.result",    APC_POLL,               'X' },
127
 
 
128
 
        { "ups.delay.start",    APC_F_SECONDS,          'r' },
129
 
        { "ups.delay.shutdown", APC_F_SECONDS,          'p' },
130
 
 
131
 
        { "ups.id",             APC_STRING,             'c' },
132
 
 
133
 
        { "ups.contacts",       APC_POLL|APC_F_HEX,     'i' },
134
 
        { "ups.display.language",
135
 
                                0,                      0x0C },
136
 
 
137
 
        { "input.voltage",      APC_POLL|APC_F_VOLT,    'L' },
138
 
        { "input.frequency",    APC_POLL|APC_F_DEC,     'F' },
139
 
        { "input.sensitivity",  0,                      's' },
140
 
        { "input.quality",      APC_POLL|APC_F_HEX,     '9' },
141
 
 
142
 
        { "input.transfer.low", APC_F_VOLT,             'l' },
143
 
        { "input.transfer.high",
144
 
                                APC_F_VOLT,             'u' },
145
 
        { "input.transfer.reason", 
146
 
                                APC_POLL,               'G' },
147
 
 
148
 
        { "input.voltage.maximum",
149
 
                                APC_POLL|APC_F_VOLT,    'M' },
150
 
        { "input.voltage.minimum",
151
 
                                APC_POLL|APC_F_VOLT,    'N' },
152
 
 
153
 
        { "output.current",     APC_POLL|APC_F_AMP,     '/' },
154
 
        { "output.voltage",     APC_POLL|APC_F_VOLT,    'O' },
155
 
        { "output.voltage.nominal",  
156
 
                                APC_F_VOLT,             'o' },
157
 
 
158
 
        { "ambient.humidity",   APC_POLL|APC_F_PERCENT, 'h' },
159
 
        { "ambient.humidity.high", 
160
 
                                APC_F_PERCENT,          '{' },
161
 
        { "ambient.humidity.low", 
162
 
                                APC_F_PERCENT,          '}' },
163
 
 
164
 
        { "ambient.temperature",        
165
 
                                APC_POLL|APC_F_CELSIUS, 't' },
166
 
        { "ambient.temperature.high",   
167
 
                                APC_F_CELSIUS,          '[' },
168
 
        { "ambient.temperature.low",    
169
 
                                APC_F_CELSIUS,          ']' },
170
 
 
171
 
        { "battery.date",       APC_STRING,             'x' },
172
 
 
173
 
        { "battery.charge",     APC_POLL|APC_F_PERCENT, 'f' },
174
 
        { "battery.charge.restart",  
175
 
                                APC_F_PERCENT,          'e' },
176
 
 
177
 
        { "battery.voltage",    APC_POLL|APC_F_VOLT,    'B' },
178
 
        { "battery.voltage.nominal", 
179
 
                                0,                      'g' },
180
 
 
181
 
        { "battery.runtime",    APC_POLL|APC_F_MINUTES, 'j' },
182
 
        { "battery.runtime.low",
183
 
                                APC_F_MINUTES,          'q' },
184
 
 
185
 
        { "battery.packs",      APC_F_DEC,              '>' },
186
 
        { "battery.packs.bad",  APC_F_DEC,              '<' },
187
 
        { "battery.alarm.threshold", 
188
 
                                0,                      'k' },
189
 
        /* todo:
190
 
 
191
 
           I = alarm enable (hex field) - split into alarm.n.enable
192
 
           J = alarm status (hex field) - split into alarm.n.status
193
 
 
194
 
        0x15 = output voltage selection (APC_F_VOLT)
195
 
        0x5C = load power (APC_POLL|APC_F_PERCENT)
196
 
 
197
 
         */
198
 
 
199
 
        {NULL,          0,                              0},
200
 
};
201
 
 
202
 
/* ------ instant commands ------ */
203
 
 
204
 
#define APC_CMD_FPTEST          'A'
205
 
#define APC_CMD_CALTOGGLE       'D'
206
 
#define APC_CMD_SHUTDOWN        'K'
207
 
#define APC_CMD_SOFTDOWN        'S'
208
 
#define APC_CMD_SIMPWF          'U'
209
 
#define APC_CMD_BTESTTOGGLE     'W'
210
 
#define APC_CMD_OFF             'Z'
211
 
 
212
 
#define APC_CMD_ON              0x0E            /* ^N */
213
 
#define APC_CMD_BYPTOGGLE       '^'
214
 
 
215
 
struct apc_cmdtab_t {
216
 
        const   char    *name;
217
 
        int     flags;
218
 
        char    cmd;
219
 
} apc_cmdtab[] =
220
 
{
221
 
        { "load.off",           APC_NASTY|APC_REPEAT,   APC_CMD_OFF       },
222
 
        { "load.on",            APC_REPEAT,             APC_CMD_ON        },
223
 
 
224
 
        { "test.panel.start",   0,                      APC_CMD_FPTEST    },
225
 
 
226
 
        { "test.failure.start", 0,                      APC_CMD_SIMPWF    },
227
 
 
228
 
        { "test.battery.start", 0,                      APC_CMD_BTESTTOGGLE },
229
 
        { "test.battery.stop",  0,                      APC_CMD_BTESTTOGGLE },
230
 
 
231
 
        { "shutdown.return",    APC_NASTY,              APC_CMD_SOFTDOWN  },
232
 
        { "shutdown.stayoff",   APC_NASTY|APC_REPEAT,   APC_CMD_SHUTDOWN  },
233
 
 
234
 
        { "calibrate.start",    0,                      APC_CMD_CALTOGGLE },
235
 
        { "calibrate.stop",     0,                      APC_CMD_CALTOGGLE },
236
 
 
237
 
        { "bypass.start",       0,                      APC_CMD_BYPTOGGLE },
238
 
        { "bypass.stop",        0,                      APC_CMD_BYPTOGGLE },
239
 
 
240
 
        { NULL, 0, 0                                    }
241
 
};
242
 
 
243
 
/* things to ignore in protocol_verify - useless variables, etc. */
244
 
#define CMD_IGN_CHARS "\032-78@.,~\047\177QHRTYayz)1IJ"
245
 
 
246
 
/* compatibility with hardware that doesn't do APC_CMDSET ('a') */
247
 
 
248
 
struct {
249
 
        const   char    *firmware;
250
 
        const   char    *cmdchars;
251
 
        int     flags;
252
 
} compat_tab[] =
253
 
{
254
 
        /* APC600 */
255
 
        { "6QD",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
256
 
        { "6TI",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
257
 
        { "6QI",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
258
 
        /* CS 350 */
259
 
        { "5.4.D",      "\1ABPQRSUYbdfgjmnx9",  0 },
260
 
        /* Smart-UPS 600 */
261
 
        { "D6",         "789ABCEFGKLMNOPQRSUVWXYZ", 0 },
262
 
        { "D5",         "789ABCEFGKLMNOPQRSUVWXYZ", 0 },
263
 
        { "D4",         "789ABCEFGKLMNOPQRSUVWXYZ", 0 },
264
 
        /* SmartUPS 1250. */
265
 
        { "8QD",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
266
 
        { "8TI",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz", 0 },
267
 
        /* APC Matrix */
268
 
        { "0ZI",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz/<>", 0 },
269
 
        { "5UI",        "79ABCDEFGKLMNOPQRSUVWXYZcefgjklmnopqrsuxz/<>", 0 },
270
 
 
271
 
        { NULL,         NULL,                   0 },
272
 
};