404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.118.164.100: ~ $
3

M�]W�s�@sXddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZGdd�de�Zejj�Zedd�dkr�ddlZdZdZd	Zd
ZdZdZd
ZdZdZGdd�de�ZnZedkr�Gdd�de�Zn@edd�dk�rddlZdZGdd�de�ZnGdd�de�Ze edd�Z!e edd�Z"e edd�Z#e edd �Z$e ed!d
�Z%e ed"d�Z&e ed#d$�Z'e ed%d&�Z(e ed'd(�Z)e ed)d*�Z*e ed+e(�Z+e ed,e)�Z,e-ed-��r�ej.Z.ne ed.d/�Z.e ed0d1�Z/ej0d2d�Z1ej0d2e&�Z2ej0d2e%�Z3e ed3d4�Z4e ed5d6�Z5d7Z6Gd8d9�d9e
e�Z7Gd:d;�d;e7�Z8Gd<d=�d=e7�Z9dS)>�N)�
SerialBase�SerialException�to_bytes�portNotOpenError�writeTimeoutErrorc@s eZdZiZdd�Zdd�ZdS)�PlatformSpecificBasecCstd��dS)Nz9non-standard baudrates are not supported on this platform)�NotImplementedError)�self�baudrate�r�!/usr/lib/python3.6/serialposix.py�_set_special_baudrate.sz*PlatformSpecificBase._set_special_baudratecCstd��dS)Nz$RS485 not supported on this platform)r)r	�rs485_settingsrrr�_set_rs485_mode1sz$PlatformSpecificBase._set_rs485_modeN)�__name__�
__module__�__qualname__�BAUDRATE_CONSTANTSr
rrrrrr+sr��linuxl*TXi+T,@ii.Ti/T����c @s`eZdZddddddddd	d
ddd
ddddddddddddddddddd �Zd!d"�Zd#d$�Zd%S)&�PlatformSpecificrrr�rr����	�
���
��iiiiiiiii	i
iii
ii)r�2�K�n����i,iXi�ii`	i�i�%iKi�i�i�i�ii �i�ii@Bi�i`�i��i�%&i��-i�g5i	=cCs�tjddgd�}yXtj|jt|�|dtjM<|dtO<||d<|d<tj|jt|�Wn2t	k
r�}zt
dj||���WYdd}~XnXdS)N�ir�@rrr z'Failed to set custom baud rate ({}): {})�array�fcntl�ioctl�fd�TCGETS2�termiosZCBAUD�BOTHER�TCSETS2�IOError�
ValueError�format)r	r
�buf�errrr
lsz&PlatformSpecific._set_special_baudratecCsFtjddgd�}y�tj|jt|�|dtO<|dk	r�|jrT|dtO<n|dtM<|jr~|dt	O<n|dt	M<|j
r�|dtO<n|dtM<|jdk	r�t
|jd�|d<|jdk	r�t
|jd�|d<nd|d<tj|jt|�Wn2tk
�r@}ztdj|���WYdd}~XnXdS)Nr,rri�rrzFailed to set RS485 mode: {})r.r/r0r1�
TIOCGRS485�SER_RS485_ENABLEDZloopback�SER_RS485_RX_DURING_TXZrts_level_for_tx�SER_RS485_RTS_ON_SENDZrts_level_for_rx�SER_RS485_RTS_AFTER_SENDZdelay_before_tx�intZdelay_before_rx�
TIOCSRS485r6r7r8)r	rr9r:rrrr|s,

z PlatformSpecific._set_rs485_modeN)rrrrr
rrrrrrIsBr�cygwinc@s(eZdZddddddddd	d
dd�Zd
S)riiiii	i
iii
ii)i�i�i �i�ii@Bi�i`�i��i�%&i��-N)rrrrrrrrr�sr�darwinlTc@s6eZdZej�djd�Zeed�dkr2dd�ZdS)rr�.rrcCs$tjd|g�}tj|jt|d�dS)Nr,r)r.r/r0r1�IOSSIOSPEED)r	r
r9rrrr
�sz&PlatformSpecific._set_special_baudrateN)	rrr�os�uname�splitZosx_versionr@r
rrrrr�sc@seZdZdS)rN)rrrrrrrr�s�TIOCMGETiT�TIOCMBISiT�TIOCMBICiT�TIOCMSETiT�	TIOCM_DTR�	TIOCM_RTS�	TIOCM_CTS� �	TIOCM_CARr-�	TIOCM_RNG��	TIOCM_DSR��TIOCM_CD�TIOCM_RI�TIOCINQZFIONREADiT�TIOCOUTQiT�I�TIOCSBRKi'T�TIOCCBRKi(Ti@c@s�eZdZdZdd�Zd7dd�Zdd�Zed	d
��Zd8dd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd9dd�Zdd�Zdd �Zd!d"�Zed#d$��Zed%d&��Zed'd(��Zed)d*��Zed+d,��Zd-d.�Zd:d0d1�Zd;d2d3�Zd4d5�Zd6S)<�Serialz�    Serial port class POSIX implementation. Serial port configuration is
    done with termios and fcntl. Runs on Linux and many other Un*x like
    systems.
    c,Cs||jdkrtd��|jr td��d|_y"tj|jtjtjBtj	B�|_Wn>t
