Added serial code

This commit is contained in:
Sebastian 2018-10-20 20:13:23 +02:00
parent ae1b3cb08f
commit 557a158a9c
2 changed files with 11 additions and 3 deletions

View File

@ -4,8 +4,6 @@ from configutils import *
SERIAL = '/dev/ttyUSB0'
BAUD_RATE = 4800
STOP_BITS = 1
PARITY = None
SFTP_HOST = 'rc-club-albersweiler.de'
SFTP_PORT = 22

View File

@ -63,6 +63,8 @@ def create_database():
def update_database(line):
update_values = []
for name, _, _ in STORED_VALUES:
if line[name] == None:
return
update_values += ["%f" % float(line[name])]
now = time.time()
@ -115,7 +117,15 @@ def upload_graphs():
print("Unexpected error while uploading:", sys.exc_info()[1])
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__':