3 M]W% @ s" d dl Z d dlZd dlZyd dlZW n ek rB d dljZY nX yd dlZW n ek rl d dlZY nX d dl m Z mZmZm Z mZmZ e je je je jdZG dd de Zedkrd dlZedZejjdje ejjd ejd ej ejjdjejd ej dS ) N) SerialBaseSerialExceptionto_bytes iterbyteswriteTimeoutErrorportNotOpenError)debuginfoZwarningerrorc s e Zd ZdZd6Z fddZdd Z fddZdd Zdd Z e dd Zd7d d!Zd"d# Z d$d% Zd&d' Zd(d) Zd*d+ Zd,d- Ze d.d/ Ze d0d1 Ze d2d3 Ze d4d5 Z ZS )8SerialzSSerial port implementation that simulates a loop back connection in plain software.2 K n , X ` % K c s( t t| j|| d| _d | _d | _d S )Ni )superr __init__buffer_sizequeuelogger)selfargskwargs) __class__ #/usr/lib/python3.6/protocol_loop.pyr - s zSerial.__init__c C s~ | j rtdd| _tj| j| _| jdkr4td| j| j | j d| _ | j s\| j | jsj| j | j | j dS )zx Open port with current settings. This may throw a SerialException if the port cannot be opened. zPort is already open.Nz.Port must be configured before it can be used.T)is_openr r! r Queuer Z_portfrom_urlZport_reconfigure_portZ_dsrdtr_update_dtr_stateZ_rtscts_update_rts_statereset_input_bufferreset_output_buffer)r" r&