%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__/serialjava.cpython-38.pyc

U

�;�V� �@s@ddlTdd�Zdd�Zeddg�Zdd	�ZGd
d�de�ZdS)
�)�*cCs2t|�}|�d�}|dd�D]}t||�}q|S)N�.�)�
__import__�split�getattr)�name�modZ
components�comp�r�3/usr/lib/python3/dist-packages/serial/serialjava.py�	my_import
s

r
c
CsH|D]6}zt|�}|j|WSttfk
r8YqXqtd��dS)z1try given list of modules and return that importsz/No Java Communications API implementation foundN)r
�
SerialPort�ImportError�AttributeError)�namesrr	rrr�detect_java_comms
rz
javax.commzgnu.iocCsFtj��}g}|��r:|��}|��tjjkr|�|�q||��S)z%Turn a port number into a device name)	�comm�CommPortIdentifierZgetPortIdentifiersZhasMoreElementsZnextElementZgetPortTypeZPORT_SERIAL�appendZgetName)Z
portnumber�enumZportsZelrrr�device*s
rc@s�eZdZdZdd�Zdd�Zdd�Zedd	��Zd%dd�Z	d
d�Z
dd�Zdd�Zd&dd�Z
dd�Zdd�Zdd�Zedd��Zedd��Zed d!��Zed"d#��Zd$S)'�Serialz�    Serial port class, implemented with Java Communications API and
    thus usable with jython and the appropriate java extension.
    c
Cs�|jdkrtd��|jr td��t|j�td�krBtj�|j�}ntj�t|j��}z|�dd�|_	Wn4t
k
r�}zd|_	td|��W5d}~XYnX|��|j	��|_
|j	��|_d|_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.�zpython serial module�
zCould not open port: %sT)Z_port�SerialException�is_open�typerrZgetPortIdentifierr�open�sPort�	Exception�_reconfigurePortZgetInputStream�	_instreamZgetOutputStream�
_outstream)�selfZportId�msgrrrr;s 
zSerial.opencCs�|jstd��|j�d�|jtkr.tjj}nJ|jtkrBtjj	}n6|jt
krVtjj}n"|jtkrjtjj
}ntd|j��|jtkr�tjj}n6|jtkr�tjj}n"|jtkr�tjj}ntd|j��|jtkr�tjj}nb|jtkr�tjj}nN|jtkr�tjj}n:|jtk�rtjj}n$|jtk�r*tjj}ntd|j��d}}|j�r`|tjjO}|tjjO}|j�r�|tjj O}|tjj!O}|j�"|j#|||�|j�$||B�|j%dk�r�|j�t&|j%d��n
|j�'�dS)	z,Set communication parameters on opened port.z'Can only operate on a valid port handle�zunsupported bytesize: %rz"unsupported number of stopbits: %rzunsupported parity type: %rri�N)(rrZenableReceiveTimeoutZ	_bytesizeZFIVEBITSrrZ
DATABITS_5ZSIXBITSZ
DATABITS_6Z	SEVENBITSZ
DATABITS_7Z	EIGHTBITSZ
DATABITS_8�
ValueErrorZ	_stopbitsZSTOPBITS_ONEZ
STOPBITS_1ZSTOPBITS_ONE_POINT_FIVEZSTOPBITS_1_5ZSTOPBITS_TWOZ
STOPBITS_2Z_parityZPARITY_NONEZPARITY_EVENZ
PARITY_ODDZPARITY_MARKZPARITY_SPACEZ_rtsctsZFLOWCONTROL_RTSCTS_INZFLOWCONTROL_RTSCTS_OUTZ_xonxoffZFLOWCONTROL_XONXOFF_INZFLOWCONTROL_XONXOFF_OUTZsetSerialPortParamsZ	_baudrateZsetFlowControlModeZ_timeout�intZdisableReceiveTimeout)r$Z	jdatabitsZ	jstopbitsZjparityZjflowinZjflowoutrrrr!RsT





















zSerial._reconfigurePortcCs:|jr6|jr0|j��|j��|j��d|_d|_dS)z
Close portNF)rrr"�closer#�r$rrrr)�s


zSerial.closecCs|js
t�|j��S)z>Return the number of characters currently in the input buffer.)r�portNotOpenErrorr"�	availabler*rrr�
in_waiting�szSerial.in_waitingrcCsX|js
t�t�}|dkrPt|�|krP|j��}|dkrD|jdkrNqPq|�|�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.
        r���)	rr+�	bytearray�lenr"�readZtimeoutr�bytes)r$�sizer1�xrrrr1�s

zSerial.readcCs@|js
t�t|ttf�s,tdtt|�f��|j�|�t	|�S)z-Output the given string over the serial port.z expected %s or bytearray, got %s)
rr+�
isinstancer2r/�	TypeErrorrr#�writer0)r$�datarrrr7�szSerial.writecCs |js
t�|j�|j���dS)z9Clear input buffer, discarding all that is in the buffer.N)rr+r"�skipr,r*rrr�reset_input_buffer�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)rr+r#�flushr*rrr�reset_output_buffer�szSerial.reset_output_buffer��?cCs|js
t�|j�|d�dS)zHSend break condition. Timed, returns to idle state after given duration.g@�@N)rr+Z	sendBreak)r$Zdurationrrr�
send_break�szSerial.send_breakcCs|jdkrt�td��dS)zBSet break: Controls TXD. When active, to transmitting is possible.Nz<The _update_break_state function is not implemented in java.)�fdr+rr*rrr�_update_break_state�s
zSerial._update_break_statecCs|js
t�|j�|j�dS)z)Set terminal status line: Request To SendN)rr+ZsetRTSZ
_rts_stater*rrr�_update_rts_state�szSerial._update_rts_statecCs|js
t�|j�|j�dS)z-Set terminal status line: Data Terminal ReadyN)rr+ZsetDTRZ
_dtr_stater*rrr�_update_dtr_state�szSerial._update_dtr_statecCs|js
t�|j��dS)z(Read terminal status line: Clear To SendN)rr+ZisCTSr*rrr�cts�sz
Serial.ctscCs|js
t�|j��dS)z)Read terminal status line: Data Set ReadyN)rr+ZisDSRr*rrr�dsr�sz
Serial.dsrcCs|js
t�|j��dS)z)Read terminal status line: Ring IndicatorN)rr+ZisRIr*rrr�ri�sz	Serial.ricCs|js
t�|j��dS)z)Read terminal status line: Carrier DetectN)rr+ZisCDr*rrr�cd�sz	Serial.cdN)r)r=)�__name__�
__module__�__qualname__�__doc__rr!r)�propertyr-r1r7r:r<r>r@rArBrCrDrErFrrrrr5s,7

		



rN)Zserial.serialutilr
rrrZ
SerialBaserrrrr�<module>
s�

Zerion Mini Shell 1.0