29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""Run a known UART vector through the real ARM DSView worker (on the board)."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import struct
|
|
import sys
|
|
import tempfile
|
|
|
|
worker = Path(sys.argv[1]).resolve()
|
|
decoders = sys.argv[2]
|
|
with tempfile.TemporaryDirectory(prefix='scope-worker-test-') as temp:
|
|
root = Path(temp)
|
|
samples = bytearray([1]*32)
|
|
for value in (0x55, 0x41, 0xA3):
|
|
for bit in [0]+[(value>>i)&1 for i in range(8)]+[1, 1]:
|
|
samples.extend([bit]*16)
|
|
samples.extend([1]*64)
|
|
snapshot = root/'uart.bin'
|
|
snapshot.write_bytes(b'LDS1'+struct.pack('<III', 153600, 0, len(samples))+samples)
|
|
for decoder in ('0:uart', '1:uart'):
|
|
config = root/'config.ini'
|
|
config.write_text('['+decoder+']\nch.rxtx=0\nopt.baudrate=9600\n')
|
|
output = root/'result.tsv'
|
|
subprocess.run([str(worker), '--decode', decoders, str(output), decoder, str(config), str(snapshot)], check=True, timeout=30)
|
|
rows = [line.split('\t') for line in output.read_text().splitlines()]
|
|
data = [r for r in rows if len(r)>=6 and r[0]=='A' and r[4]=='RX/TX']
|
|
assert [r[5] for r in data] == ['0x55', '0x41', '0xA3'], data
|
|
assert [int(r[1]) for r in data] == [32, 208, 384], data
|
|
print('PASS ARM worker: DSView 0:UART and 1:UART, 55 41 A3, exact sample timestamps')
|