add analyzer proxy magic

This commit is contained in:
Simon Renblad 2024-02-14 17:39:14 +08:00 committed by Sébastien Bourdeauducq
parent 21b77567f2
commit 795b8ae4c6
2 changed files with 5 additions and 2 deletions

View File

@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
DEFAULT_REF_PERIOD = 1e-9
ANALYZER_MAGIC = b"ARTIQ Analyzer Proxy\n"
class MessageType(Enum):
@ -156,8 +157,9 @@ class AnalyzerProxyReceiver:
async def connect(self, host, port):
self.reader, self.writer = \
await keepalive.async_open_connection(host, port)
magic = get_analyzer_magic()
try:
line = await self.reader.readline()
assert line == ANALYZER_MAGIC
self.receive_task = asyncio.create_task(self._receive_cr())
except:
if self.writer is not None:

View File

@ -9,7 +9,7 @@ from sipyco.asyncio_tools import AsyncioServer, SignalHandler, atexit_register_c
from sipyco.pc_rpc import Server
from sipyco import common_args
from artiq.coredevice.comm_analyzer import get_analyzer_dump
from artiq.coredevice.comm_analyzer import get_analyzer_dump, ANALYZER_MAGIC
logger = logging.getLogger(__name__)
@ -24,6 +24,7 @@ class ProxyServer(AsyncioServer):
async def _handle_connection_cr(self, reader, writer):
try:
writer.write(ANALYZER_MAGIC)
queue = asyncio.Queue(self._queue_limit)
self._recipients.add(queue)
try: