HOME


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

&�a_%U�
�n�ddlmZddlZddlZ	en#eef$rGd�de��ZYnwxYw	en#eef$re	ZYnwxYw	e
n#eef$re	fZ
YnwxYwd�Zd�Zedg��Z
edg��Zed	g��Zed
g��Zd\ZZZZZd\ZZZd
\ZZZZededededediZGd�de��ZGd�de��Z Gd�de��Z!Gd�de��Z"Gd�dej#��Z$e%dk�r7ddl&Z&e$��Z'e&j(�)d�*e'j+����e&j(�)d�*e'j,����e&j(�)d �*e'j-����e&j(�)d!�*e'j.����e&j(�)d"�*e'j/����e&j(�)d#�*e'����dSdS)$�)�absolute_importNc��eZdZdS)�
memoryviewN)�__name__�
__module__�__qualname__���3/usr/lib/python3/dist-packages/serial/serialutil.pyrrs�������r
rc#�K�t|t��r|���}d}	|||dz�}|dz
}|r|V�ndS�)z=Iterate over bytes, returning bytes instead of ints (python3)rT�N)�
isinstancer�tobytes)�b�i�as   r�	iterbytesr(sf�����!�Z� � ��
�I�I�K�K��	�A��
�a��A��g�J��	�Q����	��G�G�G�G��E�
r
c�p�t|t��r|St|t��rt|��St|t��r|���St|t
��r"t
d�|�����tt|����S)z"convert a sequence to a bytes typez?unicode strings are not supported, please encode to bytes: {!r})r�bytes�	bytearrayrr�unicode�	TypeError�format)�seqs r�to_bytesr8s����#�u���
%��
�	�C��	#�	#�%��S�z�z��	�C��	$�	$�%��{�{�}�}��	�C��	!�	!�%��Y�`�`�ad�e�e�f�f�f��Y�s�^�^�$�$�$r
���
�
)�N�E�O�M�S)r
g�?�)�����None�Even�Odd�Mark�Spacec��eZdZdZdS)�SerialExceptionz.Base class for serial port related exceptions.N�rrr�__doc__r	r
rr0r0\s������8�8�8�8r
r0c��eZdZdZdS)�SerialTimeoutExceptionz Write timeouts give an exceptionNr1r	r
rr4r4`s������*�*�*�*r
r4c�"��eZdZdZ�fd�Z�xZS)�PortNotOpenErrorzPort is not openc�X��tt|���d��dS)Nz)Attempting to use a port that is not open)�superr6�__init__)�self�	__class__s �rr9zPortNotOpenError.__init__fs)���
���%�%�.�.�/Z�[�[�[�[�[r
)rrrr2r9�
__classcell__)r;s@rr6r6dsG���������\�\�\�\�\�\�\�\�\r
r6c�`�eZdZdZeed��rejZnejZd�Zd�Z	d�Z
d�ZdS)�Timeouta>    Abstraction for timeout operations. Using time.monotonic() if available
    or time.time() in all other cases.

    The class can also be initialized with 0 or None, in order to support
    non-blocking and fully blocking I/O operations. The attributes
    is_non_blocking and is_infinite are set accordingly.
    �	monotonicc��|du|_|dk|_||_|�|���|z|_dSd|_dS)z(Initialize a timeout with given durationNr)�is_infinite�is_non_blocking�duration�TIME�target_time�r:rCs  rr9zTimeout.__init__sQ��$��,��� (�A�
��� ��
���#�y�y�{�{�X�5�D����#�D���r
c�D�|jduo|���dkS)z4Return a boolean, telling if the timeout has expiredNr)rE�	time_left�r:s r�expiredzTimeout.expired�s$����t�+�E����0@�0@�A�0E�Er
c���|jrdS|jrdS|j|���z
}||jkr(|���|jz|_|jStd|��S)z:Return how many seconds are left until the timeout expiresrN)rBrArErDrC�max)r:�deltas  rrHzTimeout.time_left�sq����	%��1�
�
�		%��4��$�t�y�y�{�{�2�E��t�}�$�$�#'�9�9�;�;���#>�� ��}�$��1�e�}�}�$r
c�L�||_|���|z|_dS)zb        Restart a timeout, only supported if a timeout was already set up
        before.
        N)rCrDrErFs  r�restartzTimeout.restart�s&��
