X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/0a2693126165f68131a1d1686a2bee1f1967494d..d63010ef6c3cc76ac2a035c0249c87a78e38d980:/bin/weathermon?ds=sidebyside diff --git a/bin/weathermon b/bin/weathermon index 03fad42..6980cc8 100755 --- a/bin/weathermon +++ b/bin/weathermon @@ -388,21 +388,28 @@ end records = {} while 1 do + line=serialin:read("*l") + if line == nil then break end - printLog("Received: "..line); - if startswith(line,'{') then - processJson(line) - else - processLine(line) - end - if dump_file then - local f = io.open(dump_file,"w") - io.output(f) - io.write(json.encode(records)) - io.close(f) - end + pcall(function () + + printLog("Received: "..line) + if startswith(line,'{') then + processJson(line) + else + processLine(line) + end + + if dump_file then + local f = io.open(dump_file,"w") + io.output(f) + io.write(json.encode(records)) + io.close(f) + end + end) + end