+
    a_)                        ^ RI Ht ^ RIt^ RIt^ RIt ^ RIt ^ RI	t	^ RIHtHtHtHtHtHt R]P$                  R]P&                  R]P(                  R]P*                  /t ! R R	]4      t]R
8X  d   ^ RIt]! R4      t]P6                  P9                  RP;                  ]4      4       ]P6                  P9                  R4       ]P9                  R4       ]P=                  4        ]P6                  P9                  RP;                  ]P?                  ^4      4      4       ]PA                  4        R# R#   ] d    ^ RIHt  EL(i ; i  ] d	    ^ RI
t	 EL5i ; i)    )absolute_importN)
SerialBaseSerialExceptionto_bytes	iterbytesSerialTimeoutExceptionPortNotOpenErrordebuginfowarningerrorc                      a a ] tR t^)t oRtRtV 3R ltR tV 3R ltR t	R t
]R 4       tRR ltR	 tR
 tR tR tR t]R 4       tR tR tR t]R 4       t]R 4       t]R 4       t]R 4       tRtVtV ;t# )SerialzSSerial port implementation that simulates a loop back connection in plain software.c                h   < R V n         RV n        RV n        RV n        \        \
        V `  ! V/ VB  R# )i   NF)buffer_sizequeuelogger_cancel_writesuperr   __init__)selfargskwargs	__class__s   &*,A/usr/lib/python3/dist-packages/serial/urlhandler/protocol_loop.pyr   Serial.__init__/   s5    
"fd$d5f5    c                   V P                   '       d   \        R4      hRV n        \        P                  ! V P
                  4      V n        V P                  f   \        R4      hV P                  V P                  4       V P                  4        RV n         V P                  '       g   V P                  4        V P                  '       g   V P                  4        V P                  4        V P                  4        R# )z`Open port with current settings. This may throw a SerialException
if the port cannot be opened.
zPort is already open.Nz.Port must be configured before it can be used.T)is_openr   r   r   Queuer   _portfrom_urlport_reconfigure_port_dsrdtr_update_dtr_state_rtscts_update_rts_statereset_input_bufferreset_output_bufferr   s   &r   openSerial.open6   s    
 <<<!"9::[[!1!12
::!"RSS 	dii  	 |||""$|||""$!  "r   c                   < V P                   '       d$   R V n          V P                  P                  R4       \        \
        V `  4        R#   \        P                   d     L+i ; i)FN)r   r   
put_nowaitFullr   r   close)r   r   s   &r   r1   Serial.closeQ   sQ    <<< DL

%%d+ 	fd!# :: s   A A#"A#c                6   \        V P                  \        P                  4      '       d   ^ V P                  u;8  d   R8  g'   M \	        RP                  V P                  4      4      hV P                  '       d   V P                  P                  R4       R# R# )z`Set communication parameters on opened port. For the loop://
protocol all settings are ignored!
zinvalid baudrate: {!r}z_reconfigure_port()Nl        )
isinstance	_baudratenumbersIntegral
ValueErrorformatr   r   r+   s   &r   r$   Serial._reconfigure_portZ   sh     $..'*:*:;;1t~~C_X_C_5<<T^^LMM;;;KK23 r   c                   \         P                  ! V4      pVP                  R8w  d%   \        RP	                  VP                  4      4      h \         P
                  ! VP                  R4      P                  4        F  w  r4VR8X  d{   \        P                  ! 4        \        P                  ! R4      V n        V P                  P                  \        V^ ,          ,          4       V P                  P                  R4       K  \        RP	                  V4      4      h	  R	#   \         d    p\        RP	                  T4      4      hR	p?ii ; i)
z(extract host and port from an URL stringloopznexpected a string in the form "loop://[?logging={debug|info|warning|error}]": not starting with loop:// ({!r})TloggingzpySerial.loopzenabled loggingzunknown option: {!r}zPexpected a string in the form "loop://[?logging={debug|info|warning|error}]": {}N)urlparseurlsplitschemer   r9   parse_qsqueryitemsr=   basicConfig	getLoggerr   setLevelLOGGER_LEVELSr
   r8   )r   urlpartsoptionvalueses   &&    r   r"   Serial.from_urle   s   !!#&<<6!!&&,fU\\&:< <	P"*"3"3EKK"F"L"L"NY&'')")"3"3O"DDKKK((vay)ABKK%%&78$%;%B%B6%JKK #O  	P!EEKVAYP P	Ps   CD   E
+EE
c                   V P                   '       g   \        4       hV P                  '       dC   V P                  P                  RP	                  V P
                  P                  4       4      4       V P
                  P                  4       # )z9Return the number of bytes currently in the input buffer.zin_waiting -> {:d}r   r	   r   r
   r9   r   qsizer+   s   &r   
in_waitingSerial.in_waiting~   s_     |||"$$;;; KK299$**:J:J:LMNzz!!r   c                   V P                   '       g   \        4       hV P                  e9   V P                  ^ 8w  d(   \        P                  ! 4       V P                  ,           pMRp\	        4       pV^ 8  d   V P                   '       d    V P
                  P                  V P                  R7      pVe   W4,          pV^,          pMMTV'       g   Ka  \        P                  ! 4       V8  g   K}  V P                  '       d   V P                  P                  R4        \        V4      #   \
        P                   d    T P                  ^ 8X  d    K4   Li ; i)zRead size bytes from the serial port. If a timeout is set it may
