diff options
author | jaseg <git@jaseg.net> | 2020-02-04 16:49:58 +0100 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2020-02-04 16:49:58 +0100 |
commit | 3e782060fb42ca0a13c3927e00ff4f388f79156e (patch) | |
tree | 6083b424ee2669ece251c794c84de4e9dfeb5ecd /gm_platform/fw/tw_test.py | |
parent | a6f75b2ce5f4a6d7d625d1753b97c075fc069705 (diff) | |
download | master-thesis-3e782060fb42ca0a13c3927e00ff4f388f79156e.tar.gz master-thesis-3e782060fb42ca0a13c3927e00ff4f388f79156e.tar.bz2 master-thesis-3e782060fb42ca0a13c3927e00ff4f388f79156e.zip |
Working on analysis
Diffstat (limited to 'gm_platform/fw/tw_test.py')
-rw-r--r-- | gm_platform/fw/tw_test.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gm_platform/fw/tw_test.py b/gm_platform/fw/tw_test.py index cde59f0..e329abd 100644 --- a/gm_platform/fw/tw_test.py +++ b/gm_platform/fw/tw_test.py @@ -29,7 +29,6 @@ ctrl_reset = lambda: ctrl_packet(CtrlPacketTypes.RESET) ctrl_ack = lambda pid: ctrl_packet(CtrlPacketTypes.ACK, pid) ctrl_retransmit = lambda pid: ctrl_packet(CtrlPacketTypes.RETRANSMIT, pid) - if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() @@ -71,6 +70,7 @@ if __name__ == '__main__': last_pid = None lines_written = 0 cur = db.cursor() + capture_start = time() while True: #ser.write(cobs.encode(b'\x01\xff') + b'\0') data = ser.read_until(b'\0') @@ -91,17 +91,25 @@ if __name__ == '__main__': # Calculate byte-wise CRC32 our_crc = zlib.crc32(bytes(b for x in payload for b in (0, 0, 0, x))) #log.append((time(), seq, crc32, our_crc, pid, data)) - print(f'{ts:>7.3f} {seq:05d} {crc32:08x} {our_crc:08x} {pid} {hexlify(data).decode()}', end='') + bars = '\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588' + sparkline = ''.join(bars[int(x/4096*8)] for x in struct.unpack('<32H', data)) + print(f'\033[38;5;249m{ts-capture_start:>10.3f}', + f'\033[94m{seq:05d}', + f'\033[38;5;243m{crc32:08x}', + f'\033[38;5;243m{our_crc:08x}', + f'\033[38;5;243m{pid}', + f'\033[0m{hexlify(data).decode()}', + f'\033[94m{sparkline}\033[0m', end='') error = False suppress_ack = False if crc32 != our_crc: - print(' CRC ERROR', end='') + print(' \033[1;91mCRC ERROR\033[0m', end='') suppress_ack = True error = True if last_pid is not None and pid != (last_pid+1)%8: - print(' PID ERROR', end='') + print(' \033[1;93mPID ERROR\033[0m', end='') error = True else: last_pid = pid @@ -121,6 +129,8 @@ if __name__ == '__main__': if lines_written == 80: lines_written = 0 print('\033[2J\033[H', end='') + delta = ts-capture_start + print(f'\033[7mRun {run_id}, capturing for {delta//3600//24:> 3.0f}:{delta//3600%24:02.0f}:{delta//60%60:02.0f}:{delta%60:06.3f}\033[0m') db.commit() except Exception as e: |