2
* powercom.h - defines for the newpowercom.c driver
4
* Read docs/powercom.txt for other models and manufactures
6
* $Id: - will be filled in on next CVS add/update $
9
* (C) 2002 Simon Rozman <simon@rozman.net>
10
* Added support for Egys
12
* (C) 2001 Peter Bieringer <pb@bieringer.de>
13
* Porting old style "powercom" to new style "newpowercom", cleanup header file
15
* (C) 2000 Shaul Karl <shaulk@israsrv.net.il>
16
* Creating old style "powercom"
18
* ups-trust425+625.c - model specific routines for Trust UPS 425/625
19
* Copyright (C) 1999 Peter Bieringer <pb@bieringer.de>
21
* This program is free software; you can redistribute it and/or modify
22
* it under the terms of the GNU General Public License as published by
23
* the Free Software Foundation; either version 2 of the License, or
24
* (at your option) any later version.
26
* This program is distributed in the hope that it will be useful,
27
* but WITHOUT ANY WARRANTY; without even the implied warranty of
28
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29
* GNU General Public License for more details.
31
* You should have received a copy of the GNU General Public License
32
* along with this program; if not, write to the Free Software
33
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.
43
/* C-libary includes */
46
#include <sys/ioctl.h>
47
#include <sys/types.h>
48
#include <sys/termios.h>
53
#include "shared-tables.h"
55
/* general constants */
57
SEC_FOR_POWERKILL = 10U,
58
MAX_NUM_OF_BYTES_FROM_UPS = 16U,
61
/* values for sending to UPS */
64
BATTERY_TEST = '\x03',
68
/* location of data in received string */
75
OUTPUT_FREQUENCY = 6U,
95
unsigned char num_of_bytes_from_ups;
96
void (*setup_flow_control)(void);
98
struct validation_byte {
99
unsigned char index_of_byte, required_value;
100
/* An example might explain the intention better then prose.
101
* Suppose we want to validate the data with:
102
* powercom_raw_data[5] == 0x80
103
* then we will set index_of_byte to 5 and required_value to
107
/* The validation array is of length 3 because 3 is longest
108
* validation sequence for any type.
111
/* parameters to calculate input and output freq., one pair for each
113
* Each pair defines parameters for 1/(A*x+B) to calculate freq.
118
/* parameters to calculate load %, two pairs for each type:
119
* First pair defines the parameters for A*x+B to calculate load
120
* from raw data when offline and the second pair is used when
125
/* parameters to calculate battery %, five parameters for each type:
126
* First three params defines the parameters for A*x+B*y+C to calculate
127
* battery % (x is raw data, y is load %) when offline.
128
* Fourth and fifth parameters are used to calculate D*y+E when online.
132
/* parameters to calculate utility and output voltage, two pairs for
134
* First pair defines the parameters for A*x+B to calculate utility
135
* from raw data when line voltage is >=220 and the second pair