Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Add grab_log script

Oleg Kalachevf9558e164c90
diff --git a/Makefile b/Makefile
index 6d19bbd..7dad359 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ simulator: build_simulator
gazebo --verbose ${CURDIR}/gazebo/flix.world
grab_log:
- tools/grab_log.py
+ PORT=$(PORT) tools/grab_log.py
clean:
rm -rf gazebo/plugin/build $(SKETCH)/build $(SKETCH)/cache
diff --git a/tools/grab_log.py b/tools/grab_log.py
new file mode 100755
index 0000000..620ea08
--- /dev/null
+++ b/tools/grab_log.py
@@ -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)}')