|
Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /usr/local/lib/python3.6/site-packages/serial/urlhandler/__pycache__/ |
Upload File : |
3
F�Kd) � @ s. d dl mZ d dlZd dlZd dlZyd dlZW n ek
rN d dljZY nX yd dl Z W n ek
rx d dl
Z Y nX d dlmZm
Z
mZmZmZmZ ejejejejd�ZG dd� de�Zedk�r*d dlZed�Zejjd je�� ejjd
� ejd� ej� ejjdjejd
��� ej � dS )� )�absolute_importN)�
SerialBase�SerialException�to_bytes� iterbytes�SerialTimeoutException�PortNotOpenError)�debug�info�warning�errorc s� e Zd ZdZd<Z� fdd�Zdd� Z� fdd�Zdd� Zdd� Z e
dd� �Zd=d d!�Zd"d#� Z
d$d%� Zd&d'� Zd(d)� Zd*d+� Ze
d,d-� �Zd.d/� Zd0d1� Zd2d3� Ze
d4d5� �Ze
d6d7� �Ze
d8d9� �Ze
d:d;� �Z� ZS )>�SerialzSSerial port implementation that simulates a loop back connection in plain software.�2 �K �n � � �� �, �X � � �` � �% � K � � � � � � c s. d| _ d | _d | _d| _tt| �j||� d S )Ni F)�buffer_size�queue�logger�
_cancel_write�superr
�__init__)�self�args�kwargs)� __class__� �C/tmp/pip-build-8nxjc3nm/pyserial/serial/urlhandler/protocol_loop.pyr$ / s
zSerial.__init__c C s~ | j rtd��d| _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_port�from_url�port�_reconfigure_portZ_dsrdtr�_update_dtr_stateZ_rtscts�_update_rts_state�reset_input_buffer�reset_output_buffer)r% r) r) r* �open6 s
zSerial.openc sF | j r4d| _ y| jjd � W n tjk
r2 Y nX tt| �j� d S )NF)r+ r �
put_nowait�Fullr# r
�close)r% )r( r) r* r7 Q s zSerial.closec C sR t | jtj� s,d| j k o$dk n r<tdj| j���| jrN| jjd� dS )zx Set communication parameters on opened port. For the loop://
protocol all settings are ignored!
r � � zinvalid baudrate: {!r}z_reconfigure_port()Nl )�
isinstance� _baudrate�numbers�Integral�
ValueError�formatr! r
)r% r) r) r* r/ Z s ,zSerial._reconfigure_portc C s� t j|�}|jdkr$tdj|j���ypxjt j|jd�j� D ]T\}}|dkr�tj � tj
d�| _| jjt
|d � | jjd� q:tdj|���q:W W n0 tk
r� } ztd j|���W Y d
d
}~X nX d
S )z(extract host and port from an URL stringZloopznexpected a string in the form "loop://[?logging={debug|info|warning|error}]": not starting with loop:// ({!r})T�loggingz
pySerial.loopr zenabled loggingzunknown option: {!r}zPexpected a string in the form "loop://[?logging={debug|info|warning|error}]": {}N)�urlparse�urlsplit�schemer r? �parse_qs�query�itemsr@ �basicConfig� getLoggerr! �setLevel�
LOGGER_LEVELSr r>