2
anything commented is optional
3
anything else is mandatory
8
/* #define ENDCHAR '\r' */
9
/* #define IGNCHARS "" */
11
#define DRV_VERSION "0.01"
13
void upsdrv_initinfo(void)
15
dstate_setinfo("driver.version.internal", "%s", DRV_VERSION);
16
/* dstate_setinfo("ups.mfr", "skel driver"); */
17
/* dstate_setinfo("ups.model", "longrun 15000"); */
19
/* upsh.instcmd = instcmd; */
22
void upsdrv_updateinfo(void)
27
/* upssendchar(''); */
31
* ret = upsrecv(temp, sizeof(temp), ENDCHAR, IGNCHARS);
33
* if (ret < STATUS_LEN) {
34
* upslogx(LOG_ERR, "Short read from UPS");
41
/* dstate_setinfo("var.name", ""); */
43
/* if (ioctl(upsfd, TIOCMGET, &flags)) {
44
* upslog(LOG_ERR, "TIOCMGET");
64
void upsdrv_shutdown(void)
66
/* replace with a proper shutdown function */
67
fatalx("shutdown not supported");
71
int instcmd(const char *cmdname, const char *extra)
73
if (!strcasecmp(cmdname, "test.battery.stop")) {
75
return STAT_INSTCMD_HANDLED;
78
upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname);
79
return STAT_INSTCMD_UNKNOWN;
83
void upsdrv_help(void)
87
/* list flags and values that you want to receive via -x */
88
void upsdrv_makevartable(void)
90
/* allow '-x xyzzy' */
91
/* addvar(VAR_FLAG, "xyzzy", "Enable xyzzy mode"); */
93
/* allow '-x foo=<some value>' */
94
/* addvar(VAR_VALUE, "foo", "Override foo setting"); */
97
void upsdrv_banner(void)
99
printf("Network UPS Tools - Skeleton UPS driver %s (%s)\n\n",
100
DRV_VERSION, UPS_VERSION);
103
void upsdrv_initups(void)
105
/* upssend_delay = 100; */
106
/* open_serial(port, B1200); */
109
/* to get variables and flags from the command line, use this:
111
* first populate with upsdrv_buildvartable above, then...
113
* set flag foo : /bin/driver -x foo
114
* set variable 'cable' to '1234' : /bin/driver -x cable=1234
116
* to test flag foo in your code:
118
* if (testvar("foo"))
121
* to show the value of cable:
123
* if ((cable == getval("cable")))
124
* printf("cable is set to %s\n", getval("cable"));
126
* printf("cable is not set!\n");
128
* don't use NULL pointers - test the return result first!
131
/* the upsh handlers can't be done here, as they get initialized
132
* shortly after upsdrv_initups returns to main.
136
void upsdrv_cleanup(void)
138
/* free(dynamic_mem); */