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

« back to all changes in this revision

Viewing changes to drivers/mge-shut.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
/*  mge-shut.h - monitor MGE UPS for NUT with SHUT protocol
2
2
 * 
3
 
 *  Copyright (C) 2002-2004
 
3
 *  Copyright (C) 2002 - 2005
4
4
 *     Arnaud Quette <arnaud.quette@free.fr> & <arnaud.quette@mgeups.com>
5
5
 *     Philippe Marzouk <philm@users.sourceforge.net>
6
6
 *     Russell Kroll <rkroll@exploits.org>
26
26
#include "hidparser.h"
27
27
#include "hidtypes.h"
28
28
 
29
 
#define DRIVER_VERSION "0.59"
 
29
#define DRIVER_VERSION "0.64"
30
30
 
31
31
#define DEFAULT_TIMEOUT         3000
32
32
#define MAX_STRING              64
33
33
 
34
34
#define DEFAULT_LOWBATT         30      /* low battery level, in %          */
35
35
#define DEFAULT_ONDELAY         3       /* delay between return of utility power
36
 
                                           and powering up of load, 10 seconds units */
37
 
#define DEFAULT_OFFDELAY        20      /* delay befor power off, in SECONDS*/ 
 
36
                                           and powering up of load, in 10 seconds units */
 
37
#define DEFAULT_OFFDELAY        20      /* delay befor power off, in seconds */ 
38
38
#define OFF_NOTIFICATION        1       /* notification off */
39
39
 
40
40
#define LIGHT_NOTIFICATION      2       /* light notification */
156
156
#define SHUT_FLAG_DELAY  (1 << 4)       /* delay type value: formated differently. */
157
157
 
158
158
/* --------------------------------------------------------------- */
 
159
/*      Model Name formating entries                               */
 
160
/* --------------------------------------------------------------- */
 
161
typedef struct {
 
162
  char  *iProduct;
 
163
  char  *iModel;
 
164
  char  *finalname;
 
165
} models_name_t;
 
166
 
 
167
models_name_t models_names [] =
 
168
  {
 
169
        /* Ellipse models */
 
170
        { "ELLIPSE", "300", "ellipse 300" },
 
171
        { "ELLIPSE", "500", "ellipse 500" },
 
172
        { "ELLIPSE", "650", "ellipse 650" },
 
173
        { "ELLIPSE", "800", "ellipse 800" },
 
174
        { "ELLIPSE", "1200", "ellipse 1200" },
 
175
        /* Ellipse Premium models */
 
176
        { "ellipse", "PR500", "ellipse premium 500" },
 
177
        { "ellipse", "PR650", "ellipse premium 650" },
 
178
        { "ellipse", "PR800", "ellipse premium 800" },
 
179
        { "ellipse", "PR1200", "ellipse premium 1200" },
 
180
        /* Ellipse "Pro" */
 
181
        { "ELLIPSE", "600", "Ellipse 600" },
 
182
        { "ELLIPSE", "750", "Ellipse 750" },
 
183
        { "ELLIPSE", "1000", "Ellipse 1000" },
 
184
        { "ELLIPSE", "1500", "Ellipse 1500" },
 
185
        /* Evolution models */
 
186
        { "Evolution", "500", "Pulsar Evolution 500" },
 
187
        { "Evolution", "800", "Pulsar Evolution 800" },
 
188
        { "Evolution", "1100", "Pulsar Evolution 1100" },
 
189
        { "Evolution", "1500", "Pulsar Evolution 1500" },
 
190
        { "Evolution", "2200", "Pulsar Evolution 2200" },
 
191
        { "Evolution", "3000", "Pulsar Evolution 3000" },
 
192
        { "Evolution", "3000XL", "Pulsar Evolution 3000 XL" },
 
193
        /* NOVA models */       
 
194
        { "NOVA AVR", "600", "NOVA 600 AVR" },
 
195
        { "NOVA AVR", "1100", "NOVA 1100 AVR" },
 
196
        /* EXtreme C (EMEA) */
 
197
        { "EXtreme", "700C", "Pulsar EXtreme 700C" },
 
198
        { "EXtreme", "1000C", "Pulsar EXtreme 1000C" },
 
199
        { "EXtreme", "1500C", "Pulsar EXtreme 1500C" },
 
200
        { "EXtreme", "1500CCLA", "Pulsar EXtreme 1500C CLA" },
 
201
        { "EXtreme", "2200C", "Pulsar EXtreme 2200C" },
 
202
        { "EXtreme", "3200C", "Pulsar EXtreme 3200C" },
 
203
        /* EXtreme C (USA, aka "EX RT") */
 
204
        { "EX", "700RT", "Pulsar EX 700 RT" },
 
205
        { "EX", "1000RT", "Pulsar EX 1000 RT" },
 
206
        { "EX", "1500RT", "Pulsar EX 1500 RT" },
 
207
        { "EX", "2200RT", "Pulsar EX 2200 RT" },
 
208
        { "EX", "3200RT", "Pulsar EX 3200 RT" },
 
209
        /* Comet EX RT */
 
210
        { "EX", "5RT", "EX 5 RT" },
 
211
        { "EX", "7RT", "EX 7 RT" },
 
212
        { "EX", "11RT", "EX 11 RT" },
 
213
 
 
214
        /* Galaxy 3000 */
 
215
        { "GALAXY", "3000_10", "Galaxy 3000 10 kVA" },
 
216
        { "GALAXY", "3000_15", "Galaxy 3000 15 kVA" },
 
217
        { "GALAXY", "3000_20", "Galaxy 3000 20 kVA" },
 
218
        { "GALAXY", "3000_30", "Galaxy 3000 30 kVA" },
 
219
 
 
220
        /* FIXME: To be completed (Comet, Galaxy, Esprit, ...) */
 
221
 
 
222
        /* end of structure. */
 
223
        { NULL, NULL, "Generic SHUT model" }
 
224
};
 
