aboutsummaryrefslogtreecommitdiffstats
path: root/edi/edidebug.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-10-17 19:39:09 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-10-17 19:39:09 +0200
commitc0e21b06f657135f3ffe1d647130419a70e530db (patch)
tree549d1b7cea143c56843a6a91f53068626e9906a0 /edi/edidebug.py
parent89351fa705159a0f0ec366d5f70b1c87a70837aa (diff)
downloadmmbtools-aux-c0e21b06f657135f3ffe1d647130419a70e530db.tar.gz
mmbtools-aux-c0e21b06f657135f3ffe1d647130419a70e530db.tar.bz2
mmbtools-aux-c0e21b06f657135f3ffe1d647130419a70e530db.zip
Fix EDI analysis RS check
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":