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

« back to all changes in this revision

Viewing changes to drivers/skel.c

  • 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:
5
5
 
6
6
#include "main.h"
7
7
 
 
8
/* #include "serial.h" */
 
9
 
8
10
/* #define ENDCHAR      '\r'    */
9
11
/* #define IGNCHARS     ""      */
10
12
 
12
14
 
13
15
void upsdrv_initinfo(void)
14
16
{
 
17
        /* try to detect the UPS here - call fatal() if it fails */
 
18
 
15
19
        dstate_setinfo("driver.version.internal", "%s", DRV_VERSION);
16
20
        /* dstate_setinfo("ups.mfr", "skel driver"); */
17
21
        /* dstate_setinfo("ups.model", "longrun 15000"); */
24
28
        /* int flags; */
25
29
        /* char temp[256]; */
26
30
 
27
 
        /* upssendchar(''); */
28
 
        /* upssend(""); */
 
31
        /* ser_sendchar(upsfd, 'A'); */
 
32
        /* ser_send(upsfd, "foo%d", 1234); */
 
33
        /* ser_send_buf(upsfd, bincmd, 12); */
29
34
 
30
35
        /* 
31
 
         * ret = upsrecv(temp, sizeof(temp), ENDCHAR, IGNCHARS);
 
36
         * ret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, IGNCHARS);
32
37
         *
33
38
         * if (ret < STATUS_LEN) {
34
39
         *      upslogx(LOG_ERR, "Short read from UPS");
63
68
 
64
69
void upsdrv_shutdown(void)
65
70
{
 
71
        /* tell the UPS to shut down, then return - DO NOT SLEEP HERE */
 
72
 
 
73
        /* maybe try to detect the UPS here, but try a shutdown even if
 
74
           it doesn't respond at first if possible */
 
75
 
66
76
        /* replace with a proper shutdown function */
67
77
        fatalx("shutdown not supported");
 
78
 
 
79
        /* you may have to check the line status since the commands
 
80
           for toggling power are frequently different for OL vs. OB */
 
81
 
 
82
        /* OL: this must power cycle the load if possible */
 
83
 
 
84
        /* OB: the load must remain off until the power returns */
68
85
}
69
86
 
70
87
/*
71
 
int instcmd(const char *cmdname, const char *extra)
 
88
static int instcmd(const char *cmdname, const char *extra)
72
89
{
73
90
        if (!strcasecmp(cmdname, "test.battery.stop")) {
74
 
                upssend("???");
 
91
                ser_send_buf(upsfd, ...);
75
92
                return STAT_INSTCMD_HANDLED;
76
93
        }
77
94
 
102
119
 
103
120
void upsdrv_initups(void)
104
121
{
105
 
        /* upssend_delay = 100; */
106
 
        /* open_serial(port, B1200); */
 
122
        /* upsfd = ser_open(device_path); */
 
123
        /* ser_set_speed(upsfd, device_path, B1200); */
 
124
 
107
125
        /* probe ups type */
108
126
 
109
127
        /* to get variables and flags from the command line, use this:
121
139
         * to show the value of cable:
122
140
         *
123
141
         *      if ((cable == getval("cable")))
124
 
         *              printf("cable is set to %s\n", getval("cable"));
 
142
         *              printf("cable is set to %s\n", cable);
125
143
         *      else
126
144
         *              printf("cable is not set!\n");
127
145
         *
131
149
        /* the upsh handlers can't be done here, as they get initialized
132
150
         * shortly after upsdrv_initups returns to main.
133
151
         */
 
152
 
 
153
        /* don't try to detect the UPS here */
134
154
}
135
155
 
136
156
void upsdrv_cleanup(void)
137
157
{
138
158
        /* free(dynamic_mem); */
 
159
        /* ser_close(upsfd, device_path); */
139
160
}