225
/* for lookup between HID values and NUT values*/
 
226
typedef struct {
 
227
        long    hid_value;      /* HID value */
 
228
        char    *nut_value;     /* NUT value */
 
229
} info_lkp_t;
 
230
 
 
231
/* Actual value lookup tables => should be fine for all Mfrs (TODO: validate it!) */
 
232
/* --------------------------------------------------------------- */
 
233
/*      Lookup values between NUT and HID                          */
 
234
/* --------------------------------------------------------------- */
 
235
info_lkp_t onbatt_info[] = {
 
236
  { 0, "OB" },
 
237
  { 1, "OL" },
 
238
  { 0, "NULL" }
 
239
};
 
240
info_lkp_t discharging_info[] = {
 
241
  { 1, "DISCHRG" },
 
242
  { 0, "NULL" }
 
243
};
 
244
info_lkp_t charging_info[] = {
 
245
  { 1, "CHRG" },
 
246
  { 0, "NULL" }
 
247
};
 
248
info_lkp_t lowbatt_info[] = {
 
249
  { 1, "LB" },
 
250
  { 0, "NULL" }
 
251
};
 
252
info_lkp_t overbatt_info[] = {
 
253
  { 1, "OVER" },
 
254
  { 0, "NULL" }
 
255
};
 
256
info_lkp_t replacebatt_info[] = {
 
257
  { 1, "RB" },
 
258
  { 0, "NULL" }
 
259
};
 
260
info_lkp_t shutdownimm_info[] = {
 
261
  { 1, "LB" },
 
262
  { 0, "NULL" }
 
263
};
 
264
info_lkp_t trim_info[] = {
 
265
  { 1, "TRIM" },
 
266
  { 0, "NULL" }
 
267
};
 
268
info_lkp_t boost_info[] = {
 
269
  { 1, "BOOST" },
 
270
  { 0, "NULL" }
 
271
};
 
272
/* TODO: add BYPASS, OFF, CAL */
 
273
 
 
274
info_lkp_t test_write_info[] = {
 
275
  { 0, "No test" },
 
276
  { 1, "Quick test" },
 
277
  { 2, "Deep test" },
 
278
  { 3, "Abort test" },
 
279
  { 0, "NULL" }
 
280
};
 
281
info_lkp_t test_read_info[] = {
 
282
  { 1, "Done and passed" },
 
283
  { 2, "Done and warning" },
 
284
  { 3, "Done and error" },
 
285
  { 4, "Aborted" },
 
286
  { 5, "In progress" },
 
287
  { 6, "No test initiated" },
 
288
  { 0, "NULL" }
 
289
};
 
