%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/serial/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/serial/__pycache__/serialcli.cpython-35.pyc



<�qV�$�@s�ddlZddlZddlZddlTejejZdd�ZGdd�de�Z	e
dkr�ddlZe	d�Zej
jde�e	�Zej
jde�d	e_d
e_ej�de_ej�ej
jde�dS)�N)�*cCstdd�|D��S)NcSsg|]}t|��qS�)�ord)�.0�xrr�2/usr/lib/python3/dist-packages/serial/serialcli.py�
<listcomp>s	z!as_byte_array.<locals>.<listcomp>)�sab)�stringrrr�
as_byte_arraysrc@s�eZdZdZd3Zdd�Zdd�Zdd�Zedd��Z	ddd�Z
dd�Zd d!�Zd"d#�Z
d$d%�Zd&d'�Zd(d)�Zed*d+��Zed,d-��Zed.d/��Zed0d1��Zd2S)4�Serialz)Serial port implementation for .NET/Mono.�2�K�n�����,�X���`	��%�K������cCs�|jdkrtd��|jr0td��ytjjj|j�|_WnGt	k
r�}z'd|_td|j|f��WYdd}~XnX|j
�|jj�d|_|js�|j
�|js�|j�|j�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�_reconfigurePortZOpenZ_dsrdtr�_update_dtr_state�_rtscts�_update_rts_state�reset_input_buffer)�self�msgrrr�open!s"		,

		
	
zSerial.opencCs�|jstd��|jdkr?tjjjj|j_nt	|jd�|j_|j
dkr�tjjjj|j_nt	|j
d�|j_y|j|j_
Wn7tk
r�}ztt|���WYdd}~XnX|jtkrd|j_nm|jtkr$d|j_nO|jtkrBd|j_n1|jtkr`d|j_ntd|j��|jtkr�ttjjjd	�|j_n�|jtkr�tjjjj|j_n�|jtkr�tjjjj|j_ng|jtkr!tjjjj |j_n=|jt!krKtjjjj"|j_ntd
|j��|j#t$kr�tjjj%j&|j_%ng|j#t'kr�tjjj%j(|j_%n=|j#t)kr�tjjj%j*|j_%ntd|j#��|j+r|j,rtjjj-j.|j_-nf|j+r@tjjj-j/|j_-nB|j,rdtjjj-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)1r$rZ_timeoutr r!r"r#ZInfiniteTimeoutZReadTimeout�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_TWOZTwor(Z_xonxoffZ	HandshakeZRequestToSendXOnXOffZ
RequestToSendZXOnXOff)r+�errrr&9s\	%!		zSerial._reconfigurePortcCsW|jrS|jrJy|jj�Wntjjjk
r@YnXd|_d|_dS)z
Close portNF)rr$ZCloser r!r"ZInvalidOperationException)r+rrr�close�s			zSerial.closecCs|jst�|jjS)z>Return the number of characters currently in the input buffer.)r$�portNotOpenErrorZBytesToRead)r+rrr�
in_waiting�s	zSerial.in_waiting�cCs|jst�t�}xZ|rty|j|jj��Wn)tjk
rf}zPWYdd}~XqX|d8}qWt|�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<)r$r:�	bytearray�appendZReadByter �TimeoutException�bytes)r+�size�datar8rrr�read�s			zSerial.readcCsp|jst�y&|jjt|�dt|��Wn.tjk
re}zt�WYdd}~XnXt|�S)z-Output the given string over the serial port.rN)r$r:ZWriter�lenr r?ZwriteTimeoutError)r+rBr8rrr�write�s	&zSerial.writecCs |jst�|jj�dS)z9Clear input buffer, discarding all that is in the buffer.N)r$r:ZDiscardInBuffer)r+rrrr*�s	zSerial.reset_input_buffercCs |jst�|jj�dS)zs        Clear output buffer, aborting the current output and
        discarding all that is in the buffer.
        N)r$r:ZDiscardOutBuffer)r+rrr�reset_output_buffer�s	zSerial.reset_output_buffercCs(|jst�t|j�|j_dS)zT
        Set break: Controls TXD. When active, to transmitting is possible.
        N)r$r:�boolZ_break_stateZ
BreakState)r+rrr�_update_break_state�s	zSerial._update_break_statecCs(|jst�t|j�|j_dS)z)Set terminal status line: Request To SendN)r$r:rGZ
_rts_stateZ	RtsEnable)r+rrrr)�s	zSerial._update_rts_statecCs(|jst�t|j�|j_dS)z-Set terminal status line: Data Terminal ReadyN)r$r:rGZ
_dtr_stateZ	DtrEnable)r+rrrr'�s	zSerial._update_dtr_statecCs|jst�|jjS)z(Read terminal status line: Clear To Send)r$r:Z
CtsHolding)r+rrr�cts�s	z
Serial.ctscCs|jst�|jjS)z)Read terminal status line: Data Set Ready)r$r:Z
DsrHolding)r+rrr�dsr�s	z
Serial.dsrcCs|jst�dS)z)Read terminal status line: Ring IndicatorF)r$r:)r+rrr�ri�s	z	Serial.ricCs|jst�|jjS)z)Read terminal status line: Carrier Detect)r$r:Z	CDHolding)r+rrr�cd�s	z	Serial.cdN)r
rrrrrrrrrrrrrrrr)�__name__�
__module__�__qualname__�__doc__Z	BAUDRATESr-r&r9�propertyr;rCrEr*rFrHr)r'rIrJrKrLrrrrrs$I	r�__main__z%s
iKr0)Zclrr ZSystem.IO.PortsZserial.serialutilZArrayZByter	rZ
SerialBaserrM�sys�sZstdiorEZbaudrateZdatabitsr9Zportr-rrrr�<module>
s$

�			
	


Zerion Mini Shell 1.0