From b85c9aec3b5827596aa7a99b2419f9f465e86da9 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Tue, 30 Nov 2021 14:11:05 -0500 Subject: [PATCH] arris-sb6183: Fix int32 wrapping in WebUI When error counts wrap they are displayed as int32 and negative. Recast them to uint32 to fix math. Signed-off-by: Nathaniel Clark --- plugins/router/arris-sb6183 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/router/arris-sb6183 b/plugins/router/arris-sb6183 index 258f09f7..e3898da0 100755 --- a/plugins/router/arris-sb6183 +++ b/plugins/router/arris-sb6183 @@ -80,8 +80,12 @@ GPLv2 import re import os import sys +import ctypes from urllib import request +def fixint(i): + return ctypes.c_uint32(int(i)).value + HOSTNAME = os.getenv("hostname", None) STATUS_URL = "http://192.168.100.1/RgConnect.asp" INFO_URL = "http://192.168.100.1/RgSwInfo.asp" @@ -293,10 +297,10 @@ for row in trs: data = dict( zip(headings, ["".join(x.itertext()).strip() for x in row.findall("td")]) ) - uncorr += int(data["Uncorrectables"]) - correct += int(data["Corrected"]) + uncorr += fixint(data["Uncorrectables"]) + correct += fixint(data["Corrected"]) - channel = int(data["Channel"]) + channel = fixint(data["Channel"]) print("\nmultigraph arris_power.down_{0}".format(channel)) value = data["Power"].split(" ")[0] @@ -309,8 +313,8 @@ for row in trs: snr[channel - 1] = value print("multigraph arris_error.down_{0}".format(channel)) - print("corr.value {0}".format(data["Corrected"])) - print("uncr.value {0}".format(data["Uncorrectables"])) + print("corr.value {0}".format(fixint(data["Corrected"]))) + print("uncr.value {0}".format(fixint(data["Uncorrectables"]))) # Fill missing for i in range(len(trs), DOWNCOUNT): @@ -349,7 +353,7 @@ for row in trs: data = dict( zip(headings, ["".join(x.itertext()).strip() for x in row.findall("td")]) ) - channel = int(data["Channel"]) + channel = fixint(data["Channel"]) print("multigraph arris_power.up_{0}".format(channel)) value = data["Power"].split(" ")[0] print("power.value {0}".format(value))