summaryrefslogtreecommitdiff
path: root/prototype/fw/tools/ser_test.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2020-11-27 18:43:00 +0100
committerjaseg <git@jaseg.de>2020-11-27 18:43:00 +0100
commit822c8a21d7fd834a75be20765be4b4f2e5133009 (patch)
tree7dea4cd057c4a2882bdd7707a15dfaa47c8fc4d6 /prototype/fw/tools/ser_test.py
parent6ebd1a667d6e58ca355387af24bbe2a5b00baa50 (diff)
downloadihsm-822c8a21d7fd834a75be20765be4b4f2e5133009.tar.gz
ihsm-822c8a21d7fd834a75be20765be4b4f2e5133009.tar.bz2
ihsm-822c8a21d7fd834a75be20765be4b4f2e5133009.zip
test code
Diffstat (limited to 'prototype/fw/tools/ser_test.py')
-rw-r--r--prototype/fw/tools/ser_test.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/prototype/fw/tools/ser_test.py b/prototype/fw/tools/ser_test.py
index d9dec62..14addbd 100644
--- a/prototype/fw/tools/ser_test.py
+++ b/prototype/fw/tools/ser_test.py
@@ -28,13 +28,14 @@ if __name__ == '__main__':
make_color = lambda x: f'\033[38;5;{x}m'
field_colors = [ make_color(x) for x in [ 48, 48, 48, 48, 220, 220, 220, 220, 207, 207, 207, 207 ] ]
last_tx = time.time()
+ lastc = -10000
while True:
data = ser.read()
for c in data:
if byte_count == 0:
print(f'\033[38;5;244m{time.time() - start_time: 8.3f} \033[0m', end='')
- col = '\033[91m' if c == 0 else '\033[0m'
+ col = '\033[91m' if c == 0 else ('\033[0m' if c == (lastc - 1) % 256 else '\033[92m')
print(f'{col}{c:02x}', end=' ')
line += bytes([c])
byte_count += 1
@@ -63,6 +64,7 @@ if __name__ == '__main__':
print(f'\033[93m | {printable}\033[0m')
byte_count = 0
line = b''
+ lastc = c
if time.time() - last_tx > 0.01:
@@ -70,6 +72,6 @@ if __name__ == '__main__':
data = struct.pack('<I', seq)
#seq += 1
#ser.write(bytes(list(range(255, -1, -1))))
- ser.write(cobs.encode(data + struct.pack('<I', zlib.crc32(data))) + b'\0')
+ #ser.write(cobs.encode(data + struct.pack('<I', zlib.crc32(data))) + b'\0')
last_tx = time.time()
#time.sleep(0.01)