mirror of
https://github.com/romanz/amodem.git
synced 2026-04-21 05:36:42 +08:00
Add RS ECC
This commit is contained in:
13
errors.py
13
errors.py
@@ -2,16 +2,15 @@ import common
|
||||
import sys
|
||||
|
||||
tx, rx = sys.argv[1:]
|
||||
tx = open(tx).read()
|
||||
rx = open(rx).read()
|
||||
tx = bytearray(open(tx).read())
|
||||
rx = bytearray(open(rx).read())
|
||||
|
||||
L = min(len(tx), len(rx))
|
||||
rx = list(common.to_bits(rx[:L]))
|
||||
tx = list(common.to_bits(tx[:L]))
|
||||
indices = [index for index, (r, t) in enumerate(zip(rx, tx)) if r != t]
|
||||
|
||||
if indices:
|
||||
total = L*8
|
||||
errors = len(indices)
|
||||
print('{}/{} bit error rate: {:.3f}%'.format(errors, total, (100.0 * errors) / total))
|
||||
sys.exit(1)
|
||||
total = L*8
|
||||
errors = len(indices)
|
||||
print('{}/{} bit error rate: {:.3f}%'.format(errors, total, (100.0 * errors) / total))
|
||||
sys.exit(int(errors > 0))
|
||||
|
||||
Reference in New Issue
Block a user