X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/e32107a7fe79ce34f3bdf860410a6d5455efdca7..d63010ef6c3cc76ac2a035c0249c87a78e38d980:/bin/weathermon 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