k
r�}z"d|_t|jdj|j|���WYdd}~XnXy|j
dd�Wn2ytj|j�WnYnXd|_�YnXd|_y |js�|j�|js�|j�Wn4tk
�r&}z|jdk�rn�WYdd}~XnX|j�tj�\|_|_tj�\|_|_tj|jtjtj	�tj|jtjtj	�dS)zo        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 {}: {}T)�force_update�)Z_portr�is_openr1rF�openZportstr�O_RDWR�O_NOCTTY�
O_NONBLOCK�OSError�errnor8�_reconfigure_port�closeZ_dsrdtr�_update_dtr_state�_rtscts�_update_rts_stater6�reset_input_buffer�pipe�pipe_abort_read_r�pipe_abort_read_w�pipe_abort_write_r�pipe_abort_write_wr/�F_SETFL)r	�msgr:rrrra�sD
"(zSerial.openFc,Cs~|jdkrtd��d}d}}|jdk	r:d}t|jd�}y"tj|j�}|\}}}}	}
}}Wn2tjk
r�}
ztdj|
���WYdd}
~
XnX|tjtj	BO}|	tj
tjBtjBtj
BtjBtjBtjBM}	x&dD]}tt|�r�|	tt|�M}	q�W|tjtjBtjBM}|tjtjBtjBtjBM}ttd	��rF|tjM}ttd
��r^|tjM}yttdj|j��}
}Wn�tk
�ry|j|j}
}Wnttk
�rttd�}
}yt|j�}Wn&t k
�r�t d
j|j���YnX|dk�rt d
j|j���YnXYnX|tj!M}|j"dk�r>|tj#O}nX|j"dk�rV|tj$O}n@|j"dk�rn|tj%O}n(|j"dk�r�|tj&O}nt dj|j"���|j't(j)k�r�|tj*M}nD|j't(j+k�r�|tj*O}n*|j't(j,k�r�|tj*O}nt dj|j'���|tj-tj.BM}|j/t(j0k�r*|tj1tj2BM}n�|j/t(j3k�rP|tj2M}|tj1O}n�|j/t(j4k�rp|tj1tj2BO}n�|j/t(j5k�r�t6dd�dk�r�|tj1t7Btj2BO}nL|j/t(j8k�r�t6dd�dk�r�|tj1t7BO}|tj2M}nt dj|j/���ttd��r2|j9�r|tj:tj;BO}n|tj:tj;Btj<BM}n,|j9�rL|tj:tj;BO}n|tj:tj;BM}ttd��r�|j=�r~|tj>O}n|tj>M}n,ttd��r�|j=�r�|tj?O}n|tj?M}|dk�s�|dk�r�t dj|���||tj@<|dk�s�|dk�rt dj|���||tjA<|�s.||||	|
||g|k�rNtjB|jtjC||||	|
||g�|dk	�rb|jD|�|jEdk	�rz|jF|jE�dS)z,Set communication parameters on opened port.Nz+Can only operate on a valid file descriptorrrr zCould not configure port: {}�ECHOCTL�ECHOKE�IUCLC�PARMRKzB{}ZB38400zInvalid baud rate: {!r}rrrrzInvalid char len: {!r}z$Invalid stop bit specification: {!r}rzInvalid parity: {!r}�IXANY�CRTSCTS�CNEW_RTSCTS�zInvalid vmin: {!r}zInvalid vtime: {!r})rtru)Gr1r�_inter_byte_timeoutr@r3�	tcgetattr�errorr8ZCLOCALZCREADZICANONZECHOZECHOEZECHOKZECHONLZISIGZIEXTEN�hasattr�getattrZOPOSTZONLCRZOCRNLZINLCRZIGNCRZICRNLZIGNBRKrvrwZ	_baudrate�AttributeErrorr�KeyErrorr7ZCSIZEZ	_bytesizeZCS8ZCS7ZCS6ZCS5Z	_stopbits�serialZSTOPBITS_ONEZCSTOPBZSTOPBITS_ONE_POINT_FIVEZSTOPBITS_TWOZINPCKZISTRIPZ_parityZPARITY_NONEZPARENBZPARODDZPARITY_EVENZ
PARITY_ODDZPARITY_MARK�plat�CMSPARZPARITY_SPACEZ_xonxoffZIXONZIXOFFrxrjryrz�VMIN�VTIME�	tcsetattr�TCSANOWr
Z_rs485_moder)r	r^Zcustom_baud�vmin�vtime�	orig_attr�iflag�oflag�cflag�lflag�ispeed�ospeed�ccrs�flagrrrrgs�

 .


  



