File: //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_loop.cpython-310.pyc
o
��a_) � @ s. d dl mZ d dlZd dlZd dlZzd dlZW n ey' d dlmZ Y nw zd dl Z W n
ey; d dl
Z Y nw d dlmZm
Z
mZmZmZmZ ejejejejd�ZG dd� de�Zedkr�d dlZed�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 s� e Zd ZdZdZ� fdd�Zdd� Z� fdd�Zd d
� Zdd� Z e
d
d� �Zd,dd�Zdd� Z
dd� Zdd� Zdd� Zdd� Ze
dd� �Zdd� Zd d!� Zd"d#� Ze
d$d%� �Ze
d&d'� �Ze
d(d)� �Ze
d*d+� �Z� ZS )-�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 s2 d| _ d | _d | _d| _tt| �j|i |�� d S )Ni F)�buffer_size�queue�logger�
_cancel_write�superr
�__init__)�self�args�kwargs�� __class__� �A/usr/lib/python3/dist-packages/serial/urlhandler/protocol_loop.pyr / s
zSerial.__init__c C s~ | j rtd��d| _t�| j�| _| jdu rtd��| �| j� | � � d| _ | j
s.| �� | js5| �
� | �� | �� 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 r r r �open6 s
zSerial.openc sD | j rd| _ z| j�d � W n
tjy Y nw tt| ��� d S )NF)r! r �
put_nowait�Fullr r
�closer- r r r r1 Q s �zSerial.closec C sP t | jtj�rd| j k rdk sn td�| j���| jr&| j�d� dS dS )zx Set communication parameters on opened port. For the loop://
protocol all settings are ignored!
r l zinvalid baudrate: {!r}z_reconfigure_port()N)�
isinstance� _baudrate�numbers�Integral�
ValueError�formatr r
r- r r r r&