[Nut-upsdev] Cleaned up belkinunv diff

j T hyvan_trant at hotmail.com
Fri Jun 9 12:07:52 UTC 2006


Hi Peter

Now I can get subdrivers to have ups.conf/command-line options, I've started 
looking at making the newhidups belkin-hid subdriver have the wait and 
wait-on-shutdown behaviour in the same was as belkinunv, and having just 
gone back and gone "yuck!" at my huge comments in my revised belkinunv 
source, I decided to clear out all the extraneous commentary in my 
waitonshutdown modifications.... you know it's bad when you can't see the 
code for the comments!

Anyway, I thought a cleaned-up version of the diff would be a good thing to 
post on here.

I've made a couple of tweaks too... nothing major though;

- the first change comes out of me having a bit more of a clue as to how 
things are working in the code, and makes the detection of [ waitonshutdown 
== "true" ] a little more complete (I'd missed out getval when checking if 
waitonshutdown were present and dstate_getinfo when checking if it were 
true...  I'm *really* not sure why I did... probably excess blood in my 
caffeine stream at the time! ;-) )

- the second change removed the function I'd introduced to perform the 
original "shutdown and hope" behaviour. The code is now back in 
upsdrv_shutdown() at the end and now looks like this:

upsdrv_shutdown()
    /* decide if we're in waitonshutdown and set wos=1 if we are
    ... */
    if (wos) {
        /* waitonshutdown: prepare things for going into belkin_wait()
        ... */
        belkin_wait()
        upslogx(LOG_WARNING, " belkinunv: WARNING: An error occurred in wait 
mode. Falling back to the original behaviour.");
    } else {
        upslogx(LOG_WARNING, "belkinunv: WARNING: You are using the -k 
option, which is broken for this driver.");
    }
    upslogx(LOG_WARNING, "Shutting down for 10 minutes and hoping for the 
best");
    belkin_nut_write_int(REG_RESTARTTIMER, 10); /* 10 minutes */
    belkin_nut_write_int(REG_SHUTDOWNTIMER, 1); /* 1 second */
}

The cleaned up version is a lot easier to source-read and I think it's more 
robust too.

Jo Turner
  -)O(-

-------------- next part --------------
A non-text attachment was scrubbed...
Name: belkinunv_wait_on_shutdown.diff
Type: text/x-patch
Size: 5704 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20060609/9c92bed5/belkinunv_wait_on_shutdown.bin


More information about the Nut-upsdev mailing list