mirror of
https://github.com/okalachev/flix.git
synced 2025-07-29 12:28:59 +00:00
Add grab_log script
This commit is contained in:
parent
4a045d89a4
commit
f9558e164c
2
Makefile
2
Makefile
@ -33,7 +33,7 @@ simulator: build_simulator
|
|||||||
gazebo --verbose ${CURDIR}/gazebo/flix.world
|
gazebo --verbose ${CURDIR}/gazebo/flix.world
|
||||||
|
|
||||||
grab_log:
|
grab_log:
|
||||||
tools/grab_log.py
|
PORT=$(PORT) tools/grab_log.py
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf gazebo/plugin/build $(SKETCH)/build $(SKETCH)/cache
|
rm -rf gazebo/plugin/build $(SKETCH)/build $(SKETCH)/cache
|
||||||
|
26
tools/grab_log.py
Executable file
26
tools/grab_log.py
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/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)}')
|
Loading…
x
Reference in New Issue
Block a user