관리-도구
편집 파일: protocol_spy.cpython-39.pyc
a ������WW@#����������������������@���s����d�dl�Z�d�dlZd�dlZzd�dlZW�n�eyB���d�dlmZ�Y�n0�dd��Zdd��ZG�dd��de �Z G�dd ��d e �ZG�d d��dej�Ze dkr�ed�Zd e_ee��dS�)�����Nc�����������������c���s����d}t��|��D�]d}d�t|��d|��kr2dk�r@n�n |�d�ndfV��|d7�}|dkr`d V��q|d krdV��d}q|dkr�|d k�r�|d7�}|dkr�d V��dV��q|dV��d 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. r���z{:02X} ���� �����ascii�.��������)� ������)NN)z r���N)�serialZ iterbytes�format�ord�decode)�data�n�b��r����B/usr/lib/python3.9/site-packages/serial/urlhandler/protocol_spy.py�sixteen"���s ����6r���c�����������������c���s|���g�}g�}d}t�|��D�]b\}}|du�rb|d�d�|�d�|�g�fV��|dd�=�|dd�=�|d7�}q|�|��|�|��qdS�)z yield lines with hexdump of datar���Nr���r ���r ���)r����join�append)r����valuesr����offset�h�ar���r���r����hexdump9���s���� r���c�������������������@���s0���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd S�)� FormatRawz&Forward only RX and TX data to output.c�����������������C���s���||�_�||�_d|�_d|�_d�S�)N�[32m�[31m)�output�color�rx_color�tx_color��selfr���r ���r���r���r����__init__L���s����zFormatRaw.__init__c�����������������C���s.���|�j�r|�j�|�j��|�j�|��|�j����dS�)zshow received dataN)r ���r����writer!����flush�r$���r���r���r���r����rxR���s����zFormatRaw.rxc�����������������C���s.���|�j�r|�j�|�j��|�j�|��|�j����dS�)zshow transmitted dataN)r ���r���r&���r"���r'���r(���r���r���r����txY���s����zFormatRaw.txc�����������������C���s���dS�)z(do not) show control callsNr����r$����name�valuer���r���r����control`���s����zFormatRaw.controlN)�__name__� __module__�__qualname__�__doc__r%���r)���r*���r.���r���r���r���r���r���I���s ���r���c�������������������@���s:���e�Zd�ZdZdd��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 c�����������������C���s,���t�����|�_||�_||�_d|�_d|�_d|�_d�S�)Nr���r���z[37m)�time� start_timer���r ���r!���r"���� control_colorr#���r���r���r���r%���t���s���� zFormatHexdump.__init__r ���c�����������������C���s&���|�j��d�||||���|�j�����d�S�)Nz{:010.3f} {:4} {}{} )r���r&���r���r'���)r$���Z timestampZlabelr-���Zvalue2r���r���r���� write_line|���s����zFormatHexdump.write_linec�����������������C���sh���|�j�r|�j�|�j��|rLt|�D�](\}}|��t���|�j�dd�|�|��q n|��t���|�j�dd��dS�)zshow received data as hex dumpZRX�{:04X} z<empty>N) r ���r���r&���r!���r���r7���r4���r5���r����r$���r���r����rowr���r���r���r)�������s����$zFormatHexdump.rxc�����������������C���sJ���|�j�r|�j�|�j��t|�D�](\}}|��t���|�j�dd�|�|��qdS�)z!show transmitted data as hex dumpZTXr8���N) r ���r���r&���r"���r���r7���r4���r5���r���r9���r���r���r���r*�������s����zFormatHexdump.txc�����������������C���s0���|�j�r|�j�|�j��|��t���|�j�||��dS�)zshow control callsN)r ���r���r&���r6���r7���r4���r5���r+���r���r���r���r.�������s����zFormatHexdump.controlN)r ���) r/���r0���r1���r2���r%���r7���r)���r*���r.���r���r���r���r���r3���e���s��� r3���c�����������������������sT��e�Zd�ZdZ��fdd�Zejjjdd���Zdd��Z ��fdd �Z d,��fdd� Zeejd �rd��fdd�Z eejd�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. c��������������������s&���t�t|��j|i�|���d�|�_d|�_d�S�)NF)�superr;���r%���� formatter�show_all)r$����args�kwargs�� __class__r���r���r%�������s����zSerial.__init__c�����������������C���s"���|d�urt�jj�|�|��|���d�S��N)r���r;����port�__set__�from_url)r$���r-���r���r���r���rD�������s����zSerial.portc����������� ��� ���C���s����t��|�}|jdkr&t�d�|j���t}d}tj}zrt�� |j d����D�]Z\}}|dkrht|d�d�}qH|dkrvd}qH|d kr�t }qH|d kr�d|�_qHtd�|���qHW�n4�ty��}�zt�d�|���W�Y�d }~n d }~0�0�|||�|�_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 ���)�urlparse�urlsplit�schemer���ZSerialExceptionr���r3����sys�stderr�parse_qs�query�items�openr���r>���� ValueErrorr=���r����netloc�path) r$����url�partsr=���r ���r����optionr����er���r���r���rF�������s:���� ����zSerial.from_urlc��������������������s���|�j��|��tt|���|�S�rC���)r=���r*���r<���r;���r&���)r$���r*���rA���r���r���r&�������s����zSerial.writer���c��������������������s*���t�t|���|�}|s|�jr&|�j�|��|S�rC���)r<���r;����readr>���r=���r)���)r$����sizer)���rA���r���r���r[�������s���� zSerial.read�cancel_readc��������������������s ���|�j��dd��tt|������d�S�)N�Q-RXr]���)r=���r.���r<���r;���r]����r$���rA���r���r���r]�������s����zSerial.cancel_read�cancel_writec��������������������s ���|�j��dd��tt|������d�S�)N�Q-TXr`���)r=���r.���r<���r;���r`���r_���rA���r���r���r`�������s����zSerial.cancel_writec��������������������s*���t�t|��j}|�jr&|�j�dd�|���|S�)Nr^���zin_waiting -> {})r<���r;���� in_waitingr>���r=���r.���r���)r$���r���rA���r���r���rb�������s����zSerial.in_waitingc��������������������s ���|�j��dd��tt|������d�S�)Nra���r'���)r=���r.���r<���r;���r'���r_���rA���r���r���r'�������s����zSerial.flushc��������������������s ���|�j��dd��tt|������d�S�)Nr^����reset_input_buffer)r=���r.���r<���r;���rc���r_���rA���r���r���rc�������s����zSerial.reset_input_bufferc��������������������s ���|�j��dd��tt|������d�S�)Nra����reset_output_buffer)r=���r.���r<���r;���rd���r_���rA���r���r���rd�������s����zSerial.reset_output_buffer��������?c��������������������s(���|�j��dd�|���tt|���|��d�S�)N�BRKzsend_break {}s)r=���r.���r���r<���r;���� send_break)r$���ZdurationrA���r���r���rg�������s����zSerial.send_breakc�����������������C���s*���|�j��d|rdnd��tjj�|�|��d�S�)Nrf����active�inactive)r=���r.���r���r;����break_conditionrE����r$����levelr���r���r���rj�������s����zSerial.break_conditionc�����������������C���s*���|�j��d|rdnd��tjj�|�|��d�S�)NZRTSrh���ri���)r=���r.���r���r;����rtsrE���rk���r���r���r���rm�������s����z Serial.rtsc�����������������C���s*���|�j��d|rdnd��tjj�|�|��d�S�)NZDTRrh���ri���)r=���r.���r���r;����dtrrE���rk���r���r���r���rn�������s����z Serial.dtrc��������������������s&���t�t|��j}|�j�d|rdnd��|S�)NZCTSrh���ri���)r<���r;����ctsr=���r.���rk���rA���r���r���ro�����s����z Serial.ctsc��������������������s&���t�t|��j}|�j�d|rdnd��|S�)NZDSRrh���ri���)r<���r;����dsrr=���r.���rk���rA���r���r���rp�����s����z Serial.dsrc��������������������s&���t�t|��j}|�j�d|rdnd��|S�)NZRIrh���ri���)r<���r;����rir=���r.���rk���rA���r���r���rq�����s����z Serial.ric��������������������s&���t�t|��j}|�j�d|rdnd��|S�)NZCDrh���ri���)r<���r;����cdr=���r.���rk���rA���r���r���rr�����s����z Serial.cd)r���)re���)r/���r0���r1���r2���r%���r���r;���rD����setterrF���r&���r[����hasattrr]���r`����propertyrb���r'���rc���rd���rg���rj���rm���rn���ro����getterrp���rq���rr���� __classcell__r���r���rA���r���r;�������s>��� r;����__main__zspy:///dev/ttyS0)rN���r4���r���rK����ImportError�urllib.parse�parser���r����objectr���r3���r;���r/���ZserrD����printr���r���r���r����<module>���s ���3