summaryrefslogtreecommitdiff
path: root/gm_platform/fw/reader.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2020-02-04 16:49:58 +0100
committerjaseg <git@jaseg.net>2020-02-04 16:49:58 +0100
commit3e782060fb42ca0a13c3927e00ff4f388f79156e (patch)
tree6083b424ee2669ece251c794c84de4e9dfeb5ecd /gm_platform/fw/reader.py
parenta6f75b2ce5f4a6d7d625d1753b97c075fc069705 (diff)
downloadmaster-thesis-3e782060fb42ca0a13c3927e00ff4f388f79156e.tar.gz
master-thesis-3e782060fb42ca0a13c3927e00ff4f388f79156e.tar.bz2
master-thesis-3e782060fb42ca0a13c3927e00ff4f388f79156e.zip
Working on analysis
Diffstat (limited to 'gm_platform/fw/reader.py')
-rw-r--r--gm_platform/fw/reader.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/gm_platform/fw/reader.py b/gm_platform/fw/reader.py
new file mode 100644
index 0000000..c60edb7
--- /dev/null
+++ b/gm_platform/fw/reader.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+
+import struct
+
+import sqlite3
+
+import serial
+from cobs import cobs
+
+if __name__ == '__main__':
+ import argparse
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-b', '--baudrate', type=int, default=250000)
+ parser.add_argument('port')
+ parser.add_argument('dbfile')
+ args = parser.parse_args()
+
+ db = sqlite3.connect(args.db)
+ ser = serial.Serial(args.port, args.baudrate)
+
+ while True:
+ packet = ser.read_until(b'\0')
+ try:
+ packet = cobs.decode(packet)
+ crc, seq, struct.decode('IBxH', packet[:8])
+
+ except Exception as e:
+ print(e)
+