From 96807ef32694a7ee661f90ca2ec1a9d0c20396ee Mon Sep 17 00:00:00 2001 From: Katherine A Miller Date: Wed, 7 Nov 2018 22:24:50 -0500 Subject: [PATCH] Update error correction --- .gitignore/error correction | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitignore/error correction b/.gitignore/error correction index ffe059c..111fb3a 100644 --- a/.gitignore/error correction +++ b/.gitignore/error correction @@ -33,14 +33,15 @@ def segmentString(string, fill): s1.append(s2) return s1 - def printFrames(frames): frameN = 0 for frame in frames: charN = 0 for bin in frame: char = e.bin2char(bin) - print(f"{charN:2}", bin, char) + b = bin + b = [int(n) for n in b] + print(f"{charN:2}", b, char) charN += 1 frameN += 1 print() @@ -82,3 +83,27 @@ def appendParityToFrames(frames, parity): newFrame = appendParityToFrame(frame, parity) newFrames.append(newFrame) return newFrames + +def transmitFrames(frames, error): + noisyFrames = [] + newFrames = [] + for frame in frames: + for row in frame: + row = [int(n) for n in row] + (newFrame, bitsFlipped) = e.addNoise(row, error) + newFrames.append(newFrame) + noisyFrames.append(newFrames) + print('The number of bits flipped', bitsFlipped) + return noisyFrames + +def splitFrame(frame): + payload = [] + parityColumn = [] + for row in frame[0:8]: + payload.append(row[0:8]) + parityColumn.append(row[8:]) + parityRow = frame[8:] + return payload, parityColumn, parityRow + + +