File: //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_socket.cpython-310.pyc
o
Ȧ^_�7 � @ s d dl mZ d dlZd dlZd dlZd dlZd dlZzd dlZW n ey/ d dl m
Z Y nw d dlmZm
Z
mZmZmZmZ ejejejejd�ZdZG 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�PortNotOpenError�SerialTimeoutException�Timeout)�debug�info�warning�error� c @ s� e Zd ZdZdZdd� Zdd� Zdd� Zd d
� Ze dd� �Z
d*dd�Zdd� Zdd� Z
dd� Zd+dd�Zdd� Zdd� Zdd� Ze dd � �Ze d!d"� �Ze d#d$� �Ze d%d&� �Zd'd(� Zd)S ),�Serialz-Serial port implementation for plain sockets.)�2 �K �n � � �� i, iX i� i i` i� i�% i K i � i � i � c
C s� d| _ | jdu rtd��| jrtd��ztj| �| j�td�| _ W n t
y9 } zd| _ td�| j|���d}~ww | j �d� | �
� d| _| jsN| �� | jsU| �� | �� | �� dS )zx Open port with current settings. This may throw a SerialException
if the port cannot be opened.
Nz.Port must be configured before it can be used.zPort is already open.)�timeoutzCould not open port {}: {}FT)�logger�_portr �is_open�socket�create_connection�from_url�portstr�POLL_TIMEOUT�_socket� Exception�format�setblocking�_reconfigure_port�_dsrdtr�_update_dtr_state�_rtscts�_update_rts_state�reset_input_buffer�reset_output_buffer)�self�msg� r+ �C/usr/lib/python3/dist-packages/serial/urlhandler/protocol_socket.py�open3 s*
��zSerial.openc C s, | j du r td��| jr| j�d� dS dS )zz Set communication parameters on opened port. For the socket://
protocol all settings are ignored!
NzCan only operate on open portsz!ignored port configuration change)r r r r
�r) r+ r+ r, r"