1
/* Written to work with MicroDowell BBox UPS.
2
This model is based on MicroDowell (www.microdowell.com) models.
4
Copyright (C) 2000 Gilberto Iob <research@microdowell.com>
5
Copyright (C) 2002 Aleksandar Topuzovic <aleksandar.topuzovic@avl.com>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
#include <sys/ioctl.h>
26
#include <sys/types.h>
27
#include <sys/termios.h>
32
#define NUM_POLLING_BYTES 16
33
#define NUM_MODEL_BYTES 8
34
#define NUM_POLLS_KO 4
37
#define CMD_SETTIMER 49
38
#define CMD_SCHEDULING 50
41
#define CMD_BATTEST 53
55
#define UPS_HOUR_OFF 11
60
#define MAINS_FAILURE 1 /* battery mode 0 = OFF,1 = ON */
61
#define LOW_BAT 2 /* battery low 0 = OFF,1 = ON */
62
#define END_BAT 4 /* battery discharged 0 = OFF,1 = ON */
63
#define STANDBY 8 /* Stand-By mode 0 = OFF,1 = ON */
64
#define HIGH_TEMP 16 /* high temperature 0 = OFF,1 = ON */
65
#define DANGER_TEMP 32 /* temperature warning 0 = OFF,1 = ON */
66
#define MAINS_ABSENCE 64 /* mains absence 0 = mains ON,1 = mains OFF */
67
#define FREQ_FLAG 128 /* output frequency 0 = 60Hz,1 = 50 Hz */
69
#define ST_ONLINE 0x01
70
#define ST_ONBATT 0x02
71
#define ST_LOWBATT 0x04
73
#define ST_BADCOM 0x10
82
#define CHAR_DELAY 200000
85
enum general {SHMOK = 1U, SEC_FOR_POWERKILL = 10U,
86
NUM_OF_BYTES_FROM_UPS = 16U, MAINS_VOLTAGE = 230U};
87
enum commands { BATTERY_TEST = 0x03U, SHUTDOWN = 0xbcU};
88
enum data {LOAD_LEVEL = 0U, BAT_LEVEL = 1U, IN_AC_VOLT = 2U, OUT_AC_VOLT = 3U, IN_AC_FREQ = 4U};
90
/* The following vars must be global because other parts of the NUT package
91
* use them as well. */
93
unsigned int line_voltage = 230U; /* default value */
95
/* 9 entries in the info array for:
96
- ACFREQ, BATTVOLT, LOADPCT, MFR, MODEL, STATUS, UTILITY, UPSTEMP, SERIAL
98
- Other 2 are for MEMBERS and MSGID.
109
unsigned char upshour;
110
unsigned char upsmin;
111
unsigned char upssec;
112
unsigned char houron;
114
unsigned char houroff;
115
unsigned char sddelay;