Отключение буферизации штатными средствами lua.
authorRoman Bazalevsky <rvb@rvb.name>
Wed, 14 Nov 2018 16:06:22 +0000 (19:06 +0300)
committerRoman Bazalevsky <rvb@rvb.name>
Wed, 14 Nov 2018 16:06:22 +0000 (19:06 +0300)
bin/weathermon
bin/weathermon-iio

index 6980cc835dfc8e2aa6caa9794e282ce3c8ec7443..b8be15fbc785941f9b2a77421adbb13b64b9245e 100755 (executable)
@@ -118,7 +118,9 @@ end
 
 function submitValue(type,id,param,val)
 
-  if web_url then
+  val = tonumber(val)
+
+  if web_url and val then
 
     local url = web_url.."?stype="..url_encode(type).."&sid="..url_encode(id).."&param="..url_encode(param).."&value="..url_encode(val)
 
@@ -133,8 +135,8 @@ function submitValue(type,id,param,val)
         return req_sock
       end})
 
-    if code ~= 200 then
-      print("writing record to backlog...")
+    if code ~= 200 and backlog_con then
+      printLog("writing record to backlog...")
       backlog_con:execute(string.format("INSERT INTO queue(time_stamp,sensor_id,sensor,param,value) VALUES (datetime('now','localtime'),'%s','%s','%s',%f)",id,type,param,val))
     end
 
@@ -385,6 +387,8 @@ else
   return
 end  
 
+serialin:setvbuf('no')
+
 records = {}
 
 while 1 do
index df32c3ad5849bc90d793f4379aa76b61667f1da0..cbf21f0c996fc984e7fe9c5fc20466c233ab00b3 100755 (executable)
@@ -188,6 +188,8 @@ if not delay then
   delay = 60
 end
 
+io.stdout:setvbuf('no')
+
 while true do
   if pcall(function () values = get_parameters(parameters) end) then
     records = {}