Prv8 Shell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/python3.6/site-packages/serial/urlhandler/__pycache__/protocol_loop.cpython-36.pyc
3

F�Kd)�@s.ddlmZddlZddlZddlZyddlZWnek
rNddljZYnXyddl	Z	Wnek
rxddl
Z	YnXddlmZm
Z
mZmZmZmZejejejejd�ZGdd�de�Zedk�r*ddlZed�Zejjd	je��ejjd
�ejd�ej�ejjdjejd
���ej �dS)�)�absolute_importN)�
SerialBase�SerialException�to_bytes�	iterbytes�SerialTimeoutException�PortNotOpenError)�debug�info�warning�errorcs�eZdZdZd<Z�fdd�Zdd�Z�fdd�Zdd�Zdd�Z	e
dd��Zd=d d!�Zd"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������cs.d|_d|_d|_d|_tt|�j||�dS)NiF)�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__cCs~|jrtd��d|_tj|j�|_|jdkr4td��|j|j�|j	�d|_|j
s\|j�|jsj|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_openrr!r �QueuerZ_port�from_url�port�_reconfigure_portZ_dsrdtr�_update_dtr_stateZ_rtscts�_update_rts_state�reset_input_buffer�reset_output_buffer)r%r)r)r*�open6s
zSerial.opencsF|jr4d|_y|jjd�Wntjk
r2YnXtt|�j�dS)NF)r+r �
put_nowait�Fullr#r
�close)r%)r(r)r*r7QszSerial.closecCsRt|jtj�s,d|jko$dkn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/Zs,zSerial._reconfigure_portcCs�tj|�}|jdkr$tdj|j���ypxjtj|jd�j�D]T\}}|dkr�tj	�tj
d�|_|jjt
|d�|jjd�q:tdj|���q:WWn0tk
r�}ztd	j|���WYd
d
}~XnXd
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.looprzenabled loggingzunknown option: {!r}zPexpected a string in the form "loop://[?logging={debug|info|warning|error}]": {}N)�urlparse�urlsplit�schemerr?�parse_qs�query�itemsr@�basicConfig�	getLoggerr!�setLevel�
LOGGER_LEVELSr	r>)r%�url�parts�option�values�er)r)r*r-es"


zSerial.from_urlcCs4|jst��|jr*|jjdj|jj���|jj�S)z9Return the number of bytes currently in the input buffer.zin_waiting -> {:d})r+rr!r	r?r �qsize)r%r)r)r*�
in_waiting~s
zSerial.in_waiting�cCs�|jst��|jdk	r0|jdkr0tj�|j}nd}t�}x�|dkr�|jr�y|jj|jd�}Wn"tjk
r�|jdkr|PYnX|dk	r�||7}|d8}nP|r<tj�|kr<|jr�|jj	d�Pq<Wt
|�S)z�        Read size bytes from the serial port. If a timeout is set it may
        return less characters as requested. With no timeout it will block
        until the requested number of bytes is read.
        Nr)�timeoutrRzread timeout)r+r�_timeout�time�	bytearrayr �get�Emptyr!r
�bytes)r%�sizerS�data�br)r)r*�read�s*

zSerial.readcCs|jjd�dS)N)r r5)r%r)r)r*�cancel_read�szSerial.cancel_readcCs
d|_dS)NT)r")r%r)r)r*�cancel_write�szSerial.cancel_writecCs�d|_|jst��t|�}dt|�|j}|jdk	r�||jkr�|j}x,|dkrr|jrrtjt	|d��|d8}qHW|jr~dSt
d��x"t|�D]}|jj
||jd�q�Wt|�S)z�        Output the given byte string over the serial port. Can block if the
        connection is blocked. May raise SerialException if the connection is
        closed.
        Fg$@Nrg�?z
Write timeout)rS)r"r+rr�lenr;Z_write_timeoutrU�sleep�minrrr �put)r%r[Ztime_used_to_sendZ	time_leftZbyter)r)r*�write�s zSerial.writecCsX|jst��|jr|jjd�yx|jj�r8|jj�q"WWntjk
rRYnXdS)z9Clear input buffer, discarding all that is in the buffer.zreset_input_buffer()N)r+rr!r
r rP�
get_nowaitrX)r%r)r)r*r2�szSerial.reset_input_buffercCsX|jst��|jr|jjd�yx|jj�r8|jj�q"WWntjk
rRYnXdS)zs        Clear output buffer, aborting the current output and
        discarding all that is in the buffer.
        zreset_output_buffer()N)r+rr!r
r rPrerX)r%r)r)r*r3�szSerial.reset_output_buffercCs4|jst��|jr*|jjdj|jj���|jj�S)z0Return how many bytes the in the outgoing bufferzout_waiting -> {:d})r+rr!r	r?r rP)r%r)r)r*�out_waiting�s
zSerial.out_waitingcCs|jr|jjdj|j��dS)z[        Set break: Controls TXD. When active, to transmitting is
        possible.
        z_update_break_state({!r})N)r!r
r?Z_break_state)r%r)r)r*�_update_break_state�szSerial._update_break_statecCs|jr|jjdj|j��dS)z)Set terminal status line: Request To Sendz'_update_rts_state({!r}) -> state of CTSN)r!r
r?�
_rts_state)r%r)r)r*r1�szSerial._update_rts_statecCs|jr|jjdj|j��dS)z-Set terminal status line: Data Terminal Readyz'_update_dtr_state({!r}) -> state of DSRN)r!r
r?�
_dtr_state)r%r)r)r*r0�szSerial._update_dtr_statecCs,|jst��|jr&|jjdj|j��|jS)z(Read terminal status line: Clear To SendzCTS -> state of RTS ({!r}))r+rr!r
r?rh)r%r)r)r*�ctss
z
Serial.ctscCs |jr|jjdj|j��|jS)z)Read terminal status line: Data Set ReadyzDSR -> state of DTR ({!r}))r!r
r?ri)r%r)r)r*�dsrsz
Serial.dsrcCs"|jst��|jr|jjd�dS)z)Read terminal status line: Ring Indicatorzreturning dummy for RIF)r+rr!r
)r%r)r)r*�ris
z	Serial.ricCs"|jst��|jr|jjd�dS)z)Read terminal status line: Carrier Detectzreturning dummy for CDT)r+rr!r
)r%r)r)r*�cds
z	Serial.cd)rrrrrrrrrrrrrrrrr)rR)�__name__�
__module__�__qualname__�__doc__Z	BAUDRATESr$r4r7r/r-�propertyrQr]r^r_rdr2r3rfrgr1r0rjrkrlrm�
__classcell__r)r))r(r*r
)s.	
!		r
�__main__zloop://z{}
z	write...
zhello
zread: {!r}
�)!�
__future__rr@r<rUrA�ImportError�urllib.parse�parser r,Zserial.serialutilrrrrrr�DEBUG�INFO�WARNING�ERRORrJr
rn�sys�s�stdoutrdr?�flushr]r7r)r)r)r*�<module>s8 




haha - 2025