AtServerSimulator#

class lsst.ts.attcpip.AtServerSimulator(host, port, log, dispatch_callback, connect_callback=None, name='', **kwargs)#

Bases: OneClientReadLoopServer

An implementation of OneClientJsonServer that simulates an AT server.

Parameters:
  • host (str or None) – IP address for this server; typically LOCALHOST_IPV4 for IPV4 or LOCALHOST_IPV6 for IPV6. If None then bind to all network interfaces (e.g. listen on an IPv4 socket and an IPv6 socket). None can cause trouble with port=0; see port in the Attributes section for more information.

  • port (int) – IP port for this server. If 0 then randomly pick an available port (or ports, if listening on multiple sockets). 0 is strongly recommended for unit tests.

  • log (logging.Logger) – Logger.

  • dispatch_callback (callable) – Asynchronous function to call when data are read and dispatched.

  • connect_callback (callable or None, optional) – Asynchronous or (deprecated) synchronous function to call when when a client connects or disconnects. If the other end (client) closes the connection, it may take monitor_connection_interval seconds or longer to notice. The function receives one argument: this OneClientServer.

  • name (str, optional) – Name used for log messages, e.g. “Commands” or “Telemetry”.

  • **kwargs (dict [str, typing.Any]) – Additional keyword arguments for asyncio.start_server, beyond host and port.

Methods Summary

read_and_dispatch()

Read, parse, and dispatch one item of data.

Methods Documentation

async read_and_dispatch()#

Read, parse, and dispatch one item of data.

Subclasses need to implement this method such that it reads and parses data and then dispatches handling the data to a method suitable for the subclass. Methods that might be helpful include: :rtype: None

  • read_json to read json-encoded data

  • read_str to read terminated strings

  • read_into to read binary structs