mirror of
https://github.com/okalachev/flix.git
synced 2025-07-27 17:49:33 +00:00
27 lines
581 B
Python
Executable File
27 lines
581 B
Python
Executable File
#!/usr/bin/env python3
|
|
# grab flight log and save to file
|
|
|
|
import datetime
|
|
import serial
|
|
import os
|
|
|
|
PORT = os.environ['PORT']
|
|
DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
dev = serial.Serial(port=PORT, baudrate=115200, timeout=0.5)
|
|
|
|
log = open(f'{DIR}/log/{datetime.datetime.now().isoformat()}.csv', 'wb')
|
|
|
|
print('Downloading log...')
|
|
count = 0
|
|
dev.write('log\n'.encode())
|
|
while True:
|
|
line = dev.readline()
|
|
if not line:
|
|
break
|
|
log.write(line)
|
|
count += 1
|
|
print(f'\r{count} lines', end='')
|
|
|
|
print(f'\nWritten {os.path.relpath(log.name, os.curdir)}')
|