Commit f2d183a9 authored by 方开's avatar 方开 🍔
Browse files

修复水份不返回数据的异常问题

parent bd516665
......@@ -196,7 +196,7 @@ def measureClient(sendAddr, cmd, measureType, houseType="multi", pointnum=None,
# return datas
except Exception as e:
datas = []
logging.warn(f"{e},硬件不返回数据")
logging.warning(f"{e},硬件不返回数据")
finally:
tcpSocket.close()
return datas
......@@ -334,8 +334,11 @@ def measureit(houseId, measureType="all", timeout=2):
# 注意到为了保证measureClient 函数的返回值一致,需要将水分值放在list里,所以使用的时候采用 data[0]
data = measureClient(addr, a2b_hex(
cmd), measureType, houseType, pointNum, timeout)
waterList = checkWater(cerealsSpecies, data[0])
dataList = waterList
if data == []:
dataList = []
else:
waterList = checkWater(cerealsSpecies, data[0])
dataList = waterList
logging.info(f"全部水份数据为-{dataList} ")
return dataList
......@@ -485,7 +488,7 @@ def recv(tcpSocket):
if not data:
break
logging.info(f"接收到服务器数据: {data}")
if "ff" in data and len(data)<10:
if "ff" in data and len(data) < 10:
logging.info("接收心跳包成功")
elif "measure" in data or "control" in data:
cmds = data.split("eeffeeff")
......@@ -537,7 +540,7 @@ def TCPClient():
gevent.spawn(heartBeat, tcpSocket)
])
except Exception as e:
logging.warn(f"连接发生错误:{e},30秒后再次尝试连接....")
logging.warning(f"连接发生错误:{e},30秒后再次尝试连接....")
time.sleep(30)
# 30秒重新连接服务器
continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment