28 lines
892 B
Python
28 lines
892 B
Python
# One-off bench probe: isolated 4096B echo test (4KB through 2KB chip buffer).
|
|
# Connects to MCU :8080, sends 4096B increment pattern, waits for full echo.
|
|
import socket, sys, time
|
|
|
|
ip, port = "192.168.1.100", 8080
|
|
data = bytes((i & 0xFF) for i in range(4096))
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(15)
|
|
t0 = time.time()
|
|
s.connect((ip, port))
|
|
s.sendall(data)
|
|
rx = b""
|
|
first = None
|
|
while len(rx) < 4096:
|
|
chunk = s.recv(4096 - len(rx))
|
|
if not chunk:
|
|
break
|
|
if first is None:
|
|
first = time.time()
|
|
rx += chunk
|
|
elapsed = (time.time() - t0) * 1000
|
|
if len(rx) == 4096 and rx == data:
|
|
print("PASS 4096B echo full match in %.1f ms (first byte %.1f ms)" % (elapsed, (first - t0) * 1000))
|
|
else:
|
|
print("FAIL 4096B echo: got %d/4096 bytes after %.1f ms" % (len(rx), elapsed))
|
|
s.close()
|
|
sys.exit(0 if len(rx) == 4096 and rx == data else 1)
|