AtServerSimulator#
- class lsst.ts.attcpip.AtServerSimulator(host, port, log, dispatch_callback, connect_callback=None, name='', **kwargs)#
Bases:
OneClientReadLoopServerAn implementation of OneClientJsonServer that simulates an AT server.
- Parameters:
host (
strorNone) – IP address for this server; typicallyLOCALHOST_IPV4for IPV4 orLOCALHOST_IPV6for IPV6. IfNonethen bind to all network interfaces (e.g. listen on an IPv4 socket and an IPv6 socket). None can cause trouble with port=0; seeportin 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 (
callableorNone, 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 takemonitor_connection_intervalseconds or longer to notice. The function receives one argument: thisOneClientServer.name (
str, optional) – Name used for log messages, e.g. “Commands” or “Telemetry”.**kwargs (
dict[str,typing.Any]) – Additional keyword arguments forasyncio.start_server, beyond host and port.
Methods Summary
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:
Noneread_jsonto read json-encoded dataread_strto read terminated stringsread_intoto read binary structs