o
    b!                     @   sT   d Z ddlmZ ddlmZmZ ddlmZmZ ddlm	Z	 G dd de	ej
ZdS )	z
Serial Port Protocol
    )PARITY_NONE)	EIGHTBITSSTOPBITS_ONE)abstractfdesc)BaseSerialPortc                   @   sL   e Zd ZdZdZdeeedddfddZdd Z	d	d
 Z
dd Zdd ZdS )
SerialPortz>
    A select()able serial device, acting as a transport.
       i%  r   c              
   C   s^   t j| | | j|||||||	|
d| _|| _|   |   || _| j	|  | 
  d S )N)baudratebytesizeparitystopbitstimeoutxonxoffrtscts)r   FileDescriptor__init___serialFactory_serialreactor
flushInputflushOutputprotocolmakeConnectionstartReading)selfr   deviceNameOrPortNumberr   r
   r   r   r   r   r   r    r   C/usr/lib/python3/dist-packages/twisted/internet/_posixserialport.pyr      s"   
zSerialPort.__init__c                 C   s   | j jS )N)r   fdr   r   r   r   fileno9   s   zSerialPort.filenoc                 C   s   t |  |S )z7
        Write some data to the serial device.
        )r   	writeToFDr!   )r   datar   r   r   writeSomeData<   s   zSerialPort.writeSomeDatac                 C   s   t |  | jjS )z:
        Some data's readable from serial device.
        )r   
readFromFDr!   r   dataReceivedr    r   r   r   doReadB   s   zSerialPort.doReadc                 C   s(   t j| | | j  | j| dS )z
        Called when the serial port disconnects.

        Will call C{connectionLost} on the protocol that is handling the
        serial data.
        N)r   r   connectionLostr   closer   )r   reasonr   r   r   r(   H   s   
zSerialPort.connectionLostN)__name__
__module____qualname____doc__	connectedr   r   r   r   r!   r$   r'   r(   r   r   r   r   r      s    
r   N)r.   serialr   r   r   twisted.internetr   r   twisted.internet.serialportr   r   r   r   r   r   r   <module>   s   