fix the fix that fixed the fix
This commit is contained in:
parent
f26ff29eef
commit
5aaccabc93
16
main.py
16
main.py
@ -119,16 +119,19 @@ html = """<!DOCTYPE html>
|
|||||||
|
|
||||||
|
|
||||||
temps = deque(maxlen=10)
|
temps = deque(maxlen=10)
|
||||||
|
arduino = None
|
||||||
def stream(dev):
|
def stream(dev):
|
||||||
|
with serial.Serial(ser_dev, timeout=1) as s:
|
||||||
|
global arduino
|
||||||
|
arduino = s
|
||||||
while True:
|
while True:
|
||||||
temperature = dev.readline().decode().strip().split()[0]
|
temperature = s.readline().decode().strip().split()
|
||||||
if not temperature:
|
if not temperature:
|
||||||
continue
|
continue
|
||||||
print("temperature", temperature)
|
print("temperature", temperature)
|
||||||
temps.append(temperature)
|
temps.append(temperature[0])
|
||||||
|
|
||||||
|
|
||||||
arduino = None
|
|
||||||
|
|
||||||
def application(env, start_response):
|
def application(env, start_response):
|
||||||
|
|
||||||
@ -203,11 +206,8 @@ if __name__ == "__main__":
|
|||||||
print("{} is not a valid tty device".format(ser_dev))
|
print("{} is not a valid tty device".format(ser_dev))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
with serial.Serial(ser_dev, timeout=1) as s:
|
|
||||||
arduino = s
|
|
||||||
import threading
|
import threading
|
||||||
t = threading.Thread(target=stream, args=[s])
|
t = threading.Thread(target=stream, args=[ser_dev])
|
||||||
|
|
||||||
|
|
||||||
# classifying as a daemon, so they will die when the main dies
|
# classifying as a daemon, so they will die when the main dies
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
|
Loading…
Reference in New Issue
Block a user