290
 
 
291
/* --------------------------------------------------------------- */
159
292
/*      Query Commands and their Mapping to INFO_ Variables        */
160
293
/* --------------------------------------------------------------- */
161
294
 
163
296
   information to INFO structure.
164
297
*/
165
298
typedef struct {
166
 
  char  *type;                  /* INFO_* element                        */
167
 
  int   flags;                  /* INFO-element flags to set in addinfo  */
168
 
  int   length;                 /* INFO-element length of strings        */  
169
 
  char  item_path[MAX_STRING];  /* HID object (fully qualified string path) */
170
 
  char  fmt[6];                 /* printf format string for INFO entry   */
171
 
  char  *dfl;                   /* default value */
 
299
  const char    *type;          /* INFO_* element                        */
 
300
  int                   flags;          /* INFO-element flags to set in addinfo  */
 
301
  int                   length;         /* INFO-element length of strings        */  
 
302
  const char    *item_path;     /* HID object (fully qualified string path) */
 
303
  const char    fmt[6];         /* printf format string for INFO entry   */
 
304
  const char    *dfl;           /* default value */
172
305
  unsigned long shut_flags;     /* specific SHUT flags */
 
306
  info_lkp_t    *hid2info;      /* lookup table between HID and NUT values */
173
307
} mge_info_item;
174
308
 
175
309
/* Array containing information to translate between UTalk and NUT info
176
310
 * NOTE: 
177
311
 *      - Array is terminated by element with type NULL.
178
 
 *      - Essential INFO items (ups.{mfr, model, firmware, status}) are
 
312
 *      - Essential INFO items (ups.{mfr, model, firmware, status} are
179
313
 *              handled separately.
180
314
 *      - Array is NOT const, since "shut_flags" can be changed.
181
315
 */
