Skip to content

Commit

Permalink
drivers/usbhid-ups.c: update messages and comments about onlinedischa…
Browse files Browse the repository at this point in the history
…rge_log_throttle_*charge [networkupstools#2215, networkupstools#2423]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed May 2, 2024
1 parent 8d1e049 commit 64dcd87
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions drivers/usbhid-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,8 @@ static void ups_status_set(void)
|| onlinedischarge_log_throttle_charge != -1
)) {
upsdebugx(1,
"%s: seems that UPS [%s] was in OL+DISCHRG state, "
"but no longer is now.",
"%s: seems that UPS [%s] was in OL+DISCHRG state "
"previously, but no is longer discharging now.",
__func__, upsname);
onlinedischarge_log_throttle_timestamp = 0;
onlinedischarge_log_throttle_charge = -1;
Expand Down Expand Up @@ -2011,9 +2011,21 @@ static void ups_status_set(void)
/* First disable, then enable if OK for noise*/
do_logmsg = 0;

/* Time or not, did the charge change since last log? */
/* Time or not, did the charge change since last log?
* Reminder: "onlinedischarge_log_throttle_charge" is
* the last-reported charge in OL+DISCHRG situation,
* as the battery remainder trickles down and we only
* report the changes (throttling the message stream).
* The "onlinedischarge_log_throttle_hovercharge" lets
* us ignore sufficiently high battery charges, where
* the user configuration (or defaults at 100%) tell
* us this is just about the battery not accepting the
* external power *all* the time so its charge "hovers"
* (typically between 90%-100%) to benefit the chemical
* process back-end of the battery and its life time.
*/
if ((s = dstate_getinfo("battery.charge"))) {
/* NOTE: "0" may mean a conversion error: */
/* NOTE: exact "0" may mean a conversion error: */
current_charge = atoi(s);
if (current_charge > 0
&& current_charge != onlinedischarge_log_throttle_charge
Expand Down Expand Up @@ -2073,6 +2085,7 @@ static void ups_status_set(void)
}

if (do_logmsg) {
/* If OL+DISCHRG, and not-throttled against log spam */
char msg_charge[LARGEBUF];
msg_charge[0] = '\0';

Expand Down

0 comments on commit 64dcd87

Please sign in to comment.