!��
��9�9�;�;��1����r
N)rrrr2�hasattr�timer?rDr9rJrHrOr	r
rr>r>js����������w�t�[�!�!�
�
�~���
�y��$�$�$�F�F�F�
%�
%�
%�2�2�2�2�2r
r>c���eZdZdZdZeeeefZ	e
eee
efZeeefZddee
edddddddfd�Zed���Zejd���Zed	���Zejd
���Zed���Zejd���Zed
���Zejd���Zed���Zejd���Zed���Zejd���Zed���Zejd���Zed���Zejd���Zed���Zejd���Zed���Z e jd���Z ed���Z!e!jd���Z!ed���Z"e"jdId���Z"ed���Z#e#jd ���Z#ed!���Z$e$jd"���Z$ed#���Z%e%jd$���Z%ed%���Z&e&jd&���Z&d'Z'd(�Z(d)�Z)d*�Z*d+�Z+d,�Z,d-�Z-d.�Z.d/�Z/d0�Z0dJd2�Z1d3�Z2d4�Z3d5�Z4dJd6�Z5dKd8�Z6dKd9�Z7d:�Z8d;�Z9d<�Z:d=�Z;d>�Z<ed?���Z=e=jd@���Z=edA���Z>e>jdB���Z>dC�Z?dD�Z@dE�ZAdF�ZBeCdfdG�ZDdH�ZEdS)L�
SerialBasezh    Serial port base class. Provides __init__ function and properties to
    get/set port settings.
    )�2�K�n����i,iXi�ii`	i��%iKi�i�i�i�ii �i�ii@Bi�i`�i��i�%&i��-i�g5i	=NrZFc
��d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
d|_d|_d|_d|_d|_||_||_||_||_||_||_|	|_||_||_|
|_||_||_d|
vr|
�d��|_d|
vr|
�d��|_|
r"tAd�!|
�����|�|�"��dSdS)z�        Initialize comm port object. If a "port" is given, then the port will be
        opened immediately. Otherwise a Serial port object in closed state
        is returned.
        FNT�writeTimeout�interCharTimeoutz"unexpected keyword arguments: {!r})#�is_open�portstr�name�_port�	_baudrate�	_bytesize�_parity�	_stopbits�_timeout�_write_timeout�_xonxoff�_rtscts�_dsrdtr�_inter_byte_timeout�_rs485_mode�
_rts_state�
_dtr_state�_break_state�
_exclusive�port�baudrate�bytesize�parity�stopbits�timeout�
write_timeout�xonxoff�rtscts�dsrdtr�inter_byte_timeout�	exclusive�pop�
ValueErrorr�open)r:rqrrrsrtrurvrxryrwrzr{r|�kwargss              rr9zSerialBase.__init__�sk��(��������	���
���������������
�"�����
�������#'�� ����������!��������	� ��
� ��
���� ��
����*������������"4���"����V�#�#�!'���N�!;�!;�D����'�'�&,�j�j�1C�&D�&D�D�#��	R��A�H�H��P�P�Q�Q�Q����I�I�K�K�K�K�K��r
c��|jS)z{        Get the current port setting. The value that was passed on init or using
        setPort() is passed back.
        )rarIs rrqzSerialBase.port�s���z�r
c�0�|�Dt|t��s/td�t	|�������|j}|r|���||_||_|j|_	|r|�
��dSdS)z!        Change the port.
        Nz'"port" must be None or a string, not {})r�
basestringr~r�typer^�closer_rar`r)r:rq�was_opens   rrqzSerialBase.ports���
��J�t�Z�$@�$@���F�M�M�d�SW�j�j�Y�Y�Z�Z�Z��<���	��J�J�L�L�L������
��L��	��	��I�I�K�K�K�K�K�	�	r
c��|jS)z"Get the current baud rate setting.)rbrIs rrrzSerialBase.baudrate����~�r
c��	t|��}|dkr"td�|�����||_|jr|���dSdS#t$r#td�|�����wxYw)z�        Change baud rate. It raises a ValueError if the port is open and the
        baud rate is not possible. If the port is closed, then the value is
        accepted and the exception is raised when the port is opened.
        rzNot a valid baudrate: {!r}N)�intr~rrbr^�_reconfigure_portr)r:rrrs   rrrzSerialBase.baudrates���		)��H�
�
�A��1�u�u� �!=�!D�!D�X�!N�!N�O�O�O��D�N��|�
)��&�&�(�(�(�(�(�
)�
)��
�	L�	L�	L��9�@�@��J�J�K�K�K�	L���s�A�-Bc��|jS)z"Get the current byte size setting.)rcrIs rrszSerialBase.bytesize-r�r
c��||jvr"td�|�����||_|jr|���dSdS)zChange byte size.zNot a valid byte size: {!r}N)�	BYTESIZESr~rrcr^r�)r:rss  rrszSerialBase.bytesize2sa���4�>�)�)��:�A�A�(�K�K�L�L�L�!����<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS)z)Get the current exclusive access setting.)rprIs rr|zSerialBase.exclusive;s����r
c�N�||_|jr|���dSdS)z$Change the exclusive access setting.N)rpr^r�)r:r|s  rr|zSerialBase.exclusive@s7��$����<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS)zGet the current parity setting.)rdrIs rrtzSerialBase.parityG����|�r
c��||jvr"td�|�����||_|jr|���dSdS)zChange parity setting.zNot a valid parity: {!r}N)�PARITIESr~rrdr^r�)r:rts  rrtzSerialBase.parityLsa�����&�&��7�>�>�v�F�F�G�G�G�����<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS)z"Get the current stop bits setting.)rerIs rruzSerialBase.stopbitsUr�r
c��||jvr"td�|�����||_|jr|���dSdS)zChange stop bits size.zNot a valid stop bit size: {!r}N)�STOPBITSr~rrer^r�)r:rus  rruzSerialBase.stopbitsZsa���4�=�(�(��>�E�E�h�O�O�P�P�P�!����<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS�z Get the current timeout setting.)rfrIs rrvzSerialBase.timeoutc����}�r
c��|�_	|dzn0#t$r#td�|�����wxYw|dkr"td�|�����||_|jr|���dSdS)�Change timeout setting.Nr
�Not a valid timeout: {!r}r)rr~rrfr^r��r:rvs  rrvzSerialBase.timeouths�����
N��!������
N�
N�
N� �!<�!C�!C�G�!L�!L�M�M�M�
N������{�{� �!<�!C�!C�G�!L�!L�M�M�M���
��<�	%��"�"�$�$�$�$�$�	%�	%s�
�-7c��|jSr�)rgrIs rrwzSerialBase.write_timeoutvs
���"�"r
c��|�_|dkr"td�|�����	|dzn0#t$r#td�|�����wxYw||_|jr|���dSdS)r�Nrr�r
)r~rrrgr^r�r�s  rrwzSerialBase.write_timeout{s�������{�{� �!<�!C�!C�G�!L�!L�M�M�M�
N��!������
N�
N�
N� �!<�!C�!C�G�!L�!L�M�M�M�
N����&����<�	%��"�"�$�$�$�$�$�	%�	%�	�2�-Ac��|jS)z0Get the current inter-character timeout setting.)rkrIs rr{zSerialBase.inter_byte_timeout�s
���'�'r
c��|�_|dkr"td�|�����	|dzn0#t$r#td�|�����wxYw||_|jr|���dSdS)z"Change inter-byte timeout setting.Nrr�r
)r~rrrkr^r�)r:�
ic_timeouts  rr{zSerialBase.inter_byte_timeout�s����!��A�~�~� �!<�!C�!C�J�!O�!O�P�P�P�
Q��Q������
Q�
Q�
Q� �!<�!C�!C�J�!O�!O�P�P�P�
Q����$.�� ��<�	%��"�"�$�$�$�$�$�	%�	%r�c��|jS)z!Get the current XON/XOFF setting.)rhrIs rrxzSerialBase.xonxoff�r�r
c�N�||_|jr|���dSdS)zChange XON/XOFF setting.N)rhr^r�)r:rxs  rrxzSerialBase.xonxoff�s7�� ��
��<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS)z-Get the current RTS/CTS flow control setting.)rirIs rryzSerialBase.rtscts�r�r
c�N�||_|jr|���dSdS)z$Change RTS/CTS flow control setting.N)rir^r�)r:rys  rryzSerialBase.rtscts�s7������<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS)z-Get the current DSR/DTR flow control setting.)rjrIs rrzzSerialBase.dsrdtr�r�r
c�l�|�
|j|_n||_|jr|���dSdS)z#Change DsrDtr flow control setting.N)rirjr^r�)r:rzs  rrzzSerialBase.dsrdtr�sI���>��<�D�L�L�"�D�L��<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jS�N)rmrIs r�rtszSerialBase.rts��
����r
c�N�||_|jr|���dSdSr�)rmr^�_update_rts_state�r:�values  rr�zSerialBase.rts��5������<�	%��"�"�$�$�$�$�$�	%�	%r
c��|jSr�)rnrIs r�dtrzSerialBase.dtr�r�r
c�N�||_|jr|���dSdSr�)rnr^�_update_dtr_stater�s  rr�zSerialBase.dtr�r�r
c��|jSr�)rorIs r�break_conditionzSerialBase.break_condition�s��� � r
c�N�||_|jr|���dSdSr�)ror^�_update_break_stater�s  rr�zSerialBase.break_condition�s6��!����<�	'��$�$�&�&�&�&�&�	'�	'r
c��|jS)z�        Enable RS485 mode and apply new settings, set to None to disable.
        See serial.rs485.RS485Settings for more info about the value.
        )rlrIs r�
rs485_modezSerialBase.rs485_mode�s
����r
c�N�||_|jr|���dSdSr�)rlr^r�)r:�rs485_settingss  rr�zSerialBase.rs485_mode�s6��)����<�	%��"�"�$�$�$�$�$�	%�	%r
)
rrrsrtrurxrzryrvrwr{c�D��t�fd��jD����S)zb        Get current port settings as a dictionary. For use with
        apply_settings().
        c�:��g|]}|t�d|z��f��S)�_)�getattr)�.0�keyr:s  �r�
<listcomp>z+SerialBase.get_settings.<locals>.<listcomp>s,���U�U�U��c�7�4��s��3�3�4�U�U�Ur
)�dict�_SAVED_SETTINGSrIs`r�get_settingszSerialBase.get_settings�s+���
�U�U�U�U��@T�U�U�U�V�V�Vr
c��|jD]:}||vr4||t|d|z��krt||||���;dS)z�        Apply stored settings from a dictionary returned from
        get_settings(). It's allowed to delete keys from the dictionary. These
        values will simply left unchanged.
        r�N)r�r��setattr)r:�dr�s   r�apply_settingszSerialBase.apply_settingss\���'�	+�	+�C��a�x�x�A�c�F�g�d�C�#�I�&>�&>�>�>���c�1�S�6�*�*�*��	+�	+r
