-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ports.py
More file actions
24 lines (22 loc) · 914 Bytes
/
test_ports.py
File metadata and controls
24 lines (22 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
"""Test rtkrcv TCP ports - checks which ports are accepting connections and receiving data."""
import socket, time
PORTS = {
10000: "rtkrcv rover input (RTCM from client)",
30000: "rtkrcv NMEA output",
40000: "rtkrcv corrections input",
}
for port, desc in PORTS.items():
try:
s = socket.create_connection(("127.0.0.1", port), timeout=2)
s.settimeout(3)
try:
data = s.recv(256)
print(f"[OK ] :{port} ({desc}) - connected, got {len(data)} bytes: {data[:32].hex(' ')}")
except socket.timeout:
print(f"[OK ] :{port} ({desc}) - connected, no data in 3s (may need input first)")
s.close()
except ConnectionRefusedError:
print(f"[ERR] :{port} ({desc}) - connection refused (port not open)")
except socket.timeout:
print(f"[ERR] :{port} ({desc}) - timeout (port not responding)")