Skip to content

Commit

Permalink
Simple Python to extract bitstream from a Pulseview hex digit export
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed May 22, 2024
1 parent cc53204 commit d14e0db
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions grok.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Takes pulseview Hexadeciomal digits export

import re, sys
from bitarray import bitarray

f = open(sys.argv[1], 'r')

MHZ=6
CELL=4*MHZ
THRESH=2*CELL-MHZ//2

b = bitarray()
count, prev, run = 0, 128, 0
for line in f:
if count == 1000:
break
if not line.startswith('RDATA'):
continue
count += 1
for i in range(6, len(line)-1, 3):
x = int(line[i:i+2], 16)
for j in range(8):
level = x & 128
if level != prev:
prev = level
if level == 0:
while run > THRESH:
b.append(False)
run -= CELL
b.append(True)
run = 0
run += 1
x <<= 1
print(b)

0 comments on commit d14e0db

Please sign in to comment.