TelnetServerDevice¶
-
class
dvg_devices.BaseDevice.TelnetServerDevice(name='Dev_1', long_name='Telnet Server Device')[source]¶ This class provides blocking I/O methods for a telnet server device by wrapping the telnetlib3 library.
The following functionality is offered:
- I/O methods:
readline(),write(),query().
Instances of this class will tie in nicely with
dvg_qdeviceio.QDeviceIO.Parameters: Example:
from dvg_devices.BaseDevice import TelnetServerDevice dev = TelnetServerDevice() dev.connect(host="10.10.100.2", port=23) success, reply = dev.query("My query command")
Attributes:
-
telnet_settings¶ Dictionary of keyword arguments to be passed directly to
telnetlib3.sync.TelnetConnectionwhen calling method connect().Default: {“timeout”: 4, “encoding”: “utf8”,}
Type: dict
-
conn¶ Will be set to a
telnetlib3.sync.TelnetConnectioninstance when a connection has been established. Otherwise:None.Type: telnetlib3.sync.TelnetConnection|None
- I/O methods:
Methods¶
-
TelnetServerDevice.readline(raises_on_timeout: bool = False) Tuple[bool, Optional[Union[str, bytes]]][source]¶ Listen to the telnet server for incoming data. This method is blocking and returns when a full line has been received or when the read timeout has expired.
Parameters: raises_on_timeout (
bool, optional) – Should an exception be raised when a read timeout occurs?Default:
FalseReturns: Return type:
-
TelnetServerDevice.write(msg: str) bool[source]¶ Send a message to the telnet server.
Parameters: msg ( str) – ASCII string to be sent to the serial device.Returns: True if successful, False otherwise.