HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/serial/urlhandler/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/serial/urlhandler/__pycache__/protocol_loop.cpython-311.pyc
�

��a_)���ddlmZddlZddlZddlZ	ddlZn#e$r	ddlmZYnwxYw	ddl	Z	n#e$rddl
Z	YnwxYwddlmZm
Z
mZmZmZmZejejejejd�ZGd�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�errorc���eZdZdZdZ�fd�Zd�Z�fd�Zd�Zd�Z	e
d���Zdd
�Zd�Z
d�Zd
�Zd�Zd�Ze
d���Zd�Zd�Zd�Ze
d���Ze
d���Ze
d���Ze
d���Z�xZS)�SerialzSSerial port implementation that simulates a loop back connection in plain software.)�2�K�n����i,iXi�ii`	i�i�%iKi�i�i�c���d|_d|_d|_d|_t	t
|��j|i|��dS)NiF)�buffer_size�queue�logger�
_cancel_write�superr�__init__)�self�args�kwargs�	__class__s   ��A/usr/lib/python3/dist-packages/serial/urlhandler/protocol_loop.pyrzSerial.__init__/sI��������
����"���$��f�d���$�d�5�f�5�5�5�5�5�c���|jrtd���d|_tj|j��|_|j�td���|�|j��|�	��d|_|j
s|���|js|�
��|���|���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�rs r!�openzSerial.open6s���
�<�	;�!�"9�:�:�:�����[��!1�2�2��
��:��!�"R�S�S�S�	
�
�
�d�i� � � �	
��� � � �����|�	%��"�"�$�$�$��|�	%��"�"�$�$�$����!�!�!�� � �"�"�"�"�"r"c����|jr8d|_	|j�d��n#tj$rYnwxYwt	t
|�����dS)NF)r$r�
put_nowait�Fullrr�close)rr s �r!r5zSerial.closeQsv����<�	� �D�L�
��
�%�%�d�+�+�+�+���:�
�
�
���
����
�f�d���!�!�#�#�#�#�#s�,�>�>c��t|jtj��rd|jcxkrdks)nt	d�|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�formatrrr0s r!r)zSerial._reconfigure_portZs����$�.�'�*:�;�;�	N�1�t�~�C_�C_�C_�C_�X_�C_�C_�C_�C_��5�<�<�T�^�L�L�M�M�M��;�	4��K���2�3�3�3�3�3�	4�	4r"c��tj|��}|jdkr'td�|j�����	tj|jd�����D]�\}}|dkrrtj	��tj
d��|_|j�t|d��|j�d���}td�|�����d
S#t$r'}td	�|�����d
}~wwxYw)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�schemerr<�parse_qs�query�itemsr?�basicConfig�	getLoggerr�setLevel�
LOGGER_LEVELSr
r;)r�url�parts�option�values�es      r!r'zSerial.from_urlesT���!�#�&�&���<�6�!�!�!�&�&,�f�U�\�&:�&:�<�<�
<�
	P�"*�"3�E�K��"F�"F�"L�"L�"N�"N�
L�
L�����Y�&�&��'�)�)�)�")�"3�O�"D�"D�D�K��K�(�(��v�a�y�)A�B�B�B��K�%�%�&7�8�8�8�8�$�%;�%B�%B�6�%J�%J�K�K�K�
L�
L���	P�	P�	P�!�E�EK�V�A�Y�Y�P�P�
P�����	P���s�CD�
E�"E�Ec���|jst���|jrD|j�d�|j�������|j���S)z9Return the number of bytes currently in the input buffer.zin_waiting -> {:d}�r$r	rr
r<r�qsizer0s r!�
in_waitingzSerial.in_waiting~sn���|�	%�"�$�$�$��;�	O�
�K���2�9�9�$�*�:J�:J�:L�:L�M�M�N�N�N��z���!�!�!r"�c��|jst���|j�'|jdkrtj��|jz}nd}t	��}|dkr�|jr�	|j�|j���}|�||z
}|dz}n#nj#t
j$r|jdkrYnNYnwxYw|r9tj��|kr"|jr|j�	d��n
|dkr|j��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��timeoutrSzread timeout)r$r	�_timeout�time�	bytearrayr�get�Emptyrr�bytes)r�sizerV�data�bs     r!�readzSerial.read�s.���|�	%�"�$�$�$��=�$���!�);�);��i�k�k�D�M�1�G�G��G��{�{���Q�h�h�4�<�h�

��J�N�N�4�=�N�9�9��
�=��A�I�D��A�I�D�D����;�
�
�
��=�A�%�%��E�&�%�
�����
�4�9�;�;��0�0��;�5��K�$�$�^�4�4�4��#�Q�h�h�4�<�h�$�T�{�{�s�" B�B/�.B/c�:�|j�d��dS)N)rr3r0s r!�cancel_readzSerial.cancel_read�s���
���d�#�#�#�#�#r"c��d|_dS)NT)rr0s r!�cancel_writezSerial.cancel_write�s��!����r"c���d|_|jst���t|��}dt	|��z|jz}|j�k||jkr`|j}|dkr;|js4tjt|d����|dz}|dkr|j�4|jrdStd���t|��D]#}|j�
||j����$t	|��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 timeoutrU)rr$r	r�lenr8�_write_timeoutrX�sleep�minrrr�put)rr^�time_used_to_send�	time_left�bytes     r!�writezSerial.write�s��#����|�	%�"�$�$�$���~�~�� �3�t�9�9�,�t�~�=����*�/@�4�CV�/V�/V��+�I��a�-�-��(:�-��
�3�y�#�.�.�/�/�/��S� �	��a�-�-��(:�-��!�
��q�(��9�9�9��d�O�O�	>�	>�D��J�N�N�4��)<�N�=�=�=�=��4�y�y�r"c�:�|jst���|jr|j�d��	|j���r4|j���|j����2dSdS#tj$rYdSwxYw)z9Clear input buffer, discarding all that is in the buffer.zreset_input_buffer()N�r$r	rrrrQ�
get_nowaitr[r0s r!r.zSerial.reset_input_buffer�s����|�	%�"�$�$�$��;�	5��K���3�4�4�4�	��*�"�"�$�$�
(��
�%�%�'�'�'��*�"�"�$�$�
(�
(�
(�
(�
(���{�	�	�	��D�D�	�����AB�B�Bc�:�|jst���|jr|j�d��	|j���r4|j���|j����2dSdS#tj$rYdSwxYw)zs        Clear output buffer, aborting the current output and
        discarding all that is in the buffer.
        zreset_output_buffer()Nrpr0s r!r/zSerial.reset_output_buffer�s���
�|�	%�"�$�$�$��;�	6��K���4�5�5�5�	��*�"�"�$�$�
(��
�%�%�'�'�'��*�"�"�$�$�
(�
(�
(�
(�
(���{�	�	�	��D�D�	���rrc���|jst���|jrD|j�d�|j�������|j���S)z0Return how many bytes the in the outgoing bufferzout_waiting -> {:d}rPr0s r!�out_waitingzSerial.out_waiting�sn���|�	%�"�$�$�$��;�	P�
�K���3�:�:�4�:�;K�;K�;M�;M�N�N�O�O�O��z���!�!�!r"c�|�|jr4|j�d�|j����dSdS)z[        Set break: Controls TXD. When active, to transmitting is
        possible.
        z_update_break_state({!r})N)rrr<�_break_stater0s r!�_update_break_statezSerial._update_break_state�sI��
�;�	T��K���8�?�?��@Q�R�R�S�S�S�S�S�	T�	Tr"c�|�|jr4|j�d�|j����dSdS)z)Set terminal status line: Request To Sendz'_update_rts_state({!r}) -> state of CTSN)rrr<�
_rts_stater0s r!r-zSerial._update_rts_state��F���;�	`��K���F�M�M�d�o�^�^�_�_�_�_�_�	`�	`r"c�|�|jr4|j�d�|j����dSdS)z-Set terminal status line: Data Terminal Readyz'_update_dtr_state({!r}) -> state of DSRN�rrr<�
_dtr_stater0s r!r+zSerial._update_dtr_state�r{r"c��|jst���|jr2|j�d�|j����|jS)z(Read terminal status line: Clear To SendzCTS -> state of RTS ({!r}))r$r	rrr<rzr0s r!�ctsz
Serial.ctssT���|�	%�"�$�$�$��;�	S��K���9�@�@���Q�Q�R�R�R���r"c��|jr2|j�d�|j����|jS)z)Read terminal status line: Data Set ReadyzDSR -> state of DTR ({!r})r}r0s r!�dsrz
Serial.dsrs>���;�	S��K���9�@�@���Q�Q�R�R�R���r"c�r�|jst���|jr|j�d��dS)z)Read terminal status line: Ring Indicatorzreturning dummy for RIF�r$r	rrr0s r!�riz	Serial.ris@���|�	%�"�$�$�$��;�	7��K���5�6�6�6��ur"c�r�|jst���|jr|j�d��dS)z)Read terminal status line: Carrier Detectzreturning dummy for CDTr�r0s r!�cdz	Serial.cds@���|�	%�"�$�$�$��;�	7��K���5�6�6�6��tr")rS)�__name__�
__module__�__qualname__�__doc__�	BAUDRATESrr1r5r)r'�propertyrRr`rbrdrnr.r/rurxr-r+r�r�r�r��
__classcell__)r s@r!rr)s��������]�]�4�I�6�6�6�6�6�#�#�#�6$�$�$�$�$�	4�	4�	4�P�P�P�2�"�"��X�"�����B$�$�$�"�"�"����6
�
�
�
�
�
��"�"��X�"�T�T�T�`�`�`�
`�`�`�
����X������X������X������X�����r"r�__main__zloop://z{}
z	write...
zhello
zread: {!r}
�)!�
__future__rr?r9rXr@�ImportError�urllib.parse�parserr%�serial.serialutilrrrrrr	�DEBUG�INFO�WARNING�ERRORrIrr��sys�s�stdoutrnr<�flushr`r5�r"r!�<module>r�s��� '�&�&�&�&�&�������������$��O�O�O�O���$�$�$�#�#�#�#�#�#�#�#�$������L�L�L�L����������������y�x�x�x�x�x�x�x�x�x�x�x�x�x�x�x��]��L���
�]�	��
�z�z�z�z�z�Z�z�z�z�B�z����J�J�J���y���A��J���V�]�]�1�%�%�&�&�&��J���\�"�"�"��G�G�I�����G�G�I�I�I��J���^�*�*�1�6�6�!�9�9�5�5�6�6�6��G�G�I�I�I�I�I��s��'�'�0�	<�<