SXXXXXXX_PyMsc/tests/run_with_placeholder.py
2025-12-10 11:47:46 +01:00

38 lines
994 B
Python

import time
import os
import sys
import ctypes
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if repo_root not in sys.path:
sys.path.insert(0, repo_root)
from pymsc.core.app_controller import AppController
print('RunWithPlaceholder: creating AppController and registering placeholder for SA=29')
app = AppController()
# Create a placeholder ctypes.Structure of 64 bytes (32 words)
class Payload64(ctypes.Structure):
_pack_ = 1
_fields_ = [("raw", ctypes.c_uint8 * 64)]
# Directly insert into rx_map so receiver will attempt to decode SA=29 payloads
app.rx_map[29] = Payload64
app.start()
# Let it run for a short time to collect packets from the radar
time.sleep(2.0)
print('RunWithPlaceholder: monitor_queue contents (first 50 entries):')
count = 0
while not app.monitor_queue.empty() and count < 50:
item = app.monitor_queue.get()
print(item)
count += 1
print('RunWithPlaceholder: stopping AppController')
app.stop()
print('Done')