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

« back to all changes in this revision

Viewing changes to drivers/microdowell.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-07-20 19:48:50 UTC
  • mto: (16.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050720194850-oo61wjr33rrx2mre
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Written to work with MicroDowell BBox UPS.
2
 
   This model is based on MicroDowell (www.microdowell.com) models.
3
 
    
4
 
   Copyright (C) 2000  Gilberto Iob <research@microdowell.com>
5
 
   Copyright (C) 2002  Aleksandar Topuzovic <aleksandar.topuzovic@avl.com>
6
 
 
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.
11
 
 
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.
16
 
 
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
20
 
*/
21
 
 
22
 
 
23
 
#include <sys/file.h>
24
 
#include <sys/stat.h>
25
 
#include <sys/ioctl.h>
26
 
#include <sys/types.h>
27
 
#include <sys/termios.h>
28
 
#include <limits.h>
29
 
#include "timehead.h"
30
 
 
31
 
 
32
 
#define NUM_POLLING_BYTES       16
33
 
#define NUM_MODEL_BYTES         8
34
 
#define NUM_POLLS_KO            4
35
 
 
36
 
#define SEND_DATA               48
37
 
#define CMD_SETTIMER            49
38
 
#define CMD_SCHEDULING          50
39
 
#define CMD_STDBY               51
40
 
#define CMD_BEND                52
41
 
#define CMD_BATTEST             53
42
 
#define CMD_BUZOFF              54
43
 
#define SEND_MODEL              58
44
 
 
45
 
#define STATUS                  2
46
 
#define UTILITY                 3
47
 
#define BATTVOLT                4
48
 
#define UPSTEMP                 5
49
 
#define LOADPCT                 5
50
 
#define UPS_HOUR                6
51
 
#define UPS_MIN                 7
52
 
#define UPS_SEC                 8
53
 
#define UPS_HOUR_ON             9
54
 
#define UPS_MIN_ON              10
55
 
#define UPS_HOUR_OFF            11
56
 
#define SD_DELAY                12
57
 
#define ACFREQ_L                13
58
 
#define ACFREQ_H                14
59
 
 
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 */
68
 
 
69
 
#define ST_ONLINE               0x01
70
 
#define ST_ONBATT               0x02
71
 
#define ST_LOWBATT              0x04  
72
 
#define ST_FAIL                 0x08  
73
 
#define ST_BADCOM               0x10  
74
 
 
75
 
#define LOAD_T0                 3
76
 
#define LOAD_T1                 10
77
 
#define LOAD_T2                 22
78
 
#define LOAD_T3                 37
79
 
#define LOAD_T4                 47
80
 
 
81
 
 
82
 
#define CHAR_DELAY              200000
83
 
 
84
 
 
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};
89
 
 
90
 
/* The following vars must be global because other parts of the NUT package
91
 
 * use them as well. */
92
 
 
93
 
unsigned int    line_voltage = 230U;    /* default value */
94
 
 
95
 
/* 9 entries in the info array for: 
96
 
        - ACFREQ, BATTVOLT, LOADPCT, MFR, MODEL, STATUS, UTILITY, UPSTEMP, SERIAL 
97
 
        - Commands: 8 entries
98
 
        - Other 2 are for MEMBERS and MSGID. 
99
 
*/
100
 
 
101
 
typedef struct {
102
 
        int             status;
103
 
        int             upsmodel;
104
 
        float           acfreq;
105
 
        float           utility;
106
 
        float           upstemp;
107
 
        float           battvolt;
108
 
        int             loadpct;
109
 
        unsigned char   upshour;
110
 
        unsigned char   upsmin;
111
 
        unsigned char   upssec;
112
 
        unsigned char   houron;
113
 
        unsigned char   minon;
114
 
        unsigned char   houroff;
115
 
        unsigned char   sddelay;
116
 
        int             maxbattruntime;
117
 
        int             battruntime;
118
 
}       upstype;
119
 
 
120
 
upstype         myups;