3Raw UDP packet capture - bypasses DAQ bridge to see what's actually arriving
9from datetime
import datetime
14print(f
"=== Raw UDP Packet Capture on Port {PORT} ===")
15print(f
"Listening for {TIMEOUT} seconds...")
19sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
21sock.bind((
"0.0.0.0", PORT))
24print(f
"✅ Socket bound to 0.0.0.0:{PORT}")
33 data, addr = sock.recvfrom(4096)
36 print(f
"[Packet #{packet_count}] From: {addr[0]}:{addr[1]}")
37 print(f
" Size: {len(data)} bytes")
38 print(f
" Time: {datetime.now().strftime('%H:%M:%S.%f')[:-3]}")
41 hex_str =
" ".join(f
"{b:02x}" for b
in data[:32])
42 print(f
" First 32 bytes: {hex_str}")
45 ascii_str =
"".join(chr(b)
if 32 <= b < 127
else "." for b
in data[:32])
46 print(f
" ASCII: {ascii_str}")
52 print(f
" ✅ Looks like SENSOR_DATA packet (type=3)")
53 elif 1 <= first_byte <= 9:
54 print(f
" ⚠️ Valid packet type ({first_byte}) but not SENSOR_DATA")
56 print(f
" ⚠️ Unknown packet type: 0x{first_byte:02x}")
60 except socket.timeout:
62 except KeyboardInterrupt:
71print(f
"\n=== Summary ===")
72print(f
"Total packets received: {packet_count}")
75 print(
"\n⚠️ No packets received!")
76 print(
"\nTroubleshooting:")
77 print(
" 1. Check board is sending to correct IP and port")
78 print(
" 2. Check firewall: sudo ufw status")
79 print(
" 3. Check network connectivity")
80 print(
" 4. Verify board is actually sending (check Serial monitor)")
TOML_NODISCARD_CTOR time() noexcept=default