ó
[³XMc           @   sÊ   d  Z  d d l Z d d l 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 m Z m Z d e e j f d	 „  ƒ  YZ d S(
   s   
Serial Port Protocol
iÿÿÿÿN(   t   PARITY_NONEt   PARITY_EVENt
   PARITY_ODD(   t   STOPBITS_ONEt   STOPBITS_TWO(   t   FIVEBITSt   SIXBITSt	   SEVENBITSt	   EIGHTBITS(   t   BaseSerialPort(   t   abstractt   fdesct   maint
   SerialPortc           B   sV   e  Z d  Z d Z d e e e d d d d „ Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   s>   
    A select()able serial device, acting as a transport.
    i   i€%  i    c         C   s“   t  j j |  | ƒ t j | d | d | d | d | d | d |	 d |
 ƒ|  _ | |  _ |  j ƒ  |  j ƒ  | |  _	 |  j	 j
 |  ƒ |  j ƒ  d  S(   Nt   baudratet   bytesizet   parityt   stopbitst   timeoutt   xonxofft   rtscts(   R
   t   FileDescriptort   __init__t   serialt   Serialt   _serialt   reactort
   flushInputt   flushOutputt   protocolt   makeConnectiont   startReading(   t   selfR   t   deviceNameOrPortNumberR   R   R   R   R   R   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyR      s    <	

	c         C   s
   |  j  j S(   N(   R   t   fd(   R    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyt   fileno+   s    c         C   s   t  j |  j ƒ  | ƒ S(   s7   
        Write some data to the serial device.
        (   R   t	   writeToFDR#   (   R    t   data(    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyt   writeSomeData.   s    c         C   s   t  j |  j ƒ  |  j j ƒ S(   s:   
        Some data's readable from serial device.
        (   R   t
   readFromFDR#   R   t   dataReceived(   R    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyt   doRead4   s    c         C   s$   t  j j |  | ƒ |  j j ƒ  d  S(   N(   R
   R   t   connectionLostR   t   close(   R    t   reason(    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyR*   :   s    (   t   __name__t
   __module__t   __doc__t	   connectedR   R    R   R   R#   R&   R)   R*   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyR      s   	
			(   R/   t   ost   errnoR   R    R   R   R   R   R   R   R   R   t
   serialportR	   t   twisted.internetR
   R   R   R   R   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/internet/_posixserialport.pyt   <module>   s   "