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_spy.cpython-36.pyc
3

F�Kd�#�@s�ddlmZddlZddlZddlZddlmZyddlZWnek
rZddl	j
ZYnXdd�Zdd�ZGdd	�d	e
�ZGd
d�de
�ZGdd
�d
ej�Zedkr�ed�Zde_ee�dS)�)�absolute_importN)�to_bytesccs�d}xrtj|�D]d}djt|��d|ko2dknrB|jd�ndfV|d7}|dkrbdVq|dkrdVd}qW|dkr�x(|dkr�|d7}|dkr�dVdVq�WdVdS)z�    yield tuples of hex and ASCII display in multiples of 16. Includes a
    space after 8 bytes and (None, None) after 16 bytes and at the end.
    rz{:02X} � ��ascii�.��� ��N�   )r
r)NN)r
r)r
r
)NN)�serial�	iterbytes�format�ord�decode)�data�n�b�r�B/tmp/pip-build-8nxjc3nm/pyserial/serial/urlhandler/protocol_spy.py�sixteen%s 6

rccs�g}g}d}xnt|�D]b\}}|dkrd|djdj|�dj|�g�fV|dd�=|dd�=|d7}q|j|�|j|�qWdS)z yield lines with hexdump of datarNr
rr)r�join�append)r�valuesr�offset�h�arrr�hexdump<s 



rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�	FormatRawz&Forward only RX and TX data to output.cCs||_||_d|_d|_dS)Nzz)�output�color�rx_color�tx_color)�selfr!r"rrr�__init__OszFormatRaw.__init__cCs.|jr|jj|j�|jj|�|jj�dS)zshow received dataN)r"r!�writer#�flush)r%rrrr�rxUszFormatRaw.rxcCs.|jr|jj|j�|jj|�|jj�dS)zshow transmitted dataN)r"r!r'r$r()r%rrrr�tx\szFormatRaw.txcCsdS)z(do not) show control callsNr)r%�name�valuerrr�controlcszFormatRaw.controlN)�__name__�
__module__�__qualname__�__doc__r&r)r*r-rrrrr Ls
r c@s:eZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�
FormatHexdumpax    Create a hex dump of RX ad TX data, show when control lines are read or
    written.

    output example::

        000000.000 Q-RX flushInput
        000002.469 RTS  inactive
        000002.773 RTS  active
        000003.001 TX   48 45 4C 4C 4F                                    HELLO
        000003.102 RX   48 45 4C 4C 4F                                    HELLO

    cCs,tj�|_||_||_d|_d|_d|_dS)Nzzz)�time�
start_timer!r"r#r$�
control_color)r%r!r"rrrr&ws
zFormatHexdump.__init__rcCs&|jjdj||||��|jj�dS)Nz{:010.3f} {:4} {}{}
)r!r'rr()r%�	timestamp�labelr,Zvalue2rrr�
write_lineszFormatHexdump.write_linecCsl|jr|jj|j�|rPxNt|�D](\}}|jtj�|jddj|�|�q"Wn|jtj�|jdd�dS)zshow received data as hex dumpZRXz{:04X}  z<empty>N)	r"r!r'r#rr8r3r4r)r%rr�rowrrrr)�s&zFormatHexdump.rxcCsN|jr|jj|j�x4t|�D](\}}|jtj�|jddj|�|�qWdS)z!show transmitted data as hex dumpZTXz{:04X}  N)	r"r!r'r$rr8r3r4r)r%rrr9rrrr*�szFormatHexdump.txcCs0|jr|jj|j�|jtj�|j||�dS)zshow control callsN)r"r!r'r5r8r3r4)r%r+r,rrrr-�szFormatHexdump.controlN)r)	r.r/r0r1r&r8r)r*r-rrrrr2hs


r2csTeZdZdZ�fdd�Zejjjdd��Zdd�Z	�fdd	�Z
d,�fdd�	Zeejd
�rd�fdd�Z
eejd�r|�fdd�Ze�fdd��Z�fdd�Z�fdd�Z�fdd�Zd-�fdd�	Zejjjdd��Zejjjd d!��Zejjjd"d#��Zejjj�fd$d%��Zejjj�fd&d'��Zejjj�fd(d)��Zejjj�fd*d+��Z�ZS).�Serialzc    Inherit the native Serial port implementation and wrap all the methods and
    attributes.
    cs"tt|�j||�d|_d|_dS)NF)�superr:r&�	formatter�show_all)r%�args�kwargs)�	__class__rrr&�szSerial.__init__cCs"|dk	rtjjj||j|��dS)N)rr:�port�__set__�from_url)r%r,rrrrA�szSerial.portc	Cs�tj|�}|jdkr&tjdj|j���t}d}tj}yvxptj	|j