zSerial._reconfigure_portcCst|jrp|jdk	rjtj|j�d|_tj|j�tj|j�tj|j�tj|j�d\|_|_d\|_|_d|_dS)z
Close portNF)NN)NN)r`r1rFrhrornrqrp)r	rrrrh�s
zSerial.closecCs tj|jtt�}tjd|�dS)z9Return the number of bytes currently in the input buffer.rZr)r/r0r1rX�TIOCM_zero_str�struct�unpack)r	�srrr�
in_waiting�szSerial.in_waitingrc	CsX|js
t�t�}|j}�x6t|�|k�rNyvtj�}tj|j|jggg|�\}}}|j|krjt	j
|jd�P|spPt	j
|j|t|��}|s�td��|j|�Wn�t
k
r�}z,|jtjkr�|jtjkr�tdj|���WYdd}~XnDtjk
�r(}z$|dtjk�rtdj|���WYdd}~XnX|dk	r|tj�|8}|dkrPqWt|�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.
        i�zgdevice reports readiness to read but returned no data (device disconnected or multiple access on port?)zread failed: {}Nr)r`r�	bytearray�_timeout�len�time�selectr1rnrF�readr�extendrerf�EAGAINZEINTRr8r~�bytes)	r	�sizer��timeoutZ
start_time�ready�_r9r:rrrr��s:
 zSerial.readcCstj|jd�dS)N�x)rF�writero)r	rrr�cancel_read�szSerial.cancel_readcCstj|jd�dS)Nr�)rFr�rq)r	rrr�cancel_write�szSerial.cancel_writecCs�|js
t�t|�}t|�}|j}|r8|dkr8|tj�7}�xT|dk�r�y�tj|j|�}|dkrb|S|r�|dkr�|tj�}|dkr�t	�t
j
|jg|jgg|�\}}}	|r�tj|jd�P|s�t	�n@t
j
|jg|jggd�\}}}	|r�tj|jd�P|�st
d��||d�}||8}Wq<t
k
�r0�Yq<tk
�r�}
z>|
jtjk�r^t
dj|
���|�rz|tj�dk�rzt	�WYdd}
~
Xq<Xq<Wt|�S)z2Output the given byte string over the serial port.ri�Nrzwrite failed (select)zwrite failed: {})r`rrr�Z_write_timeoutr�rFr�r1rr�rpr�rrerfr�r8)r	�data�dZtx_lenr��nZtimeleft�abortr�r��vrrrr��sLzSerial.writecCs|js
t�tj|j�dS)zb        Flush of file like objects. In this case, wait until all data
        is written.
        N)r`rr3Ztcdrainr1)r	rrr�flushszSerial.flushcCs|js
