BaseDevice#

class lsst.ts.ess.common.device.BaseDevice(name, device_id, sensor, baud_rate, callback_func, log)#

Bases: ABC

Base class for the different types of Sensor Devices.

This class holds all common code for the hardware devices. Device specific code (for instance for a serial or an FTDI device) needs to be implemented in a subclass.

Parameters:
  • name (str) – The name of the device.

  • device_id (str) – The hardware device ID to connect to. This can be a physical ID (e.g. /dev/ttyUSB0), a serial port (e.g. serial_ch_1) or any other ID used by the specific device.

  • sensor (BaseSensor) – The sensor that produces the telemetry.

  • baud_rate (int) – The baud rate of the sensor.

  • callback_func (Callable) – Callback function to receive the telemetry.

  • log (logging.Logger) – The logger to create a child logger for.

Methods Summary

basic_close()

Close the Sensor Device.

basic_open()

Open the Sensor Device.

close()

Stop the telemetry loop.

handle_readline_exception(exception)

Handle any exception that happened in the readline method.

open()

Generic open function.

readline()

Read a line of telemetry from the device.

Methods Documentation

abstract async basic_close()#

Close the Sensor Device.

Return type:

None

abstract async basic_open()#

Open the Sensor Device.

Return type:

None

async close()#

Stop the telemetry loop.

Return type:

None

async handle_readline_exception(exception)#

Handle any exception that happened in the readline method.

The default is to log and ignore but subclasses may override this method to customize the behavior.

Parameters:

exception (BaseException) – The exception to handle.

Return type:

None

async open()#

Generic open function.

Check if the device is open and, if not, call basic_open. Then start the telemetry loop.

Raises:

RuntimeError – In case the device already is open.

Return type:

None

abstract async readline()#

Read a line of telemetry from the device.

Returns:

line – Line read from the device. Includes terminator string if there is one. May be returned empty if nothing was received or partial if the readline was started during device reception.

Return type:

str