diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2021-04-09 18:38:02 +0200 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2021-04-09 18:38:57 +0200 |
commit | 50998fcfb916ae251309bd4b464f2c122e8cb30d (patch) | |
tree | 4ecf7a7443b75ab51c4dc0c0fc9289342dc7d6a0 /hardware/fw/reader.py | |
parent | 312fee491cfab436d52db4b6265107e20f3e1293 (diff) | |
download | master-thesis-50998fcfb916ae251309bd4b464f2c122e8cb30d.tar.gz master-thesis-50998fcfb916ae251309bd4b464f2c122e8cb30d.tar.bz2 master-thesis-50998fcfb916ae251309bd4b464f2c122e8cb30d.zip |
Repo re-org
Diffstat (limited to 'hardware/fw/reader.py')
-rw-r--r-- | hardware/fw/reader.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/hardware/fw/reader.py b/hardware/fw/reader.py new file mode 100644 index 0000000..c60edb7 --- /dev/null +++ b/hardware/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) + |