�
��a_) � � � d dl mZ d dlZd dlZd dlZ d dlZn# e$ r d dlmZ Y nw xY w d dl Z n# e$ r d dl
Z Y nw xY wd dlmZm
Z
mZmZmZmZ ej ej ej ej d�Z G d� de� � Zedk r�d dlZ ed� � Zej � d � e� � � � ej � d
� � e� d� � e� � � ej � d� e� d
� � � � � � e� � � dS dS )� )�absolute_importN)�
SerialBase�SerialException�to_bytes� iterbytes�SerialTimeoutException�PortNotOpenError)�debug�info�warning�errorc � � � e Zd ZdZdZ� fd�Zd� Z� fd�Zd� Zd� Z e
d� � � Zdd
�Zd� Z
d� Zd
� Zd� Zd� Ze
d� � � Zd� Zd� Zd� Ze
d� � � Ze
d� � � Ze
d� � � Ze
d� � � Z� xZS )�SerialzSSerial port implementation that simulates a loop back connection in plain software.)�2 �K �n � � �� i, iX i� i i` i� i�% i K i � i � i � c � �� d| _ d | _ d | _ d| _ t t
| � � j |i |�� d S )Ni F)�buffer_size�queue�logger�
_cancel_write�superr �__init__)�self�args�kwargs� __class__s ��A/usr/lib/python3/dist-packages/serial/urlhandler/protocol_loop.pyr zSerial.__init__/ sI �� ������
����"���$��f�d���$�d�5�f�5�5�5�5�5� c �� � | j rt d� � �d| _ t j | j � � | _ | j �t d� � �| � | j � � | � � � d| _ | j
s| � � � | j s| �
� � | � � � | � � � 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 �_port�from_url�port�_reconfigure_port�_dsrdtr�_update_dtr_state�_rtscts�_update_rts_state�reset_input_buffer�reset_output_buffer�r s r! �openzSerial.open6 s� � �
�<� ;�!�"9�:�:�:�����[��!1�2�2��
��:��!�"R�S�S�S�
�
�
�d�i� � � �
��� � � �����|� %��"�"�$�$�$��|� %��"�"�$�$�$����!�!�!�� � �"�"�"�"�"r" |