c�`�d�|jjt|��|���S)zAString representation of the current port settings and its state.z�{name}<id=0x{id:x}, open={p.is_open}>(port={p.portstr!r}, baudrate={p.baudrate!r}, bytesize={p.bytesize!r}, parity={p.parity!r}, stopbits={p.stopbits!r}, timeout={p.timeout!r}, xonxoff={p.xonxoff!r}, rtscts={p.rtscts!r}, dsrdtr={p.dsrdtr!r}))r`�id�p)rr;rr�rIs r�__repr__zSerialBase.__repr__s9��;�<B�6���/�B�t�H�H��<B�<F�<F�	Fr
c��dS�NTr	rIs r�readablezSerialBase.readable����tr
c��dSr�r	rIs r�writablezSerialBase.writabler�r
c��dS)NFr	rIs r�seekablezSerialBase.seekable!s���ur
c��|�t|����}t|��}	||d|�<nM#t$r@}ddl}t	||j��s|�|�d|��|d|�<Yd}~nd}~wwxYw|S)Nrr)�read�lenr�arrayr)r:r�data�n�errr�s      r�readintozSerialBase.readinto$s����y�y��Q��� � ����I�I��	+��A�b�q�b�E�E���	+�	+�	+��L�L�L��a���-�-�
��	��K�K��T�*�*�A�b�q�b�E�E�E�E�E�E�����		+����
�s�;�
B�6B�Bc�J�|j�|js|���|Sr�)rar^rrIs r�	__enter__zSerialBase.__enter__3s#���:�!�$�,�!��I�I�K�K�K��r
c�.�|���dSr�)r�)r:�argsr�s   r�__exit__zSerialBase.__exit__8s���
�
�����r
��?c�t�|jst���d|_tj|��d|_dS)za        Send break condition. Timed, returns to idle state after given
        duration.
        TFN)r^r6r�rQ�sleeprFs  r�
