HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_spy.cpython-38.pyc
U

��WW@#�@s�ddlZddlZddlZzddlZWn ek
rDddlmZYnXdd�Zdd�ZGdd�de	�Z
Gdd	�d	e	�ZGd
d�dej�Ze
dkr�ed�Zd
e_ee�dS)�Nccs�d}t�|�D]d}d�t|��d|kr2dkr@nn
|�d�ndfV|d7}|dkr`d	Vq|d
krdVd}q|dkr�|d
kr�|d7}|dkr�d	VdVq|dVd
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�.��)� ��)NN)z   rN)�serialZ	iterbytes�format�ord�decode)�data�n�b�r�@/usr/lib/python3/dist-packages/serial/urlhandler/protocol_spy.py�sixteen"s 6rccs|g}g}d}t|�D]b\}}|dkrb|d�d�|�d�|�g�fV|dd�=|dd�=|d7}q|�|�|�|�qdS)z yield lines with hexdump of datarNrr	r
)r�join�append)r�valuesr�offset�h�arrr�hexdump9s 



rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�	FormatRawz&Forward only RX and TX data to output.cCs||_||_d|_d|_dS)N��)�output�color�rx_color�tx_color��selfrr rrr�__init__LszFormatRaw.__init__cCs.|jr|j�|j�|j�|�|j��dS)zshow received dataN)r r�writer!�flush�r$rrrr�rxRszFormatRaw.rxcCs.|jr|j�|j�|j�|�|j��dS)zshow transmitted dataN)r rr&r"r'r(rrr�txYszFormatRaw.txcCsdS)z(do not) show control callsNr�r$�name�valuerrr�control`szFormatRaw.controlN)�__name__�
__module__�__qualname__�__doc__r%r)r*r.rrrrrIs
rc@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,t��|_||_||_d|_d|_d|_dS)Nrrz)�time�
start_timerr r!r"�
control_colorr#rrrr%ts
zFormatHexdump.__init__r	cCs&|j�d�||||��|j��dS)Nz{:010.3f} {:4} {}{}
)rr&rr')r$Z	timestampZlabelr-Zvalue2rrr�
write_line|szFormatHexdump.write_linecCsh|jr|j�|j�|rLt|�D](\}}|�t��|jdd�|�|�q n|�t��|jdd�dS)zshow received data as hex dumpZRX�{:04X}  z<empty>N)	r rr&r!rr7r4r5r�r$rr�rowrrrr)�s$zFormatHexdump.rxcCsJ|jr|j�|j�t|�D](\}}|�t��|jdd�|�|�qdS)z!show transmitted data as hex dumpZTXr8N)	r rr&r"rr7r4r5rr9rrrr*�szFormatHexdump.txcCs0|jr|j�|j�|�t��|j||�dS)zshow control callsN)r rr&r6r7r4r5r+rrrr.�szFormatHexdump.controlN)r	)	r/r0r1r2r%r7r)r*r.rrrrr3es

r3csTeZdZdZ�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	rtjj�||�|��dS�N)rr;�port�__set__�from_url)r$r-rrrrD�szSerial.portc	
Cs�t�|�}|jdkr&t�d�|j���t}d}tj}zrt�	|j
d���D]Z\}}|dkrht|dd�}qH|dkrvd}qH|d	kr�t
}qH|d
kr�d|_qHtd�|���qHWn2tk
r�}zt�d�|���W5d
}~XYnX|||�|_d�|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	)�urlparseZurlsplitZschemerZSerialExceptionrr3�sys�stderrZparse_qsZquery�items�openrr>�
ValueErrorr=rZnetloc�path)	r$Zurl�partsr=r rZoptionr�errrrF�s:

����zSerial.from_urlcs|j�|�tt|��|�SrC)r=r*r<r;r&)r$r*rArrr&�szSerial.writercs*tt|��|�}|s|jr&|j�|�|SrC)r<r;�readr>r=r))r$�sizer)rArrrT�s
zSerial.read�cancel_readcs |j�dd�tt|���dS)N�Q-RXrV)r=r.r<r;rV�r$rArrrV�szSerial.cancel_read�cancel_writecs |j�dd�tt|���dS)N�Q-TXrY)r=r.r<r;rYrXrArrrY�szSerial.cancel_writecs*tt|�j}|jr&|j�dd�|��|S)NrWzin_waiting -> {})r<r;�
in_waitingr>r=r.r)r$rrArrr[�szSerial.in_waitingcs |j�dd�tt|���dS)NrZr')r=r.r<r;r'rXrArrr'�szSerial.flushcs |j�dd�tt|���dS)NrW�reset_input_buffer)r=r.r<r;r\rXrArrr\�szSerial.reset_input_buffercs |j�dd�tt|���dS)NrZ�reset_output_buffer)r=r.r<r;r]rXrArrr]�szSerial.reset_output_buffer��?cs(|j�dd�|��tt|��|�dS)N�BRKzsend_break {}s)r=r.rr<r;�
send_break)r$ZdurationrArrr`�szSerial.send_breakcCs*|j�d|rdnd�tjj�||�dS)Nr_�active�inactive)r=r.rr;�break_conditionrE�r$�levelrrrrc�szSerial.break_conditioncCs*|j�d|rdnd�tjj�||�dS)NZRTSrarb)r=r.rr;�rtsrErdrrrrf�sz
Serial.rtscCs*|j�d|rdnd�tjj�||�dS)NZDTRrarb)r=r.rr;�dtrrErdrrrrg�sz
Serial.dtrcs&tt|�j}|j�d|rdnd�|S)NZCTSrarb)r<r;�ctsr=r.rdrArrrhsz
Serial.ctscs&tt|�j}|j�d|rdnd�|S)NZDSRrarb)r<r;�dsrr=r.rdrArrrisz
Serial.dsrcs&tt|�j}|j�d|rdnd�|S)NZRIrarb)r<r;�rir=r.rdrArrrjsz	Serial.rics&tt|�j}|j�d|rdnd�|S)NZCDrarb)r<r;�cdr=r.rdrArrrksz	Serial.cd)r)r^)r/r0r1r2r%rr;rD�setterrFr&rT�hasattrrVrY�propertyr[r'r\r]r`rcrfrgrh�getterrirjrk�
__classcell__rrrArr;�s>



r;�__main__zspy:///dev/ttyS0)rLr4rrK�ImportErrorZurllib.parse�parserr�objectrr3r;r/ZserrD�printrrrr�<module>s 3