Project fixes and correct MARTe style makefile and source structure
This commit is contained in:
52
test_gui_sim.py
Normal file
52
test_gui_sim.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
import signal
|
||||
|
||||
# Start server
|
||||
print("Starting server...")
|
||||
proc = subprocess.Popen(
|
||||
["./run_debug_app.sh"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd="/home/martino/Projects/marte_debug",
|
||||
env=os.environ,
|
||||
)
|
||||
|
||||
time.sleep(5) # Wait for server to start
|
||||
|
||||
print("Connecting to server...")
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(3)
|
||||
s.connect(("127.0.0.1", 8080))
|
||||
|
||||
# Send TREE
|
||||
s.sendall(b"TREE\n")
|
||||
print("Sent TREE")
|
||||
|
||||
# Send DISCOVER immediately (like GUI does)
|
||||
s.sendall(b"DISCOVER\n")
|
||||
print("Sent DISCOVER")
|
||||
|
||||
# Wait and read
|
||||
time.sleep(1)
|
||||
data = b""
|
||||
while True:
|
||||
try:
|
||||
chunk = s.recv(4096)
|
||||
if not chunk:
|
||||
break
|
||||
data += chunk
|
||||
except:
|
||||
break
|
||||
|
||||
print(f"Got {len(data)} bytes")
|
||||
print("Contains OK TREE:", b"OK TREE" in data)
|
||||
print("Contains OK DISCOVER:", b"OK DISCOVER" in data)
|
||||
|
||||
s.close()
|
||||
proc.terminate()
|
||||
proc.wait()
|
||||
print("Done")
|
||||
Reference in New Issue
Block a user