Skip to content

Commit c6d97df

Browse files
committed
Reimplement sync to syn.
1 parent 51b230f commit c6d97df

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

scripts/irpmon/irpmon_to_json.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ def __init__(self, records):
161161
def communication(self):
162162
return self.comm
163163

164+
"""
165+
Return the remaining number of bytes.
166+
"""
167+
def remaining(self):
168+
remains = 0
169+
inner = self.index.inner
170+
for outer in range(self.index.outer, len(self.records)):
171+
this_record = self.records[outer]
172+
remains += len(this_record.data) - inner
173+
inner = 0
174+
return remains
175+
164176
"""
165177
Returns a new record index offset away from the current index.
166178
"""
@@ -258,12 +270,14 @@ def parse(self):
258270

259271

260272
def drop_until_syn(self):
261-
raise NotImplemented("todo")
262-
for i in range(1, len(data)):
263-
if data[i] == 0xaa and data[i+1] == 0x55:
264-
eprint("data dropped: " + ' '.join(map(hex, data[:i])))
265-
data_push(i+2)
266-
return data[i+2:]
273+
for i in range(1, self.remaining()):
274+
expected_syn = self.data(i, length=2)
275+
if expected_syn[0] == 0xaa and expected_syn[1] == 0x55:
276+
dropped_data = self.data(0, i)
277+
eprint(f"Found new syn, bytes dropped: {hfmt(dropped_data)}")
278+
self.advance(i)
279+
eprint(f"Now at {self.index} with record {self.current_record()}")
280+
return
267281

268282

269283
def parse_syn(self):

0 commit comments

Comments
 (0)