Added serial code
This commit is contained in:
parent
ae1b3cb08f
commit
557a158a9c
|
@ -4,8 +4,6 @@ from configutils import *
|
||||||
|
|
||||||
SERIAL = '/dev/ttyUSB0'
|
SERIAL = '/dev/ttyUSB0'
|
||||||
BAUD_RATE = 4800
|
BAUD_RATE = 4800
|
||||||
STOP_BITS = 1
|
|
||||||
PARITY = None
|
|
||||||
|
|
||||||
SFTP_HOST = 'rc-club-albersweiler.de'
|
SFTP_HOST = 'rc-club-albersweiler.de'
|
||||||
SFTP_PORT = 22
|
SFTP_PORT = 22
|
||||||
|
|
12
update.py
12
update.py
|
@ -63,6 +63,8 @@ def create_database():
|
||||||
def update_database(line):
|
def update_database(line):
|
||||||
update_values = []
|
update_values = []
|
||||||
for name, _, _ in STORED_VALUES:
|
for name, _, _ in STORED_VALUES:
|
||||||
|
if line[name] == None:
|
||||||
|
return
|
||||||
update_values += ["%f" % float(line[name])]
|
update_values += ["%f" % float(line[name])]
|
||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
@ -115,7 +117,15 @@ def upload_graphs():
|
||||||
print("Unexpected error while uploading:", sys.exc_info()[1])
|
print("Unexpected error while uploading:", sys.exc_info()[1])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
pass
|
ser = serial.Serial(SERIAL, BAUD_RATE, timeout=10.0)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
line = ser.readline().decode('ascii')
|
||||||
|
print(line)
|
||||||
|
if len(line) > 0:
|
||||||
|
parsed = parse_line(line)
|
||||||
|
update_database(parsed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue