28 lines
No EOL
794 B
Python
28 lines
No EOL
794 B
Python
import subprocess
|
|
import numpy as np
|
|
from encoder import text_to_signal
|
|
from decoder import signal_to_text
|
|
|
|
def test_server():
|
|
message = "HelloWorld123 ThisIsATestMessage12345678"
|
|
x, codebook = text_to_signal(message, r=6, Eb=1)
|
|
np.savetxt("input.txt", x, fmt="%.10f")
|
|
|
|
subprocess.run([
|
|
"python3", "client.py",
|
|
"--input_file", "input.txt",
|
|
"--output_file", "output.txt",
|
|
"--srv_hostname", "iscsrv72.epfl.ch",
|
|
"--srv_port", "80"
|
|
])
|
|
|
|
y = np.loadtxt("output.txt")
|
|
decoded = signal_to_text(y, codebook, r=6)
|
|
|
|
print(f"Original: {message}")
|
|
print(f"Decoded : {decoded}")
|
|
errors = sum(1 for a, b in zip(message, decoded) if a != b)
|
|
print(f"Character errors: {errors}/40")
|
|
|
|
if __name__ == "__main__":
|
|
test_server() |