�
ʦ^_\! � �� � d dl Z d dlZ d dlZn# e$ r d dlmZ Y nw xY w d dlZn# e$ r d dlZY nw xY wd dlZd dl Z d dl
mZmZm
Z
mZmZ dZd ZdZdZdZdZdZdZd Z G d
� de� � ZdS )� N)�
SerialBase�SerialException�PortNotOpenError�to_bytes�Timeout�A � �C � �P �Q �R c �v � � e Zd ZdZ� fd�Zd� Zd� Zd� Zd� Ze d� � � Z
d� Zd � Zd
� Z
dd�Zd
� Zd� Z� xZS )�Serial)i, iw iX i� i i` i� i�% i K i � i � i � i � i i � i � i i@B c �r �� d | _ d | _ d | _ t t | � � j |i |�� d S �N)�_hid_handle�_read_buffer�_thread�superr �__init__)�self�args�kwargs� __class__s ��C/usr/lib/python3/dist-packages/serial/urlhandler/protocol_cp2110.pyr zSerial.__init__E sB �� ���� ������$��f�d���$�d�5�f�5�5�5�5�5� c �H � | j �t d� � �| j rt d� � �t j � � | _ t j � � | _ | � | j � � }| j �
|� � n@# t $ r3}t |j d�
| j |� � � � �d }~ww xY w | � � � d| _ t j | j �� � | _ | j � d� � | j � d�
| j � � � � | j � � � d S # | j � � � n# Y nxY wd | _ � xY w)Nz.Port must be configured before it can be used.zPort is already open.zcould not open port {}: {}T)�targetz$pySerial CP2110 reader thread for {})�_portr �is_open�Queuer �hid�devicer �from_url�portstr� open_path�OSError�errno�format�_reconfigure_port� threading�Thread�_hid_read_loopr � setDaemon�setName�start�close)r �portpath�msgs r �openzSerial.openK s� � ��:��!�"R�S�S�S��<� ;�!�"9�:�:�:�!�K�M�M����:�<�<��� c��}�}�T�\�2�2�H���&�&�x�0�0�0�0��� c� c� c�!�#�)�-I�-P�-P�QU�Q[�]`�-a�-a�b�b�b����� c���� !��"�"�$�$�$� �D�L�$�+�4�3F�G�G�G�D�L��L�"�"�4�(�(�(��L� � �!G�!N�!N�t�z�!Z�!Z�[�[�[��L��� � � � � �� �
�� �&�&�(�(�(�(��
������#�D�����s< |