Skip to content

Commit 7eeb74b

Browse files
authored
Merge pull request #788 from madscientist159/master
Fix long-standing transfer threshold read bug with APCC 3 phase Symme…
2 parents ea2e088 + 9a48ba3 commit 7eeb74b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/snmp-ups.c

+19
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct snmp_session g_snmp_sess, *g_snmp_sess_p;
114114
const char *OID_pwr_status;
115115
int g_pwr_battery;
116116
int pollfreq; /* polling frequency */
117+
int quirk_symmetra_threephase = 0;
117118
/* Number of device(s): standard is "1", but daisychain means more than 1 */
118119
long devices_count = 1;
119120
int current_device_number = 0; /* global var to handle daisychain iterations - changed by loops in snmp_ups_walk() and su_addcmd() */
@@ -199,6 +200,11 @@ su_addcmd(su_info_p);
199200
if (testvar("notransferoids"))
200201
disable_transfer_oids();
201202

203+
if (testvar("symmetrathreephase"))
204+
quirk_symmetra_threephase = 1;
205+
else
206+
quirk_symmetra_threephase = 0;
207+
202208
/* initialize all other INFO_ fields from list */
203209
if (snmp_ups_walk(SU_WALKMODE_INIT) == TRUE)
204210
dstate_dataok();
@@ -302,6 +308,8 @@ void upsdrv_makevartable(void)
302308
"Specifies the Net-SNMP timeout in seconds between retries (default=1)");
303309
addvar(VAR_FLAG, "notransferoids",
304310
"Disable transfer OIDs (use on APCC Symmetras)");
311+
addvar(VAR_FLAG, "symmetrathreephase",
312+
"Enable APCC three phase Symmetra quirks (use on APCC three phase Symmetras)");
305313
addvar(VAR_VALUE, SU_VAR_SECLEVEL,
306314
"Set the securityLevel used for SNMPv3 messages (default=noAuthNoPriv, allowed: authNoPriv,authPriv)");
307315
addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_SECNAME,
@@ -2562,6 +2570,17 @@ bool_t su_ups_get(snmp_info_t *su_info_p)
25622570

25632571
if (su_info_p->info_flags & ST_FLAG_STRING) {
25642572
status = nut_snmp_get_str(su_info_p->OID, buf, sizeof(buf), su_info_p->oid2info);
2573+
if (status == TRUE) {
2574+
if (quirk_symmetra_threephase) {
2575+
if (!strcasecmp(su_info_p->info_type, "input.transfer.low")
2576+
|| !strcasecmp(su_info_p->info_type, "input.transfer.high")) {
2577+
/* Convert from three phase line-to-line voltage to line-to-neutral voltage */
2578+
double value = atof(buf);
2579+
value = value * 0.707;
2580+
snprintf(buf, sizeof(buf), "%.2f", value);
2581+
}
2582+
}
2583+
}
25652584
} else {
25662585
status = nut_snmp_get_int(su_info_p->OID, &value);
25672586
if (status == TRUE) {

0 commit comments

Comments
 (0)