U
    Â“«jÎ  ã                   @   s’   d 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mZmZmZm	Z	m
Z
mZ ddlmZ G dd„ dƒZe ¡ r‚ddlmZ n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 |¡ n| j |¡ d S )NÚsetBaudrate)ÚhasattrÚ_serialr   ÚsetBaudRate)ÚselfZbaudrate© r   ú?/tmp/pip-unpacked-wheel-59kc99xd/twisted/internet/serialport.pyr   ;   s    zBaseSerialPort.setBaudRatec                 C   s
   | j  ¡ S ©N)r   Ú	inWaiting©r   r   r   r   r   A   s    zBaseSerialPort.inWaitingc                 C   s   | j  ¡  d S r   )r   Ú
flushInputr   r   r   r   r   D   s    zBaseSerialPort.flushInputc                 C   s   | j  ¡  d S r   )r   ÚflushOutputr   r   r   r   r   G   s    zBaseSerialPort.flushOutputc                 C   s   | j  ¡  d S r   )r   Ú	sendBreakr   r   r   r   r   J   s    zBaseSerialPort.sendBreakc                 C   s
   | j  ¡ S r   )r   ÚgetDSRr   r   r   r   r   M   s    zBaseSerialPort.getDSRc                 C   s
   | j  ¡ S r   )r   ÚgetCDr   r   r   r   r   P   s    zBaseSerialPort.getCDc                 C   s
   | j  ¡ S r   )r   ÚgetRIr   r   r   r   r   S   s    zBaseSerialPort.getRIc                 C   s
   | j  ¡ S r   )r   ÚgetCTSr   r   r   r   r   V   s    zBaseSerialPort.getCTSé   c                 C   s   | j  |¡ d S r   )r   ÚsetDTR©r   Úonr   r   r   r!   Y   s    zBaseSerialPort.setDTRc                 C   s   | j  |¡ d S r   )r   ÚsetRTSr"   r   r   r   r$   \   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(   Ú__all__r   r   r   r   r   r   r	   r
   r   r   Ztwisted.python.runtimer   r   Z	isWindowsZ!twisted.internet._win32serialportr   Z!twisted.internet._posixserialportr   r   r   r   Ú<module>   s&   	ô,4