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