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

« back to all changes in this revision

Viewing changes to drivers/powercom.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
1
/*
2
2
 * powercom.h - defines for the newpowercom.c driver
3
3
 *
4
 
 * Read docs/powercom.txt for other models and manufactures
5
 
 *
6
 
 * $Id: - will be filled in on next CVS add/update $
 
4
 * $Id: powercom.h,v 1.2 2005/02/28 09:14:07 aquette Exp $
7
5
 *
8
6
 * Copyrights:
9
7
 * (C) 2002 Simon Rozman <simon@rozman.net>
10
 
 *  Added support for Egys
11
 
 *
12
 
 * (C) 2001 Peter Bieringer <pb@bieringer.de>
13
 
 *  Porting old style "powercom" to new style "newpowercom", cleanup header file
14
 
 *
15
 
 * (C) 2000  Shaul Karl <shaulk@israsrv.net.il>
16
 
 *  Creating old style "powercom"
17
 
 *   Heavily based on
18
 
 *    ups-trust425+625.c - model specific routines for Trust UPS 425/625
19
 
 *    Copyright (C) 1999  Peter Bieringer <pb@bieringer.de>
 
8
 * (C) 1999  Peter Bieringer <pb@bieringer.de>
20
9
 *
21
10
 * This program is free software; you can redistribute it and/or modify
22
11
 * it under the terms of the GNU General Public License as published by
32
21
 * along with this program; if not, write to the Free Software
33
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34
23
 *
35
 
 * Changes
36
 
 * 20011208/PB: add support for subtypes
37
 
 * 20020629/SR: add support for calc. parameters
38
 
 * 20020701/SK: subtypes as structures
39
 
 * 20030506/SK: replaced the previous validation method with
40
 
 *              validation_byte[] and replaced subtype by type.
41
24
 */
42
25
 
43
26
/* C-libary includes */
50
33
 
51
34
/* nut includes */
52
35
#include "timehead.h"
53
 
#include "shared-tables.h"
54
36
 
55
37
/* general constants */
56
38
enum general {
57
 
        SEC_FOR_POWERKILL         = 10U,
58
 
        MAX_NUM_OF_BYTES_FROM_UPS = 16U,
 
39
        MAX_NUM_OF_BYTES_FROM_UPS = 16
59
40
};
60
41
 
61
42
/* values for sending to UPS */
62
43
enum commands {
63
44
        SEND_DATA    = '\x01',
64
45
        BATTERY_TEST = '\x03',
65
 
        SHUTDOWN     = '\xbc',
 
46
        SHUTDOWN     = '\xbc'
66
47
};
67
48
 
68
49
/* location of data in received string */
72
53
        INPUT_VOLTAGE    = 2U,
73
54
        OUTPUT_VOLTAGE   = 3U,
74
55
        INPUT_FREQUENCY  = 4U,
75
 
        OUTPUT_FREQUENCY = 6U,
 
56
        OUTPUT_FREQUENCY = 6U
76
57
};
77
58
 
78
59
/* status bits */
86
67
        OVERLOAD      = 32U,
87
68
        OFF           = 128U,
88
69
        STATUS_A      = 9U,
89
 
        STATUS_B      = 10U,
 
70
        STATUS_B      = 10U
90
71
};
91
72
 
92
73
/* supported types */
93
74
struct type {
94
 
        char          *name;
 
75
        const char    *name;
95
76
        unsigned char num_of_bytes_from_ups;
96
 
        void          (*setup_flow_control)(void);
 
77
        
 
78
        struct method_of_flow_control {
 
79
            char *name;
 
80
            void (*setup_flow_control)(void);
 
81
        } flowControl;
97
82
        
98
83
        struct validation_byte {
99
 
            unsigned char index_of_byte, required_value;
 
84
            unsigned int index_of_byte, required_value;
100
85
            /* An example might explain the intention better then prose.
101
86
             * Suppose we want to validate the data with:
102
87
             *     powercom_raw_data[5] == 0x80
103
 
             * then we will set index_of_byte to 5 and required_value to
104
 
             * 0x80: { 5, 0x80 }.
 
88
             * then we will set index_of_byte to 5U and required_value to
 
89
             * 0x80U: { 5U, 0x80U }.
105
90
             */
106
91
        } validation[3];
107
92
        /* The validation array is of length 3 because 3 is longest 
108
93
         * validation sequence for any type.
109
94
         */
110
95
        
111
 
        /* parameters to calculate input and output freq., one pair for each
112
 
         * type:
 
96
        /* Some UPSs must have a minutes and a seconds arguments for 
 
97
         * the SHUTDOWN commands while others are known to work with the
 
98
         * seconds argument alone.
 
99
         */
 
100
        struct deley_for_power_kill {
 
101
            unsigned int  delay[2];   /* { minutes, seconds } */
 
102
            unsigned char minutesShouldBeUsed;
 
103
            /* 'n' in case the minutes value, which is deley[0], should
 
104
                 * be skipped and not sent to the UPS. 
 
105
                 */
 
106
        } shutdown_arguments;
 
107
        
 
108
        /* parameters to calculate input and output freq., one pair for
 
109
         * each type:
113
110
         *  Each pair defines parameters for 1/(A*x+B) to calculate freq.
114
111
         *  from raw data
115
112
         */