182
316
 
 
317
/* FIXME: should be shared with mgehid.h */
183
318
static mge_info_item mge_info[] = {
184
 
        { "driver.version.internal", FLAG_STRING, 5, "", "%s", DRIVER_VERSION, SHUT_FLAG_ABSENT | SHUT_FLAG_OK },
 
319
        { "driver.version.internal", ST_FLAG_STRING, 5, NULL, "%s", DRIVER_VERSION, SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL },
185
320
        /* Battery page */
186
 
        { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", "%i", NULL, SHUT_FLAG_OK },
187
 
        { "battery.charge.low", FLAG_RW |ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimitSetting", "%ld", NULL, SHUT_FLAG_OK }, /* RW, to be caught first if exists... */
188
 
        { "battery.charge.low",ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimit", "%ld", NULL, SHUT_FLAG_OK }, /* ... or Read only */
189
 
        { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", "%05d", NULL, SHUT_FLAG_OK },
 
321
        { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", "%i", NULL, SHUT_FLAG_OK, NULL },
 
322
        { "battery.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimitSetting",
 
323
          "%ld", NULL, SHUT_FLAG_OK, NULL }, /* RW, to be caught first if exists... */
 
324
        { "battery.charge.low", ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimit",
 
325
          "%ld", NULL, SHUT_FLAG_OK, NULL }, /* ... or Read only */
 
326
        { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", "%05d", NULL, SHUT_FLAG_OK, NULL },
190
327
        /* UPS page */
191
 
        { "ups.mfr",ST_FLAG_STRING, 20, "", "%s", "MGE UPS SYSTEMS", SHUT_FLAG_ABSENT | SHUT_FLAG_OK },
192
 
        { "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", "%i", NULL, SHUT_FLAG_OK },
193
 
        { "ups.delay.shutdown",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeShutdown", "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY},
194
 
        { "ups.delay.reboot",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeReboot", "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY},
195
 
        { "ups.delay.start",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeStartup", "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY},
196
 
        { "ups.test.interval",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.BatterySystem.Battery.TestPeriod", "%i", NULL, SHUT_FLAG_OK },
197
 
        { "ups.test.result",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.BatterySystem.Battery.Test", "%i", NULL, SHUT_FLAG_OK },
 
328
        { "ups.mfr", ST_FLAG_STRING, 20, NULL, "%s", "MGE UPS SYSTEMS", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL },
 
329
        { "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", "%i", NULL, SHUT_FLAG_OK, NULL },
 
330
        { "ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeShutdown",
 
331
          "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY, NULL },
 
332
        { "ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeReboot",
 
333
          "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY, NULL },
 
334
        { "ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeStartup",
 
335
          "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY, NULL },
 
336
        /* FIXME: miss ups.power */
 
337
        { "ups.power.nominal", ST_FLAG_STRING, 5, "UPS.Flow.[4].ConfigApparentPower",
 
338
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
339
        { "ups.test.interval", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.BatterySystem.Battery.TestPeriod",
 
340
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
341
        { "ups.test.result", ST_FLAG_STRING, 5, "UPS.BatterySystem.Battery.Test",
 
342
          "%i", NULL, SHUT_FLAG_OK, &test_read_info[0] },
198
343
 
199
344
        /* Output page */
200
 
        { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", "%i", NULL, SHUT_FLAG_OK },
201
 
        { "output.voltage.target.line", 0, 0, "UPS.PowerSummary.ConfigVoltage", "%i", NULL, SHUT_FLAG_OK },
202
 
        { "output.voltage.target.battery", 0, 0, "UPS.PowerSummary.ConfigVoltage", "%i", NULL, SHUT_FLAG_OK },
203
 
        { "output.current", 0, 0, "UPS.PowerSummary.Output.Current", "%i", NULL, SHUT_FLAG_OK },
204
 
        { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", "%i", NULL, SHUT_FLAG_OK },
 
345
        { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", "%i", NULL, SHUT_FLAG_OK, NULL },
 
346
        { "output.voltage.target.line", 0, 0, "UPS.PowerSummary.ConfigVoltage", "%i", NULL, SHUT_FLAG_OK, NULL },
 
347
        { "output.voltage.target.battery", 0, 0, "UPS.PowerSummary.ConfigVoltage", "%i", NULL, SHUT_FLAG_OK, NULL },
 
348
        { "output.current", 0, 0, "UPS.PowerSummary.Output.Current", "%i", NULL, SHUT_FLAG_OK, NULL },
 
349
    { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", "%i", NULL, SHUT_FLAG_OK, NULL },
205
350
 
206
351
        /* Outlet page (using MGE UPS SYSTEMS - PowerShare technology) */
207
352
        /* TODO: add an iterative semantic [%x] to factorise outlets */
208
 
        { "outlet.0.id", 0, 0, "UPS.OutletSystem.Outlet.[1].OutletID", "%i", NULL, SHUT_FLAG_OK },
209
 
        { "outlet.0.desc",ST_FLAG_RW |ST_FLAG_STRING, 20, "", "s", "Main Outlet", SHUT_FLAG_ABSENT | SHUT_FLAG_OK },
210
 
        { "outlet.0.switchable", 0, 0, "UPS.OutletSystem.Outlet.[1].PresentStatus.Switchable", "%i", NULL, SHUT_FLAG_OK },
211
 
        { "outlet.1.id", 0, 0, "UPS.OutletSystem.Outlet.[2].OutletID", "%i", NULL, SHUT_FLAG_OK },      
212
 
        { "outlet.1.desc",ST_FLAG_RW |ST_FLAG_STRING, 20, "", "s", "PowerShare Outlet 1", SHUT_FLAG_ABSENT | SHUT_FLAG_OK },
213
 
        { "outlet.1.switchable", 0, 0, "UPS.OutletSystem.Outlet.[2].PresentStatus.Switchable", "%i", NULL, SHUT_FLAG_OK },
214
 
        { "outlet.1.switch",ST_FLAG_RW |ST_FLAG_STRING, 2, "UPS.OutletSystem.Outlet.[2].PresentStatus.SwitchOn/Off", "%i", NULL, SHUT_FLAG_OK },
215
 
        { "outlet.1.autoswitch.charge.low",ST_FLAG_RW |ST_FLAG_STRING, 3, "UPS.OutletSystem.Outlet.[2].RemainingCapacityLimit", "%i", NULL, SHUT_FLAG_OK },
216
 
        { "outlet.1.delay.shutdown",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[2].DelayBeforeShutdown", "%i", NULL, SHUT_FLAG_OK },
217
 
        { "outlet.1.delay.start",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[2].DelayBeforeStartup", "%i", NULL, SHUT_FLAG_OK },
218
 
        { "outlet.2.id", 0, 0, "UPS.OutletSystem.Outlet.[3].OutletID", "%i", NULL, SHUT_FLAG_OK },      
219
 
        { "outlet.2.desc",ST_FLAG_RW |ST_FLAG_STRING, 20, "", "s", "PowerShare Outlet 2", SHUT_FLAG_ABSENT | SHUT_FLAG_OK },
220
 
        { "outlet.2.switchable", 0, 0, "UPS.OutletSystem.Outlet.[3].PresentStatus.Switchable", "%i", NULL, SHUT_FLAG_OK },
221
 
        { "outlet.2.switch",ST_FLAG_RW |ST_FLAG_STRING, 2, "UPS.OutletSystem.Outlet.[3].PresentStatus.SwitchOn/Off", "%i", NULL, SHUT_FLAG_OK },
222
 
        { "outlet.2.autoswitch.charge.low",ST_FLAG_RW |ST_FLAG_STRING, 3, "UPS.OutletSystem.Outlet.[3].RemainingCapacityLimit", "%i", NULL, SHUT_FLAG_OK },
223
 
        { "outlet.2.delay.shutdown",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[3].DelayBeforeShutdown", "%i", NULL, SHUT_FLAG_OK },
224
 
        { "outlet.2.delay.start",ST_FLAG_RW |ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", "%i", NULL, SHUT_FLAG_OK },
 
353
        { "outlet.0.id", 0, 0, "UPS.OutletSystem.Outlet.[1].OutletID", "%i", NULL, SHUT_FLAG_OK, NULL },
 
354
        { "outlet.0.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[1].OutletID",
 
355
          "%s", "Main Outlet", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL },
 
356
        { "outlet.0.switchable", 0, 0, "UPS.OutletSystem.Outlet.[1].PresentStatus.Switchable",
 
357
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
358
        { "outlet.1.id", 0, 0, "UPS.OutletSystem.Outlet.[2].OutletID", "%i", NULL, SHUT_FLAG_OK, NULL },        
 
359
        { "outlet.1.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[2].OutletID",
 
360
          "%s", "PowerShare Outlet 1", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL },
 
361
        { "outlet.1.switchable", 0, 0, "UPS.OutletSystem.Outlet.[2].PresentStatus.Switchable",
 
362
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
363
        { "outlet.1.switch", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.OutletSystem.Outlet.[2].PresentStatus.SwitchOn/Off",
 
364
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
365
        { "outlet.1.autoswitch.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 3,
 
366
          "UPS.OutletSystem.Outlet.[2].RemainingCapacityLimit", "%i", NULL, SHUT_FLAG_OK, NULL },
 
367
        { "outlet.1.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5,
 
368
          "UPS.OutletSystem.Outlet.[2].DelayBeforeShutdown", "%i", NULL, SHUT_FLAG_OK, NULL },
 
369
        { "outlet.1.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[2].DelayBeforeStartup", "%i", NULL, SHUT_FLAG_OK, NULL },
 
370
        { "outlet.2.id", 0, 0, "UPS.OutletSystem.Outlet.[3].OutletID", "%i", NULL, SHUT_FLAG_OK, NULL },        
 
371
        { "outlet.2.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[3].OutletID",
 
372
          "%s", "PowerShare Outlet 2", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL },
 
373
        { "outlet.2.switchable", 0, 0, "UPS.OutletSystem.Outlet.[3].PresentStatus.Switchable",
 
374
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
375
        { "outlet.2.switch", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.OutletSystem.Outlet.[3].PresentStatus.SwitchOn/Off",
 
376
          "%i", NULL, SHUT_FLAG_OK, NULL },
 
377
        { "outlet.2.autoswitch.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 3,
 
378
          "UPS.OutletSystem.Outlet.[3].RemainingCapacityLimit", "%i", NULL, SHUT_FLAG_OK, NULL },
 
379
        { "outlet.2.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5,
 
380
          "UPS.OutletSystem.Outlet.[3].DelayBeforeShutdown", "%i", NULL, SHUT_FLAG_OK, NULL },
 
381
        { "outlet.2.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 5,
 
382
          "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", "%i", NULL, SHUT_FLAG_OK, NULL },
225
383
 
226
384
        /* Input page */
227
 
        { "input.voltage", 0, 0, "UPS.PowerConverter.Input.[1].Voltage", "%i", NULL, SHUT_FLAG_OK },
228
 
        { "input.frequency", 0, 0, "UPS.PowerConverter.Input.[1].Frequency", "%i", NULL, SHUT_FLAG_OK },
 
385
        { "input.voltage", 0, 0, "UPS.PowerConverter.Input.[1].Voltage", "%i", NULL, SHUT_FLAG_OK, NULL },
 
386
        { "input.frequency", 0, 0, "UPS.PowerConverter.Input.[1].Frequency", "%i", NULL, SHUT_FLAG_OK, NULL },
229
387
 
230
388
        /* terminating element */
231
 
        { NULL, 0, 0, "\0", "\0", NULL, 0 } 
 
389
        { NULL, 0, 0, "\0", "\0", NULL, 0, NULL } 
232
390
};
233
391
 
234
392
/* temporary usage code lookup */
235
393
typedef struct {
236
 
        char *usage_name;
 
394
        const char *usage_name;
237
395
        int usage_code;
238
396
} usage_lkp_t;
239
397
 
265
423
        {  "DelayBeforeStartup", 0x00840056 },
266
424
        {  "DelayBeforeShutdown", 0x00840057 },
267
425
        {  "Test", 0x00840058 },
 
426
        {  "Good", 0x00840061 },
268
427
        {  "OverLoad", 0x00840065 }, /* mispelled in usb.ids */
269
428
        {  "SwitchOn/Off", 0x0084006b },        
270
429
        {  "Switchable", 0x0084006c },  
 
430
        {  "Used", 0x0084006d },
271
431
        {  "Flow", 0x0084001e },
272
432
        /* Battery System Page */
273
433
        {  "RemainingCapacityLimit", 0x00850029 },
289
449
/* SHUT / HID functions Prototypes */
290
450
 
291
451
int   shut_ups_start(void);
292
 
uchar shut_checksum(const unsigned char *buf, int bufsize);
293
 
int   shut_token_send(unsigned char token);
294
 
int   shut_packet_send (hid_data_u *hdata, int datalen, unsigned char token);
295
 
int   shut_packet_recv (unsigned char *Buf, int datalen);
 
452
u_char shut_checksum(const u_char *buf, int bufsize);
 
453
int   shut_token_send(u_char token);
 
454
int   shut_packet_send (hid_data_u *hdata, int datalen, u_char token);
 
455
int   shut_packet_recv (u_char *Buf, int datalen);
296
456
 
297
 
int   shut_get_descriptor(int desctype, unsigned char *pkt, int reportlen);
298
 
int   shut_get_string(int index, char *string, int strlen);
299
 
int   shut_get_report(int id, unsigned char *pkt, int reportlen);
300
 
int   shut_set_report(int id, unsigned char *pkt, int reportlen);
 
457
int   shut_get_descriptor(int desctype, u_char *pkt, int reportlen);
 
458
int   shut_get_string(int strindex, char *string, int stringlen);
 
459
int   shut_get_report(int id, u_char *pkt, int reportlen);
 
460
int   shut_set_report(int id, u_char *pkt, int reportlen);
301
461
int   shut_identify_ups (void);
302
462
int   shut_wait_ack (void);
303
463
void  shut_ups_status(void);
304
464
 
305
465
int    hid_init_device(void);
306
 
int        hid_lookup_usage(char *name);
307
 
int    hid_get_value(char *item_path);
 
466
char  *get_model_name(char *iProduct, char *iModel);
 
467
int    hid_lookup_usage(char *name);
 
468
int    hid_get_value(const char *item_path);
308
469
int    hid_set_value(const char *varname, const char *val);
309
 
ushort lookup_path(char *HIDpath, HIDData *data);
 
470
u_short lookup_path(const char *HIDpath, HIDData *data);
310
471
 
311
472
int    instcmd(const char *cmdname, const char *extra);
312
473
void   setline(int set);
313
 
int    serial_read (int read_timeout, unsigned char *read);
314
 
int    serial_send(unsigned char *buf, int len);
 
474
int    serial_read (int read_timeout, u_char *readbuf);
 
475
int    serial_send(u_char *buf, int len);
315
476
 
316
 
void   dump_hex(const char *msg, const unsigned char *buf, int len);
317
 
void   make_string(unsigned char *buf, int datalen, char *string);
 
477
void   dump_hex(const char *msg, const u_char *buf, int len);
 
478
void   make_string(u_char *buf, int datalen, char *string);
318
479
 
319
480
 
320
481
mge_info_item *shut_find_info(const char *varname);