Commit 21b45a50 authored by joliu's avatar joliu

修改发现的BUG

parent a6f6ac04
......@@ -128,12 +128,6 @@ def sendBySocket(ip, port, cmd):
print("Error receiving data: %s" % err_msg)
s.close()
return (-1, err_msg)
try:
response = s.recv(1024).decode()
except socket.error as err_msg:
print("Error receiving data: %s" % err_msg)
s.close()
return (-1, err_msg)
print(str(response))
s.close()
......
......@@ -70,15 +70,20 @@ def mainWhileProcess(input_ctime):
(condition, command) = task.split(';')
(ip, port, method) = command.split(':')
# 构建控制指令
method = 'device&' + method
# 读取传感器数值
(status, output) = sendCommandToDevice(method)
# 针对dht11的数据格式做一个简单的数据预处理
output = output.split('&')[0]
if status == -1:
print("get device data failed! ip: %s, method: %s" % (ip, method))
continue
if compare(condition[0], float(output), float(condition[1:])):
# 当结果为真,向目标传感器发出指令
(status, output) = sendBySocket(ip, port, method)
(status, output) = sendBySocket(ip, int(port), method)
print(output)
else:
pass
......
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