aboutsummaryrefslogtreecommitdiffstats
path: root/edi/edidebug.py
diff options
context:
space:
mode:
Diffstat (limited to 'edi/edidebug.py')
-rwxr-xr-xedi/edidebug.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/edi/edidebug.py b/edi/edidebug.py
index c27a374..ab61ab7 100755
--- a/edi/edidebug.py
+++ b/edi/edidebug.py
@@ -234,23 +234,38 @@ def get_rs_decoder(chunk_size, zeropad):
# p.hexpr(" ZE CHUNK DATA", c[0]);
# p.hexpr(" ZE CHUNK PROT", c[1]);
- rs_codec = RSCodec(48)
+ rs_codec = RSCodec(48, fcr=1)
+ protection_ok = True
for chunk, protection in rs_chunks:
- p.pr(" Protection")
+ #p.pr(" Protection")
#p.hexpr(" OF ZE CHUNK DATA", chunk);
- recalc_protection = rs_codec.encode(bytearray(chunk))[-48:]
- if (protection != recalc_protection):
+
+ bchunk = bytearray(chunk)
+ padbytes = 255-(48 + len(chunk))
+ bchunk = bchunk + bytearray(0 for i in range(padbytes))
+ recalc_protection = rs_codec.encode(bchunk)[-48:]
+ if protection != recalc_protection:
p.pr(" PROTECTION ERROR")
p.hexpr(" orig", protection)
p.hexpr(" calc", recalc_protection)
+ protection_ok = False
+ else:
+ p.pr(" PROTECTION OK")
+
+ if protection_ok:
+ p.pr("Protection check: OK")
+
afpacket = "".join(data for (data, protection) in rs_chunks)
#p.hexpr(" ZE AF PACKET", afpacket)
- return decode_af(afpacket[0:-zeropad])
+ if zeropad:
+ return decode_af(afpacket[0:-zeropad])
+ else:
+ return decode_af(afpacket)
return decode_rs
@@ -268,6 +283,9 @@ def decode_af(in_data, is_stream=False):
else:
headerdata = in_data[:10]
+ if len(headerdata) != 10:
+ p.hexpr("AF Header", headerdata)
+
sync, plen, seq, ar, pt = struct.unpack(af_head_struct, headerdata)
if sync != "AF":