send_breakzSerialBase.send_break=s@��
�|�	%�"�$�$�$�#����
�8����$����r
c�.�|���dSr�)�reset_input_bufferrIs r�
flushInputzSerialBase.flushInputKs�����!�!�!�!�!r
c�.�|���dSr�)�reset_output_bufferrIs r�flushOutputzSerialBase.flushOutputNs��� � �"�"�"�"�"r
c��|jSr�)�
in_waitingrIs r�	inWaitingzSerialBase.inWaitingQs
����r
c�0�|�|��dSr�)r�rFs  r�	sendBreakzSerialBase.sendBreakTs������!�!�!�!�!r
r
c��||_dSr�)r�r�s  r�setRTSzSerialBase.setRTSW�
������r
c��||_dSr�)r�r�s  r�setDTRzSerialBase.setDTRZr�r
c��|jSr�)�ctsrIs r�getCTSzSerialBase.getCTS]�	���x�r
c��|jSr�)�dsrrIs r�getDSRzSerialBase.getDSR`r�r
c��|jSr�)�rirIs r�getRIzSerialBase.getRIc�	���w�r
c��|jSr�)�cdrIs r�getCDzSerialBase.getCDfrr
c��||_dSr�)rq)r:rqs  r�setPortzSerialBase.setPortis
����	�	�	r
c��|jSr��rwrIs rr\zSerialBase.writeTimeoutls���!�!r
c��||_dSr�rr�s  rr\zSerialBase.writeTimeoutps��$����r
c��|jSr��r{rIs rr]zSerialBase.interCharTimeoutts���&�&r
c��||_dSr�r)r:r]s  rr]zSerialBase.interCharTimeoutxs��"2����r
c�*�|���Sr�)r�rIs r�getSettingsDictzSerialBase.getSettingsDict|s��� � �"�"�"r
c�0�|�|��dSr�)r�)r:r�s  r�applySettingsDictzSerialBase.applySettingsDicts�����A�����r
c��|jSr�)r^rIs r�isOpenzSerialBase.isOpen�s
���|�r
c�6�|�|j��S)zL        Read all bytes currently available in the buffer of the OS.
        )r�r�rIs r�read_allzSerialBase.read_all�s���y�y���)�)�)r
c�8�t|��}t��}t|j��}	|�d��}|r,||z
}||d�|krn.|�t|��|krnnn|���rn�Zt
|��S)z�        Read until an expected sequence is found ('
' by default), the size
        is exceeded or until timeout occurs.
        Tr
N)r�rr>rfr�rJr)r:�expected�size�lenterm�linerv�cs       r�
read_untilzSerialBase.read_until�s���
�h�-�-���{�{���$�-�(�(��	��	�	�!���A��
���	�����	�	�?�h�.�.���#��D�	�	�T�(9�(9������� � �
��	��T�{�{�r
c/�4K�	|j|i|��}|sdS|V��)zs        Read lines, implemented as generator. It will raise StopIteration on
        timeout (empty read).
        TN)r)r:r�r�rs    r�iread_untilzSerialBase.iread_until�s<����
	�"�4�?�D�3�F�3�3�D��
����J�J�J�		r
r�)r�)r
)Frrrr2�	BAUDRATES�FIVEBITS�SIXBITS�	SEVENBITS�	EIGHTBITSr��PARITY_NONE�PARITY_EVEN�
PARITY_ODD�PARITY_MARK�PARITY_SPACEr��STOPBITS_ONE�STOPBITS_ONE_POINT_FIVE�STOPBITS_TWOr�r9�propertyrq�setterrrrsr|rtrurvrwr{rxryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
r\r]rrrr�LFrr!r	r
rrSrS�sV��������,�I��7�I�y�9�I��[�*�k�<�P�H��5�|�D�H���#�#�&����#��$(��@�@�@�@�T����X��
�[�
�
��[�
�����X���_�)�)��_�)�"����X���_�%�%��_�%�����X����%�%���%�����X���]�%�%��]�%�����X���_�%�%��_�%�����X��
�^�%�%��^�%��#�#��X�#���%�%���%��(�(��X�(���%�%���%�����X��
�^�%�%��^�%�����X���]�%�%��]�%�����X���]�	%�	%�	%��]�	%�����X��	�Z�%�%��Z�%�
����X��	�Z�%�%��Z�%�
�!�!��X�!���'�'���'�� � ��X� ���%�%���%�-�O�W�W�W�+�+�+�F�F�F����������
�
�
����
���
	%�	%�	%�	%�"�"�"�#�#�#����"�"�"�"�������������������������"�"��X�"���%�%���%��'�'��X�'���3�3���3�#�#�#�������*�*�*�#%�4�����,	�	�	�	�	r
rS�__main__zport name:  {}
zbaud rates: {}
zbyte sizes: {}
zparities:   {}
zstop bits:  {}
z{}
)0�
__future__r�iorQr�	NameError�AttributeError�objectr�strr�rr�XON�XOFF�CRr1r'r(r)r*r+r,r-r.r#r$r%r&�PARITY_NAMES�IOErrorr0r4r6r>�	RawIOBaserSr�sys�s�stdout�writerr`r"r�r�r�r	r
r�<module>rCs���'�&�&�&�&�&�	�	�	�	�����
��J�J���>�"�
�
�
�
�
�
�
�
�V�
�
�
�
�
�
������G�G���>�"�����G�G�G�������J�J���>�"������J�J�J�����
��� %�%�%� �h��t�n�n���x���~�~��
�X�r�d�^�^��
�X�r�d�^�^��CZ�?��[�*�k�<�6A�3��%�|�*6�'��'�9�i����������'���9�9�9�9�9�g�9�9�9�+�+�+�+�+�_�+�+�+�\�\�\�\�\��\�\�\�82�82�82�82�82�f�82�82�82�vH�H�H�H�H���H�H�H�X�z����J�J�J��
���A��J���'�.�.�q�v�6�6�7�7�7��J���'�.�.�q�{�;�;�<�<�<��J���'�.�.�q�{�;�;�<�<�<��J���'�.�.�q�z�:�:�;�;�;��J���'�.�.�q�z�:�:�;�;�;��J���V�]�]�1�%�%�&�&�&�&�&��s*��+�+�2�	>�>�A�
A�A