return less characters as requested. With no timeout it will block
until the requested number of bytes is read.
Ntimeoutzread timeout)r   r	   _timeouttime	bytearrayr   getEmptyr   r   bytes)r   sizerU   databs   &&   r   readSerial.read   s     |||"$$==$!);iikDMM1GG{Qh4<<<
JJNN4==N9
 =IDAID w499;0;;;KK$$^4T{ ;; ==A% &s   	&D% %&EEc                <    V P                   P                  R 4       R # )N)r   r/   r+   s   &r   cancel_readSerial.cancel_read   s    

d#r   c                    R V n         R# )TN)r   r+   s   &r   cancel_writeSerial.cancel_write   s
    !r   c                D   RV n         V P                  '       g   \        4       h\        V4      pR\	        V4      ,          V P
                  ,          pV P                  e   W P                  8  dp   V P                  pV^ 8  d>   V P                   '       g,   \        P                  ! \        VR4      4       VR,          pKD  V P                   '       d   ^ # \        R4      h\        V4       F)  pV P                  P                  W@P                  R7       K+  	  \	        V4      # )zOutput the given byte string over the serial port. Can block if the
connection is blocked. May raise SerialException if the connection is
closed.
Fg      $@g      ?zWrite timeoutrT   )r   r   r	   r   lenr5   _write_timeoutrW   sleepminr   r   r   put)r   r]   time_used_to_send	time_leftbytes   &&   r   writeSerial.write   s     #|||"$$~ 3t9,t~~= */@CVCV/V++Ia-(:(:(:

3y#./S 	!!!(99dODJJNN4)<)<N= $4yr   c                J   V P                   '       g   \        4       hV P                  '       d   V P                  P                  R4        V P                  P                  4       '       d   V P                  P                  4        K<  R#   \        P                   d     R# i ; i)z9Clear input buffer, discarding all that is in the buffer.zreset_input_buffer()Nr   r	   r   r   r   rP   
get_nowaitrZ   r+   s   &r   r)   Serial.reset_input_buffer   ss    |||"$$;;;KK34	**""$$

%%' %{{ 		   B	 +B	 	B"!B"c                J   V P                   '       g   \        4       hV P                  '       d   V P                  P                  R4        V P                  P                  4       '       d   V P                  P                  4        K<  R#   \        P                   d     R# i ; i)z[Clear output buffer, aborting the current output and
discarding all that is in the buffer.
zreset_output_buffer()Nrs   r+   s   &r   r*   Serial.reset_output_buffer   su    
 |||"$$;;;KK45	**""$$

%%' %{{ 		rv   c                   V P                   '       g   \        4       hV P                  '       dC   V P                  P                  RP	                  V P
                  P                  4       4      4       V P
                  P                  4       # )z0Return how many bytes the in the outgoing bufferzout_waiting -> {:d}rO   r+   s   &r   out_waitingSerial.out_waiting   s_     |||"$$;;; KK3::4::;K;K;MNOzz!!r   c                    V P                   '       d7   V P                   P                  RP                  V P                  4      4       R# R# )zCSet break: Controls TXD. When active, to transmitting is
possible.
z_update_break_state({!r})N)r   r   r9   _break_stater+   s   &r   _update_break_stateSerial._update_break_state   s6    
 ;;;KK8??@Q@QRS r   c                    V P                   '       d7   V P                   P                  RP                  V P                  4      4       R# R# )z)Set terminal status line: Request To Sendz'_update_rts_state({!r}) -> state of CTSN)r   r   r9   
_rts_stater+   s   &r   r(   Serial._update_rts_state   2    ;;;KKFMMdoo^_ r   c                    V P                   '       d7   V P                   P                  RP                  V P                  4      4       R# R# )z-Set terminal status line: Data Terminal Readyz'_update_dtr_state({!r}) -> state of DSRNr   r   r9   
_dtr_stater+   s   &r   r&   Serial._update_dtr_state   r   r   c                    V P                   '       g   \        4       hV P                  '       d5   V P                  P                  RP	                  V P
                  4      4       V P
                  # )z(Read terminal status line: Clear To SendzCTS -> state of RTS ({!r}))r   r	   r   r   r9   r   r+   s   &r   cts
Serial.cts  sK     |||"$$;;;KK9@@QRr   c                    V P                   '       d5   V P                   P                  RP                  V P                  4      4       V P                  # )z)Read terminal status line: Data Set ReadyzDSR -> state of DTR ({!r})r   r+   s   &r   dsr
Serial.dsr  s9     ;;;KK9@@QRr   c                    V P                   '       g   \        4       hV P                  '       d   V P                  P                  R4       R# )z)Read terminal status line: Ring Indicatorzreturning dummy for RIFr   r	   r   r   r+   s   &r   ri	Serial.ri  s5     |||"$$;;;KK56r   c                    V P                   '       g   \        4       hV P                  '       d   V P                  P                  R4       R# )z)Read terminal status line: Carrier Detectzreturning dummy for CDTr   r+   s   &r   cd	Serial.cd  s5     |||"$$;;;KK56r   )r   r   r   r   r   )2   K   n            i,  iX  i  i  i`	  i  i%  i K  i   i   i  )   )__name__
__module____qualname____firstlineno____doc__	BAUDRATESr   r,   r1   r$   r"   propertyrQ   r_   rb   re   rp   r)   r*   rz   r~   r(   r&   r   r   r   r   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r   r   )   s     ]4I6#6$	4P2 " "B$"6
 " "T`
`
         r   r   __main__zloop://z{}
z	write...
zhello
zread: {!r}
)!
__future__r   r=   r6   rW   r>   ImportErrorurllib.parseparser   r    serial.serialutilr   r   r   r   r   r	   DEBUGINFOWARNINGERRORrG   r   r   syssstdoutrp   r9   flushr_   r1    r   r   <module>r      s    '   $ y x W]]
GLLwW]]	zZ zB zyAJJV]]1%&JJ\"GGIGGIJJ^**166!956GGI g  $##$  s"   D0 E 0E EEE