lewis.examples.timeout_device

Members

TimeTerminatedDevice

TimeTerminatedInterface

A simple device where commands are terminated by a timeout.

class lewis.examples.timeout_device.TimeTerminatedDevice[source]

Bases: Device

class lewis.examples.timeout_device.TimeTerminatedInterface[source]

Bases: StreamInterface

A simple device where commands are terminated by a timeout.

This demonstrates how to implement devices that do not have standard terminators and where a command is considered terminated after a certain time delay of not receiving more data.

To interact with this device, you must switch telnet into char mode, or use netcat with special tty settings:

$ telnet host port ^] telnet> mode char [type command and wait]

$ stty -icanon && nc host port hello world! foobar!

The following commands are available:

  • ``hello ``: Reply with “world!”

  • foo: Replay with “bar!”

  • P: Returns the device parameter

  • P=something: Set parameter to specified value

handle_error(request, error)[source]

Override this method to handle exceptions that are raised during command processing. The default implementation does nothing, so that any errors are silently ignored.

Parameters:
  • request – The request that resulted in the error.

  • error – The exception that was raised.