38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
#!/usr/bin/env python
|
|
|
|
import serial
|
|
import string
|
|
import re # Matches
|
|
import os
|
|
|
|
test=serial.Serial("/dev/ttyACM0",9600)
|
|
test.open()
|
|
onSort = False
|
|
try:
|
|
while not onSort:
|
|
line = test.readline()
|
|
sp = line.split(' ')
|
|
result = bool('fumee' in line)
|
|
if result:
|
|
print(line)
|
|
print(sp[0])
|
|
print(sp[1])
|
|
print(sp[2])
|
|
#print(line[6:9])
|
|
#print(line[14:18])
|
|
#print(line[24:26])
|
|
spCo = sp[0].split('=')
|
|
spButane = sp[1].split('=')
|
|
spPhoto = sp[2].split('=')[1].split('\r')
|
|
#print(spPhoto[1].split('\r'))
|
|
os.system("curl \"http://localhost:81/json.htm?type=command¶m=udevice&idx=110&nvalue=" + spCo[1] + "\"")
|
|
os.system("curl \"http://localhost:81/json.htm?type=command¶m=udevice&idx=109&nvalue=" + spButane[1] + "\"")
|
|
os.system("curl \"http://localhost:81/json.htm?type=command¶m=udevice&idx=107&svalue=" + spPhoto[0] + "\"")
|
|
onSort = True
|
|
|
|
except KeyboardInterrupt:
|
|
pass # do cleanup here
|
|
|
|
test.close()
|
|
|