3
,s²Y	  ã               @   sÂ   d Z ddlmZmZ ddddddd	d
dddgZddlZddlmZmZmZ ddlm	Z	m
Z
 ddlmZmZmZmZ ddlmZ ddlmZ eG dd„ dƒƒZejƒ r²ddlmZ nddlmZ dS )z
Serial Port Protocol
é    )ÚdivisionÚabsolute_importÚserialÚ
PARITY_ODDÚPARITY_EVENÚPARITY_NONEÚSTOPBITS_TWOÚSTOPBITS_ONEÚFIVEBITSÚ	EIGHTBITSÚ	SEVENBITSÚSIXBITSÚ
SerialPortN)r   r   r   )r	   r   )r
   r   r   r   )Ú	_oldStyle)Úplatformc               @   sr   e Zd ZdZejZdd„ Zdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zddd„Zddd„ZdS )ÚBaseSerialPortaV  
    Base class for Windows and POSIX serial ports.

    @ivar _serialFactory: a pyserial C{serial.Serial} factory, used to create
        the instance stored in C{self._serial}. Overrideable to enable easier
        testing.

    @ivar _serial: a pyserial C{serial.Serial} instance used to manage the
        options on the serial port.
    c             C   s*   t | jdƒr| jj|ƒ n| jj|ƒ d S )NÚsetBaudrate)ÚhasattrÚ_serialr   ÚsetBaudRate)ÚselfZbaudrate© r   ú=/usr/lib/python3/dist-packages/twisted/internet/serialport.pyr   /   s    zBaseSerialPort.setBaudRatec             C   s
   | j jƒ S )N)r   Ú	inWaiting)r   r   r   r   r   5   s    zBaseSerialPort.inWaitingc             C   s   | j jƒ  d S )N)r   Ú
flushInput)r   r   r   r   r   8   s    zBaseSerialPort.flushInputc             C   s   | j jƒ  d S )N)r   ÚflushOutput)r   r   r   r   r   ;   s    zBaseSerialPort.flushOutputc             C   s   | j jƒ  d S )N)r   Ú	sendBreak)r   r   r   r   r   >   s    zBaseSerialPort.sendBreakc             C   s
   | j jƒ S )N)r   ÚgetDSR)r   r   r   r   r   A   s    zBaseSerialPort.getDSRc             C   s
   | j jƒ S )N)r   ÚgetCD)r   r   r   r   r   D   s    zBaseSerialPort.getCDc             C   s
   | j jƒ S )N)r   ÚgetRI)r   r   r   r   r   G   s    zBaseSerialPort.getRIc             C   s
   | j jƒ S )N)r   ÚgetCTS)r   r   r   r   r    J   s    zBaseSerialPort.getCTSé   c             C   s   | j j|ƒ d S )N)r   ÚsetDTR)r   Úonr   r   r   r"   M   s    zBaseSerialPort.setDTRc             C   s   | j j|ƒ d S )N)r   ÚsetRTS)r   r#   r   r   r   r$   P   s    zBaseSerialPort.setRTSN)r!   )r!   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ZSerialZ_serialFactoryr   r   r   r   r   r   r   r   r    r"   r$   r   r   r   r   r      s   
r   )r   )r(   Z
__future__r   r   Ú__all__r   r   r   r   r	   r   r
   r   r   r   Ztwisted.python._oldstyler   Ztwisted.python.runtimer   r   Z	isWindowsZ!twisted.internet._win32serialportr   Z!twisted.internet._posixserialportr   r   r   r   Ú<module>   s   7