Skip to content

Commit

Permalink
[lm] Add serial checksum error count to conf page
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Aug 10, 2012
1 parent 6230610 commit 65666e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions openwrt/package/linkmeter/luasrc/lucid/linkmeterd.lua
Expand Up @@ -251,8 +251,11 @@ local function segmentValidate(line)
csum = nixio.bit.bxor(csum, line:byte(i))
end

if csum ~= 0 then nixio.syslog("warning", "Checksum failed: "..line) end
csum = csum == 0
if not csum then
nixio.syslog("warning", "Checksum failed: "..line)
if hmConfig then hmConfig.cerr = (hmConfig.cerr or 0) + 1 end
end
end

-- Returns nil if no checksum or true/false if checksum checks
Expand Down Expand Up @@ -281,7 +284,7 @@ local function lmdStart()
local SERIAL_DEVICE = cfg:get("lucid", "linkmeter", "serial_device")
local SERIAL_BAUD = cfg:get("lucid", "linkmeter", "serial_baud")

if os.execute("/bin/stty -F " .. SERIAL_DEVICE .. " sane " .. SERIAL_BAUD) ~= 0 then
if os.execute("/bin/stty -F " .. SERIAL_DEVICE .. " raw -echo " .. SERIAL_BAUD) ~= 0 then
return nil, -2, "Can't set serial baud"
end

Expand Down
4 changes: 3 additions & 1 deletion openwrt/package/linkmeter/luasrc/view/linkmeter/conf.htm
Expand Up @@ -50,6 +50,8 @@
}
else if (k == "ucid")
elem.html(val);
else if (k == "cerr")
elem.html("Serial checksum errors: " + val);
else if (val != null)
elem.val(val);
else
Expand Down Expand Up @@ -351,7 +353,7 @@ <h3>HeaterMeter Configuration</h3>

<fieldset class="cbi-section" id="cbi-lm-pid">
<legend>HeaterMeter Information</legend>
Version <span id="ucid"></span>
Version <span id="ucid"></span><br/><span id="cerr" style="color: #f00;"></span>
</fieldset>

<input type="button" onclick="configToForm();" value="Reset to current"
Expand Down

0 comments on commit 65666e4

Please sign in to comment.