t�tj|jtj�dS)z9Clear input buffer, discarding all that is in the buffer.N)r`rr3�tcflushr1ZTCIFLUSH)r	rrrrl(szSerial.reset_input_buffercCs|js
t�tj|jtj�dS)zs        Clear output buffer, aborting the current output and discarding all
        that is in the buffer.
        N)r`rr3r�r1ZTCOFLUSH)r	rrr�reset_output_buffer.szSerial.reset_output_buffer��?cCs$|js
t�tj|jt|d��dS)za        Send break condition. Timed, returns to idle state after given
        duration.
        g�?N)r`rr3Ztcsendbreakr1r@)r	Zdurationrrr�
send_break7szSerial.send_breakcCs(|jrtj|jt�ntj|jt�dS)zS        Set break: Controls TXD. When active, no transmitting is possible.
        N)Z_break_stater/r0r1r[r\)r	rrr�_update_break_state@szSerial._update_break_statecCs,|jrtj|jtt�ntj|jtt�dS)z)Set terminal status line: Request To SendN)Z
_rts_stater/r0r1rJ�
TIOCM_RTS_strrK)r	rrrrkIszSerial._update_rts_statecCs,|jrtj|jtt�ntj|jtt�dS)z-Set terminal status line: Data Terminal ReadyN)Z
_dtr_stater/r0r1rJ�
TIOCM_DTR_strrK)r	rrrriPszSerial._update_dtr_statecCs2|js
t�tj|jtt�}tjd|�dt	@dkS)z(Read terminal status line: Clear To SendrZr)
r`rr/r0r1rIr�r�r�rO)r	r�rrr�ctsWsz
Serial.ctscCs2|js
t�tj|jtt�}tjd|�dt	@dkS)z)Read terminal status line: Data Set ReadyrZr)
r`rr/r0r1rIr�r�r�rT)r	r�rrr�dsr_sz
Serial.dsrcCs2|js
t�tj|jtt�}tjd|�dt	@dkS)z)Read terminal status line: Ring IndicatorrZr)
r`rr/r0r1rIr�r�r�rW)r	r�rrr�rigsz	Serial.ricCs2|js
t�tj|jtt�}tjd|�dt	@dkS)z)Read terminal status line: Carrier DetectrZr)
r`rr/r0r1rIr�r�r�rV)r	r�rrr�cdosz	Serial.cdcCs tj|jtt�}tjd|�dS)z:Return the number of bytes currently in the output buffer.rZr)r/r0r1rYr�r�r�)r	r�rrr�out_waitingyszSerial.out_waitingcCs|js
t�|jS)z�        For easier use of the serial port instance with select.
        WARNING: this function is not portable to different platforms!
        )r`rr1)r	rrr�fileno�sz
Serial.filenoTcCs4|js
t�|r tj|jtj�ntj|jtj�dS)z�        Manually control flow - when software flow control is enabled.
        This will send XON (true) or XOFF (false) to the other device.
        WARNING: this function is not portable to different platforms!
        N)r`rr3�tcflowr1ZTCIONZTCIOFF)r	�enablerrr�set_input_flow_control�s
zSerial.set_input_flow_controlcCs4|js
t�|r tj|jtj�ntj|jtj�dS)z�        Manually control flow of outgoing data - when hardware or software flow
        control is enabled.
        WARNING: this function is not portable to different platforms!
        N)r`rr3r�r1ZTCOONZTCOOFF)r	r�rrr�set_output_flow_control�s
zSerial.set_output_flow_controlcCsddl}|jdt�dS)zDEPRECATED - has no userNz0nonblocking() has no effect, already nonblocking)�warnings�warn�DeprecationWarning)r	r�rrr�nonblocking�szSerial.nonblockingN)F)r)r�)T)T)rrr�__doc__rargrh�propertyr�r�r�r�r�r�rlr�r�r�rkrir�r�r�r�r�r�r�r�r�rrrrr]�s4.

