HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/imh-python/lib/python3.9/site-packages/serial/__pycache__/serialcli.cpython-39.pyc
a

]�h�#�@sLddlmZddlZddlZddlTejejZdd�ZGdd�de	�Z
dS)�)�absolute_importN)�*cCstdd�|D��S)NcSsg|]}t|��qS�)�ord)�.0�xrr��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/serial/serialcli.py�
<listcomp>�z!as_byte_array.<locals>.<listcomp>)�sab)�stringrrr�
as_byte_arraysr
c@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�|jdurtd��|jr td��ztjj�|j�|_Wn<t	yr}z$d|_td|j|f��WYd}~n
d}~00|j
dur�d|_
|jdur�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��|jdur*tjjjj|j_nt	|jd�|j_|j
durXtjjjj|j_nt	|j
d�|j_z|j|j_
Wn0ty�}ztt|���WYd}~n
d}~00|jtkr�d|j_nJ|jtkr�d|j_n6|jtkr�d|j_n"|jtkr�d|j_ntd|j��|jtk�r*ttjjjd	�|j_n�|jtk�rHtjjjj|j_nh|jtk�rftjjjj|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�r
tjjj%j*|j_%ntd|j#��|j+�r:|j,�r:tjjj-j.|j_-nH|j+�rTtjjj-j/|j_-n.|j,�rntjjj-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)1rr�_timeoutrrrrZInfiniteTimeout�ReadTimeout�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=s\

"







zSerial._reconfigure_portcCsD|jr@|jr:z|j��Wntjjjy2Yn0d|_d|_dS)z
Close portNF)rr�CloserrrZInvalidOperationException�r$rrr�close�szSerial.closecCs|jst��|jjS)z>Return the number of characters currently in the input buffer.)r�PortNotOpenErrorrZBytesToReadr5rrr�
in_waiting�szSerial.in_waiting�cCsV|jst��t�}|rNz|�|j���WntjyBYqNYq0|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.
        r9)	rr7�	bytearray�appendrZReadByter�TimeoutException�bytes)r$�size�datarrr�read�s

zSerial.readcCsN|jst��z|j�t|�dt|��WntjyDtd��Yn0t|�S)z-Output the given string over the serial port.rz
Write timeout)	rr7rZWriter
�lenrr<ZSerialTimeoutException)r$r?rrr�write�szSerial.writecCs|jst��|j��dS)z9Clear input buffer, discarding all that is in the buffer.N)rr7rZDiscardInBufferr5rrrr#�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)rr7rZDiscardOutBufferr5rrr�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)rr7�boolZ_break_staterZ
BreakStater5rrr�_update_break_state�szSerial._update_break_statecCs|jst��t|j�|j_dS)z)Set terminal status line: Request To SendN)rr7rDrrZ	RtsEnabler5rrrr"�szSerial._update_rts_statecCs|jst��t|j�|j_dS)z-Set terminal status line: Data Terminal ReadyN)rr7rDrrZ	DtrEnabler5rrrr �szSerial._update_dtr_statecCs|jst��|jjS)z(Read terminal status line: Clear To Send)rr7rZ
CtsHoldingr5rrr�cts�sz
Serial.ctscCs|jst��|jjS)z)Read terminal status line: Data Set Ready)rr7rZ
DsrHoldingr5rrr�dsr�sz
Serial.dsrcCs|jst��dS)z)Read terminal status line: Ring IndicatorF)rr7r5rrr�ri�sz	Serial.ricCs|jst��|jjS)z)Read terminal status line: Carrier Detect)rr7rZ	CDHoldingr5rrr�cd�sz	Serial.cdN)r9)�__name__�
__module__�__qualname__�__doc__Z	BAUDRATESr&rr6�propertyr8r@rBr#rCrEr"r rFrGrHrIrrrrrs,H

	


r)�
__future__rrZSystem.IO.PortsZserial.serialutilZArrayZByterr
Z
SerialBaserrrrr�<module>
s