CasperSecurity

Current Path : /lib/python3/dist-packages/serial/urlhandler/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_loop.cpython-310.pyc

o

��a_)�@s.ddlmZddlZddlZddlZzddlZWney'ddlmZYnwzddl	Z	Wn
ey;ddl
Z	YnwddlmZm
Z
mZmZmZmZejejejejd�ZGdd�de�Zedkr�ddlZed�Zej�d	�e��ej�d
�e�d�e��ej�d�e�d
���e� �dSdS)�)�absolute_importN)�
SerialBase�SerialException�to_bytes�	iterbytes�SerialTimeoutException�PortNotOpenError)�debug�info�warning�errorcs�eZdZdZdZ�fdd�Zdd�Z�fdd�Zd	d
�Zdd�Z	e
d
d��Zd,dd�Zdd�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,iXi�ii`	i�i�%iKi�i�i�cs2d|_d|_d|_d|_tt|�j|i|��dS)NiF)�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__cCs~|jrtd��d|_t�|j�|_|jdurtd��|�|j�|�	�d|_|j
s.|��|js5|�
�|��|��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_openrrr�Queuer�_port�from_url�port�_reconfigure_port�_dsrdtr�_update_dtr_state�_rtscts�_update_rts_state�reset_input_buffer�reset_output_buffer�rrrr �open6s
zSerial.opencsD|jrd|_z|j�d�Wn
tjyYnwtt|���dS)NF)r!r�
put_nowait�Fullrr
�closer-rrr r1Qs�zSerial.closecCsPt|jtj�rd|jkrdksntd�|j���|jr&|j�d�dSdS)zx        Set communication parameters on opened port. For the loop://
        protocol all settings are ignored!
        rlzinvalid baudrate: {!r}z_reconfigure_port()N)�
isinstance�	_baudrate�numbers�Integral�
ValueError�formatrr
r-rrr r&Zs
&�zSerial._reconfigure_portc
Cs�t�|�}|jdkrtd�|j���z6t�|jd���D])\}}|dkr?t�	�t�
d�|_|j�t
|d�|j�d�qtd�|���Wd
Sty[}ztd	�|���d
}~ww)z(extract host and port from an URL string�loopznexpected 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�schemerr7�parse_qs�query�itemsr9�basicConfig�	getLoggerr�setLevel�
LOGGER_LEVELSr	r6)r�url�parts�option�values�errr r$es,

�����zSerial.from_urlcC�4|jst��|jr|j�d�|j����|j��S)z9Return the number of bytes currently in the input buffer.zin_waiting -> {:d}�r!rrr	r7r�qsizer-rrr �
in_waiting~�

zSerial.in_waiting�cCs�|jst��|jdur|jdkrt��|j}nd}t�}|dkrr|jrrz
|jj|jd�}WntjyB|jdkr@Yt
|�SYnw|durP||7}|d8}n	t
|�S|rkt��|krk|jrf|j�	d�	t
|�S|dkrr|js$t
|�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��timeoutrNzread timeout)r!r�_timeout�time�	bytearrayr�get�Emptyrr
�bytes)r�sizerP�data�brrr �read�s6

��
��zSerial.readcCs|j�d�dS)N)rr/r-rrr �cancel_read�szSerial.cancel_readcCs
d|_dS)NT)rr-rrr �cancel_write�s
zSerial.cancel_writecCs�d|_|js	t��t|�}dt|�|j}|jdurF||jkrF|j}|dkr=|js=t�t	|d��|d8}|dkr=|jr*|jrBdSt
d��t|�D]}|jj
||jd�qJt|�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 timeoutrO)rr!rr�lenr3�_write_timeoutrR�sleep�minrrr�put)rrX�time_used_to_send�	time_left�byterrr �write�s"�zSerial.writecC�`|jst��|jr|j�d�z|j��r"|j��|j��sWdSWdStjy/YdSw)z9Clear input buffer, discarding all that is in the buffer.zreset_input_buffer()N�r!rrr
rrK�
get_nowaitrUr-rrr r+�s

��zSerial.reset_input_buffercCrf)zs        Clear output buffer, aborting the current output and
        discarding all that is in the buffer.
        zreset_output_buffer()Nrgr-rrr r,�s

��zSerial.reset_output_buffercCrI)z0Return how many bytes the in the outgoing bufferzout_waiting -> {:d}rJr-rrr �out_waiting�rMzSerial.out_waitingcC�"|jr|j�d�|j��dSdS)z[        Set break: Controls TXD. When active, to transmitting is
        possible.
        z_update_break_state({!r})N)rr
r7�_break_stater-rrr �_update_break_state�s�zSerial._update_break_statecCrj)z)Set terminal status line: Request To Sendz'_update_rts_state({!r}) -> state of CTSN)rr
r7�
_rts_stater-rrr r*���zSerial._update_rts_statecCrj)z-Set terminal status line: Data Terminal Readyz'_update_dtr_state({!r}) -> state of DSRN�rr
r7�
_dtr_stater-rrr r(�rnzSerial._update_dtr_statecCs,|jst��|jr|j�d�|j��|jS)z(Read terminal status line: Clear To SendzCTS -> state of RTS ({!r}))r!rrr
r7rmr-rrr �ctss
z
Serial.ctscCs |jr
|j�d�|j��|jS)z)Read terminal status line: Data Set ReadyzDSR -> state of DTR ({!r})ror-rrr �dsrsz
Serial.dsrcC�"|jst��|jr|j�d�dS)z)Read terminal status line: Ring Indicatorzreturning dummy for RIF�r!rrr
r-rrr �ri�
z	Serial.ricCrs)z)Read terminal status line: Carrier Detectzreturning dummy for CDTrtr-rrr �cdrvz	Serial.cd)rN)�__name__�
__module__�__qualname__�__doc__�	BAUDRATESrr.r1r&r$�propertyrLrZr[r\rer+r,rirlr*r(rqrrrurw�
__classcell__rrrr r
)s:	


!




r
�__main__zloop://z{}
z	write...
zhello
zread: {!r}
�)!�
__future__rr9r4rRr:�ImportError�urllib.parse�parserr"�serial.serialutilrrrrrr�DEBUG�INFO�WARNING�ERRORrCr
rx�sys�s�stdoutrer7�flushrZr1rrrr �<module>sB�� �
�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY