o
    ¯bà  ã                   @   s‚   d Z g d¢ZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZ ddlmZ G dd„ dƒZe ¡ r9ddlmZ dS ddlmZ dS )	z
Serial Port Protocol
)ÚserialÚ
PARITY_ODDÚPARITY_EVENÚPARITY_NONEÚSTOPBITS_TWOÚSTOPBITS_ONEÚFIVEBITSÚ	EIGHTBITSÚ	SEVENBITSÚSIXBITSÚ
SerialPorté    N)	r   r   r   r   r   r	   r
   r   r   )Ú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 |¡ d S | j |¡ d S )NÚsetBaudrate)ÚhasattrÚ_serialr   ÚsetBaudRate)ÚselfÚbaudrate© r   ú=/usr/lib/python3/dist-packages/twisted/internet/serialport.pyr   ;   s   zBaseSerialPort.setBaudRatec                 C   ó
   | j  ¡ S ©N)r   Ú	inWaiting©r   r   r   r   r   A   ó   
zBaseSerialPort.inWaitingc                 C   ó   | j  ¡  d S r   )r   Ú
flushInputr   r   r   r   r   D   ó   zBaseSerialPort.flushInputc                 C   r   r   )r   ÚflushOutputr   r   r   r   r   G   r   zBaseSerialPort.flushOutputc                 C   r   r   )r   Ú	sendBreakr   r   r   r   r    J   r   zBaseSerialPort.sendBreakc                 C   r   r   )r   ÚgetDSRr   r   r   r   r!   M   r   zBaseSerialPort.getDSRc                 C   r   r   )r   ÚgetCDr   r   r   r   r"   P   r   zBaseSerialPort.getCDc                 C   r   r   )r   ÚgetRIr   r   r   r   r#   S   r   zBaseSerialPort.getRIc                 C   r   r   )r   ÚgetCTSr   r   r   r   r$   V   r   zBaseSerialPort.getCTSé   c                 C   ó   | j  |¡ d S r   )r   ÚsetDTR©r   Úonr   r   r   r'   Y   ó   zBaseSerialPort.setDTRc                 C   r&   r   )r   ÚsetRTSr(   r   r   r   r+   \   r*   zBaseSerialPort.setRTSN)r%   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚSerialÚ_serialFactoryr   r   r   r   r    r!   r"   r#   r$   r'   r+   r   r   r   r   r   -   s    
r   )r   )r/   Ú__all__r   r   r   r   r   r   r	   r
   r   r   Útwisted.python.runtimer   r   Ú	isWindowsÚ!twisted.internet._win32serialportr   Ú!twisted.internet._posixserialportr   r   r   r   Ú<module>   s   ,4