%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2379/lib/python3/dist-packages/serial/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2379/lib/python3/dist-packages/serial/__pycache__/serialcli.cpython-38.pyc

U

z�YW�#�@s@ddlZddlZddlTejejZdd�ZGdd�de�ZdS)�N)�*cCstdd�|D��S)NcSsg|]}t|��qS�)�ord)�.0�xrr�2/usr/lib/python3/dist-packages/serial/serialcli.py�
<listcomp>sz!as_byte_array.<locals>.<listcomp>)�sab)�stringrrr�
as_byte_arraysrc@s�eZdZdZdZdd�Zdd�Zdd�Zed	d
��Z	d#dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zedd��Zedd��Zedd��Zed d!��Zd"S)$�Serialz)Serial port implementation for .NET/Mono.)�2�K�n����i,iXi�ii`	i�i�%iKi�i�i�c
Cs�|jdkrtd��|jr td��ztjj�|j�|_Wn:t	k
rp}zd|_td|j|f��W5d}~XYnX|j
dkr�d|_
|jdkr�d|_|��|j�
�d|_|js�|��|js�|��|��dS)zx        Open port with current settings. This may throw a SerialException
        if the port cannot be opened.
        Nz.Port must be configured before it can be used.zPort is already open.zcould not open port %s: %sT)Z_port�SerialException�is_open�System�IO�Ports�
SerialPortZportstr�_port_handle�	Exception�
_rts_state�
_dtr_state�_reconfigure_portZOpenZ_dsrdtr�_update_dtr_state�_rtscts�_update_rts_state�reset_input_buffer)�self�msgrrr�opens*
$


zSerial.openc
Cs�|jstd��|jdkr*tjjjj|j_nt	|jd�|j_|j
dkrXtjjjj|j_nt	|j
d�|j_z|j|j_
Wn.tk
r�}ztt|���W5d}~XYnX|jtkr�d|j_nJ|jtkr�d|j_n6|jtkr�d|j_n"|jtkr�d|j_ntd|j��|jtk�r(ttjjjd	�|j_n�|jtk�rFtjjjj|j_nh|jtk�rdtjjjj|j_nJ|jtk�r�tjjjj |j_n,|jt!k�r�tjjjj"|j_ntd
|j��|j#t$k�r�tjjj%j&|j_%nJ|j#t'k�r�tjjj%j(|j_%n,|j#t)k�rtjjj%j*|j_%ntd|j#��|j+�r8|j,�r8tjjj-j.|j_-nH|j+�rRtjjj-j/|j_-n.|j,�rltjjj-j0|j_-nttjjj-d	�|j_-dS)z,Set communication parameters on opened port.z'Can only operate on a valid port handleNi�����z#Unsupported number of data bits: %r�NonezUnsupported parity mode: %rz#Unsupported number of stop bits: %r)1rrZ_timeoutrrrrZInfiniteTimeoutZReadTimeout�intZ_write_timeoutZWriteTimeoutZ	_baudrateZBaudRate�IOError�
ValueError�strZ	_bytesizeZFIVEBITSZDataBitsZSIXBITSZ	SEVENBITSZ	EIGHTBITSZ_parityZPARITY_NONE�getattrZParityZPARITY_EVENZEvenZ
PARITY_ODDZOddZPARITY_MARKZMarkZPARITY_SPACEZSpaceZ	_stopbitsZSTOPBITS_ONEZStopBitsZOneZSTOPBITS_ONE_POINT_FIVEZOnePointFiveZSTOPBITS_TWOZTworZ_xonxoffZ	HandshakeZRequestToSendXOnXOffZ
RequestToSendZXOnXOff)r"�errrr;s\









zSerial._reconfigure_portcCsF|jrB|jr<z|j��Wntjjjk
r4YnXd|_d|_dS)z
Close portNF)rrZCloserrrZInvalidOperationException�r"rrr�close�szSerial.closecCs|js
t�|jjS)z>Return the number of characters currently in the input buffer.)r�portNotOpenErrorrZBytesToReadr0rrr�
in_waiting�szSerial.in_waiting�cCsV|js
t�t�}|rNz|�|j���Wntjk
rBYqNYqX|d8}qt|�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.
        r4)	rr2�	bytearray�appendrZReadByter�TimeoutException�bytes)r"�size�datarrr�read�s

zSerial.readcCsJ|js
t�z|j�t|�dt|��Wntjk
r@t�YnXt|�S)z-Output the given string over the serial port.r)	rr2rZWriter�lenrr7ZwriteTimeoutError)r"r:rrr�write�s
zSerial.writecCs|js
t�|j��dS)z9Clear input buffer, discarding all that is in the buffer.N)rr2rZDiscardInBufferr0rrrr!�szSerial.reset_input_buffercCs|js
t�|j��dS)zs        Clear output buffer, aborting the current output and
        discarding all that is in the buffer.
        N)rr2rZDiscardOutBufferr0rrr�reset_output_buffer�szSerial.reset_output_buffercCs|js
t�t|j�|j_dS)zT
        Set break: Controls TXD. When active, to transmitting is possible.
        N)rr2�boolZ_break_staterZ
BreakStater0rrr�_update_break_state�szSerial._update_break_statecCs|js
t�t|j�|j_dS)z)Set terminal status line: Request To SendN)rr2r?rrZ	RtsEnabler0rrrr �szSerial._update_rts_statecCs|js
t�t|j�|j_dS)z-Set terminal status line: Data Terminal ReadyN)rr2r?rrZ	DtrEnabler0rrrr�szSerial._update_dtr_statecCs|js
t�|jjS)z(Read terminal status line: Clear To Send)rr2rZ
CtsHoldingr0rrr�cts�sz
Serial.ctscCs|js
t�|jjS)z)Read terminal status line: Data Set Ready)rr2rZ
DsrHoldingr0rrr�dsr�sz
Serial.dsrcCs|js
t�dS)z)Read terminal status line: Ring IndicatorF)rr2r0rrr�ri�sz	Serial.ricCs|js
t�|jjS)z)Read terminal status line: Carrier Detect)rr2rZ	CDHoldingr0rrr�cd�sz	Serial.cdN)r4)�__name__�
__module__�__qualname__�__doc__Z	BAUDRATESr$rr1�propertyr3r;r=r!r>r@r rrArBrCrDrrrrrs,H

	


r)	rZSystem.IO.PortsZserial.serialutilZArrayZByter	rZ
SerialBaserrrrr�<module>
s


Zerion Mini Shell 1.0