aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Twisted/py2/twisted/internet/_posixserialport.py
diff options
context:
space:
mode:
authorshmel1k <shmel1k@ydb.tech>2023-11-26 18:16:14 +0300
committershmel1k <shmel1k@ydb.tech>2023-11-26 18:43:30 +0300
commitb8cf9e88f4c5c64d9406af533d8948deb050d695 (patch)
tree218eb61fb3c3b96ec08b4d8cdfef383104a87d63 /contrib/python/Twisted/py2/twisted/internet/_posixserialport.py
parent523f645a83a0ec97a0332dbc3863bb354c92a328 (diff)
downloadydb-b8cf9e88f4c5c64d9406af533d8948deb050d695.tar.gz
add kikimr_configure
Diffstat (limited to 'contrib/python/Twisted/py2/twisted/internet/_posixserialport.py')
-rw-r--r--contrib/python/Twisted/py2/twisted/internet/_posixserialport.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/contrib/python/Twisted/py2/twisted/internet/_posixserialport.py b/contrib/python/Twisted/py2/twisted/internet/_posixserialport.py
new file mode 100644
index 0000000000..7d4730c3b5
--- /dev/null
+++ b/contrib/python/Twisted/py2/twisted/internet/_posixserialport.py
@@ -0,0 +1,73 @@
+# Copyright (c) Twisted Matrix Laboratories.
+# See LICENSE for details.
+
+
+"""
+Serial Port Protocol
+"""
+
+from __future__ import division, absolute_import
+
+# dependent on pyserial ( http://pyserial.sf.net/ )
+# only tested w/ 1.18 (5 Dec 2002)
+from serial import PARITY_NONE
+from serial import STOPBITS_ONE
+from serial import EIGHTBITS
+
+from twisted.internet.serialport import BaseSerialPort
+
+from twisted.internet import abstract, fdesc
+
+
+
+class SerialPort(BaseSerialPort, abstract.FileDescriptor):
+ """
+ A select()able serial device, acting as a transport.
+ """
+
+ connected = 1
+
+ def __init__(self, protocol, deviceNameOrPortNumber, reactor,
+ baudrate = 9600, bytesize = EIGHTBITS, parity = PARITY_NONE,
+ stopbits = STOPBITS_ONE, timeout = 0, xonxoff = 0, rtscts = 0):
+ abstract.FileDescriptor.__init__(self, reactor)
+ self._serial = self._serialFactory(
+ deviceNameOrPortNumber, baudrate=baudrate, bytesize=bytesize,
+ parity=parity, stopbits=stopbits, timeout=timeout,
+ xonxoff=xonxoff, rtscts=rtscts)
+ self.reactor = reactor
+ self.flushInput()
+ self.flushOutput()
+ self.protocol = protocol
+ self.protocol.makeConnection(self)
+ self.startReading()
+
+
+ def fileno(self):
+ return self._serial.fd
+
+
+ def writeSomeData(self, data):
+ """
+ Write some data to the serial device.
+ """
+ return fdesc.writeToFD(self.fileno(), data)
+
+
+ def doRead(self):
+ """
+ Some data's readable from serial device.
+ """
+ return fdesc.readFromFD(self.fileno(), self.protocol.dataReceived)
+
+
+ def connectionLost(self, reason):
+ """
+ Called when the serial port disconnects.
+
+ Will call C{connectionLost} on the protocol that is handling the
+ serial data.
+ """
+ abstract.FileDescriptor.connectionLost(self, reason)
+ self._serial.close()
+ self.protocol.connectionLost(reason)