31		
		
	


r]c@seZdZdZddd�ZdS)�PosixPollSerialz�    Poll based read implementation. Not all systems support poll properly.
    However this one has better handling of errors, such as a device
    disconnecting while it's in use (e.g. USB-serial unplugged).
    rcCs�|js
t�t�}tj�}|j|jtjtjBtj	Btj
B�|dkr�x�t|�|kr�x:|j|jd�D]&\}}|tjtj	Btj
B@rbt
d��qbWtj|j|t|��}|j|�|jdk	r�|jdks�|jdk	rD|jdkrD|rDPqDWt|�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.
        ri�zdevice reports error (poll)N)r`rr�r��poll�registerr1ZPOLLINZPOLLERRZPOLLHUPZPOLLNVALr�r�rrFr�r�r|r�)r	r�r�r�r1Zeventr9rrrr��s "
zPosixPollSerial.readN)r)rrrr�r�rrrrr��sr�cs,eZdZdZd�fdd�	Zd	dd�Z�ZS)
�VTIMESeriala    Implement timeout using vtime of tty device instead of using select.
    This means that no inter character timeout can be specified and that
    the error handling is degraded.

    Overall timeout is disabled when inter-character timeout is used.
    Tc
s�tt|�j�tj|jtjd�|jdk	r>d}t|jd�}nd}t|jd�}y"t	j
|j�}|\}}}}}	}
}Wn4t	jk
r�}ztj
dj|���WYdd}~XnX|dks�|dkr�tdj|���||t	j<||t	j<t	j|jt	j|||||	|
|g�dS)z,Set communication parameters on opened port.rNrr zCould not configure port: {}r{zInvalid vtime: {!r})�superr�rgr/r1rrr|r@r�r3r}r~r�rr8r7r�r�r�r�)
r	r^r�r�r�r�r�r�r�r�r�r�rs)�	__class__rrrg�s(
"

zVTIMESerial._reconfigure_portrcCsP|js
t�t�}x6t|�|krFtj|j|t|��}|s:P|j|�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.
        )	r`rr�r�rFr�r1r�r�)r	r�r�r9rrrr��szVTIMESerial.read)T)r)rrrr�rgr��
__classcell__rr)r�rr��sr�):rfr/rFr�r��sysr3r�r�Zserial.serialutilrrrrr�objectr�platform�lowerr�r.r2r5r4r;rAr<r>r?r=rrEr�rIrJrKrLrMrNrOrQrRrTrVrWrrXrY�packr�r�r�r[r\r�r]r�r�rrrr�<module>st
P
J#

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 2 KB 0644
__init__.cpython-36.pyc File 2 KB 0644
aio.cpython-36.opt-1.pyc File 14 KB 0644
aio.cpython-36.pyc File 14.18 KB 0644
rfc2217.cpython-36.opt-1.pyc File 31.88 KB 0644
rfc2217.cpython-36.pyc File 31.88 KB 0644
rs485.cpython-36.opt-1.pyc File 2.72 KB 0644
rs485.cpython-36.pyc File 2.72 KB 0644
serialcli.cpython-36.opt-1.pyc File 6.45 KB 0644
serialcli.cpython-36.pyc File 6.45 KB 0644
serialjava.cpython-36.opt-1.pyc File 7.08 KB 0644
serialjava.cpython-36.pyc File 7.08 KB 0644
serialposix.cpython-36.opt-1.pyc File 18.69 KB 0644
serialposix.cpython-36.pyc File 18.72 KB 0644
serialutil.cpython-36.opt-1.pyc File 16.04 KB 0644
serialutil.cpython-36.pyc File 16.04 KB 0644
serialwin32.cpython-36.opt-1.pyc File 12.11 KB 0644
serialwin32.cpython-36.pyc File 12.11 KB 0644
win32.cpython-36.opt-1.pyc File 6.15 KB 0644
win32.cpython-36.pyc File 6.15 KB 0644