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

« back to all changes in this revision

Viewing changes to docs/commands.txt

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Quette
  • Date: 2004-05-28 13:10:01 UTC
  • mto: (16.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040528131001-yj2m9qcez4ya2w14
Tags: upstream-1.4.2
ImportĀ upstreamĀ versionĀ 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Desc: Commands sent to the UPS modules
 
1
Desc: Commands sent to the UPS drivers
2
2
File: commands.txt
3
 
Date: 7 Febuary 2002
 
3
Date: 30 June 2003
4
4
Auth: Russell Kroll <rkroll@exploits.org>
5
5
 
6
6
upsd can call drivers to store values in read/write variables and to kick
10
10
function pointers in your upsdrv_initinfo() function.  Right now, there
11
11
are only two possibilities:
12
12
 
13
 
        - setvar  = setting UPS variables (SET protocol command)
14
 
        - instcmd = instant UPS commands (INSTCMD protocol command)
15
 
 
16
 
If your module's function for handling variable set events is called 
 
13
Note: these have "new_" in front as a temporary measure to allow old
 
14
drivers and new drivers to coexist in the tree for a little while.  The 
 
15
final names will not have that prefix, and this note will disappear from
 
16
this file.
 
17
 
 
18
        - new_setvar  = setting UPS variables (SET VAR protocol command)
 
19
        - new_instcmd = instant UPS commands (INSTCMD protocol command)
 
20
 
 
21
SET
 
22
---
 
23
 
 
24
If your driver's function for handling variable set events is called 
17
25
my_ups_set(), then you'd do this to add the pointer:
18
26
 
19
 
        upsh.setvar = my_ups_set;
20
 
 
21
 
my_ups_set() will receive three parameters:
22
 
 
23
 
        int   - the type being set, see shared.h for the values
24
 
        int   - data length
25
 
        *char - pointer to the actual value that should be set
26
 
 
27
 
If you configure a handler for instcmd, it will receive the instant
28
 
command type (CMD_*) in the first int.  The other two variables are
29
 
not currently used for instant commands, and any values found in them
30
 
should be ignored.
 
27
        upsh.new_setvar = my_ups_set;
 
28
 
 
29
my_ups_set() will receive two parameters:
 
30
 
 
31
        const char * - the variable being changed
 
32
        const char * - the new value
 
33
 
 
34
You should return either STAT_SET_HANDLED if your driver recognizes the
 
35
command, or STAT_SET_UNKNOWN if it doesn't.  Other possibilities will be
 
36
added at some point in the future.
 
37
 
 
38
INSTCMD
 
39
-------
 
40
 
 
41
This works just like the set process, with slightly different values
 
42
arriving from the server.
 
43
 
 
44
        upsh.new_instcmd = my_ups_cmd;
 
45
 
 
46
Your function will receive two args:
 
47
 
 
48
        const char * - the command name
 
49
        const char * - (reserved)
 
50
 
 
51
You should return eeither STAT_INSTCMD_HANDLED or STAT_INSTCMD_UNKNOWN
 
52
depending on whether your driver can handle the requested command.
 
53
 
 
54
Notes
 
55
-----
 
56
 
 
57
Use strcasecmp.  The command names arriving from upsd should be treated
 
58
without regards to case.
31
59
 
32
60
Responses
33
61
---------