d�j�D]Z\}}|dkrjt|dd�}qJ|dkrxd}qJ|d	kr�t
}qJ|d
kr�d|_qJtdj|���qJWWn2tk
r�}ztjdj|���WYd
d
}~XnX|||�|_dj|j|jg�S)z(extract host and port from an URL stringZspyzmexpected a string in the form "spy://port[?option[=value][&option[=value]]]": not starting with spy:// ({!r})FT�filer�wr"�raw�allzunknown option: {!r}zPexpected a string in the form "spy://port[?option[=value][&option[=value]]]": {}Nr)�urlparse�urlsplit�schemerZSerialExceptionrr2�sys�stderr�parse_qs�query�items�openr r=�
ValueErrorr<r�netloc�path)	r%�url�partsr<r"r!�optionr�errrrC�s2


zSerial.from_urlcs$t|�}|jj|�tt|�j|�S)N)rr<r*r;r:r')r%r*)r@rrr'�szSerial.writercs*tt|�j|�}|s|jr&|jj|�|S)N)r;r:�readr=r<r))r%�sizer))r@rrrX�s
zSerial.read�cancel_readcs |jjdd�tt|�j�dS)NzQ-RXrZ)r<r-r;r:rZ)r%)r@rrrZ�szSerial.cancel_read�cancel_writecs |jjdd�tt|�j�dS)NzQ-TXr[)r<r-r;r:r[)r%)r@rrr[�szSerial.cancel_writecs*tt|�j}|jr&|jjddj|��|S)NzQ-RXzin_waiting -> {})r;r:�
in_waitingr=r<r-r)r%r)r@rrr\�szSerial.in_waitingcs |jjdd�tt|�j�dS)NzQ-TXr()r<r-r;r:r()r%)r@rrr(�szSerial.flushcs |jjdd�tt|�j�dS)NzQ-RX�reset_input_buffer)r<r-r;r:r])r%)r@rrr]�szSerial.reset_input_buffercs |jjdd�tt|�j�dS)NzQ-TX�reset_output_buffer)r<r-r;r:r^)r%)r@rrr^�szSerial.reset_output_buffer��?cs(|jjddj|��tt|�j|�dS)N�BRKzsend_break {}s)r<r-rr;r:�
send_break)r%�duration)r@rrra�szSerial.send_breakcCs*|jjd|rdnd�tjjj||�dS)Nr`�active�inactive)r<r-rr:�break_conditionrB)r%�levelrrrre�szSerial.break_conditioncCs*|jjd|rdnd�tjjj||�dS)NZRTSrcrd)r<r-rr:�rtsrB)r%rfrrrrg�sz
Serial.rtscCs*|jjd|rdnd�tjjj||�dS)NZDTRrcrd)r<r-rr:�dtrrB)r%rfrrrrhsz
Serial.dtrcs&tt|�j}|jjd|rdnd�|S)NZCTSrcrd)r;r:�ctsr<r-)r%rf)r@rrrisz
Serial.ctscs&tt|�j}|jjd|rdnd�|S)NZDSRrcrd)r;r:�dsrr<r-)r%rf)r@rrrjsz
Serial.dsrcs&tt|�j}|jjd|rdnd�|S)NZRIrcrd)r;r:�rir<r-)r%rf)r@rrrksz	Serial.rics&tt|�j}|jjd|rdnd�|S)NZCDrcrd)r;r:�cdr<r-)r%rf)r@rrrlsz	Serial.cd)r)r_)r.r/r0r1r&rr:rA�setterrCr'rX�hasattrrZr[�propertyr\r(r]r^rarergrhri�getterrjrkrl�
__classcell__rr)r@rr:�s,r:�__main__zspy:///dev/ttyS0)�
__future__rrKr3rZserial.serialutilrrH�ImportError�urllib.parse�parserr�objectr r2r:r.ZserrA�printrrrr�<module>s$3

haha - 2025