Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/serial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/serial/__pycache__/serialwin32.cpython-310.pyc
o

+�a_<O�@s`ddlmZddlZddlZddlmZddlZddlmZmZm	Z	m
Z
mZGdd�de�ZdS)�)�absolute_importN)�win32)�
SerialBase�SerialException�to_bytes�PortNotOpenError�SerialTimeoutExceptioncseZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	e
d
d��Zd;dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Ze
d"d#��Ze
d$d%��Ze
d&d'��Ze
d(d)��Zd<d,d-�Zd=d/d0�Ze
d1d2��Zd3d4�Zd5d6�Zd7d8�Zej j!d9d:��Z �Z"S)>�Serialz5Serial port implementation for Win32 based on ctypes.)�2�K�n����i,iXi�ii`	i�i�%iKi�i�i�cs,d|_d|_d|_tt|�j|i|��dS�N)�_port_handle�_overlapped_read�_overlapped_write�superr	�__init__)�self�args�kwargs��	__class__��4/usr/lib/python3/dist-packages/serial/serialwin32.pyrszSerial.__init__c	Cs�|jdur	td��|jrtd��|j}z|���d�r)t|dd��dkr)d|}Wn	ty3Ynwt�	|tj
tjBddtjtj
tjBd�|_|jtjkr]d|_td	�|jt�����zMt��|_t�dd
dd�|j_t��|_t�dddd�|j_t�|jdd�t��|_t�|jt�|j��|��t� |jtj!tj"Btj#Btj$B�Wnz	|�%�Wd|_�Yd|_�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.�COM��z\\.\rzcould not open port {!r}: {!r}��T)&�_portr�is_open�name�upper�
startswith�int�
ValueErrorr�
CreateFile�GENERIC_READ�
GENERIC_WRITE�
OPEN_EXISTING�FILE_ATTRIBUTE_NORMAL�FILE_FLAG_OVERLAPPEDr�INVALID_HANDLE_VALUE�format�portstr�ctypes�WinError�
OVERLAPPEDr�CreateEvent�hEventr�	SetupComm�COMMTIMEOUTS�_orgTimeouts�GetCommTimeouts�byref�_reconfigure_port�	PurgeComm�
PURGE_TXCLEAR�
PURGE_TXABORT�
PURGE_RXCLEAR�
PURGE_RXABORT�_close)r�portrrr�open#sf
"��

�



���
�
zSerial.opencCs�|jstd��t��}|jdurn|jdkrtj|_ntt|jd�d�|_	|jdkr;|j
dur;tt|j
d�d�|_|jdurAn|jdkrKtj|_ntt|jd�d�|_t�
|jt�|��t�|jtj�t��}t�|jt�|��|j|_|jtjkr�d|_n&|jtjkr�d|_n|jtjkr�d|_n|jtjkr�d	|_ntd
�|j���|jtj kr�tj!|_"d|_#n@|jtj$kr�tj%|_"d|_#n2|jtj&kr�tj'|_"d|_#n$|jtj(kr�tj)|_"d|_#n|jtj*kr�tj+|_"d|_#ntd�|j���|j,tj-k�rtj.|_/n |j,tj0k�rtj1|_/n|j,tj2k�rtj3|_/ntd�|j,���d|_4|j5du�rF|j6�r6tj7|_8n|j9�r=tj:ntj;|_8|j6|_<nQ|j5j=�sTtd
�|j5j=���|j5j>�rbtd�|j5j>���|j5j?du�rrtd�|j5j?���|j5j@du�r�td�|j5j@���|j5jA�r�td�|j5jA���tjB|_8d|_<|jC�r�tjD|_En|jF�r�tjGntjH|_E|jC|_I|jJ|_K|jJ|_Ld|_Md|_Nd|_OtjP|_QtjR|_St�T|jt�|���s�td�t�U����dS)z,Set communication parameters on opened port.z'Can only operate on a valid port handleNri�r ���rz%Unsupported number of data bits: {!r}zUnsupported parity mode: {!r}z%Unsupported number of stop bits: {!r}zQUnsupported value for RS485Settings.rts_level_for_tx: {!r} (only True is allowed)zRUnsupported value for RS485Settings.rts_level_for_rx: {!r} (only False is allowed)zPUnsupported value for RS485Settings.delay_before_tx: {!r} (only None is allowed)zPUnsupported value for RS485Settings.delay_before_rx: {!r} (only None is allowed)zJUnsupported value for RS485Settings.loopback: {!r} (only False is allowed)zCCannot configure port, something went wrong. Original message: {!r})Vrrrr8�_timeout�MAXDWORD�ReadIntervalTimeout�maxr'�ReadTotalTimeoutConstant�_inter_byte_timeout�_write_timeout�WriteTotalTimeoutConstant�SetCommTimeoutsr2r;�SetCommMask�EV_ERR�DCB�GetCommState�	_baudrate�BaudRate�	_bytesize�serial�FIVEBITS�ByteSize�SIXBITS�	SEVENBITS�	EIGHTBITSr(r0�_parity�PARITY_NONE�NOPARITY�Parity�fParity�PARITY_EVEN�
EVENPARITY�
PARITY_ODD�	ODDPARITY�PARITY_MARK�
MARKPARITY�PARITY_SPACE�SPACEPARITY�	_stopbits�STOPBITS_ONE�
ONESTOPBIT�StopBits�STOPBITS_ONE_POINT_FIVE�ONE5STOPBITS�STOPBITS_TWO�TWOSTOPBITS�fBinary�_rs485_mode�_rtscts�RTS_CONTROL_HANDSHAKE�fRtsControl�
_rts_state�RTS_CONTROL_ENABLE�RTS_CONTROL_DISABLE�fOutxCtsFlow�rts_level_for_tx�rts_level_for_rx�delay_before_tx�delay_before_rx�loopback�RTS_CONTROL_TOGGLE�_dsrdtr�DTR_CONTROL_HANDSHAKE�fDtrControl�
_dtr_state�DTR_CONTROL_ENABLE�DTR_CONTROL_DISABLE�fOutxDsrFlow�_xonxoff�fOutX�fInX�fNull�
fErrorChar�
fAbortOnError�XON�XonChar�XOFF�XoffChar�SetCommStater3)r�timeouts�comDCBrrrr<ds�











��
������
��

��zSerial._reconfigure_portcCs�|jdur>t�|j|j�|jdur |��t�|jj�d|_|jdur3|�	�t�|jj�d|_t�|j�d|_dSdS)zinternal close port helperN)
rrrPr9r�cancel_read�CloseHandler6r�cancel_write�rrrrrB�s



�z
Serial._closecCs|jr|��d|_dSdS)z
Close portFN)r#rBr�rrr�close�s
�zSerial.closecC�Dt��}t��}t�|jt�|�t�|��std�t�	����|j
S)z9Return the number of bytes currently in the input buffer.�ClearCommError failed ({!r}))r�DWORD�COMSTAT�ClearCommErrorrr2r;rr0r3�cbInQue�r�flags�comstatrrr�
in_waiting��
zSerial.in_waitingr c
	CsX|jst��|dkr�t�|jj�t��}t��}t�|j	t
�|�t
�|��s0td�
t
�����|jdkr;t|j|�n|}|dkr�t
�|�}t��}t�|j	||t
�|�t
�|j��}|spt��tjtjfvrptd�
t
�����t�|j	t
�|j�t
�|�d�}|s�t��tjkr�td�
t
�����|jd|j�}	t|	�St�}	t|	�St�}	t|	�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.
        rr�zReadFile failed ({!r})Tz!GetOverlappedResult failed ({!r})N)r#rr�
ResetEventrr6r�r�r�rr2r;rr0r3�timeout�minr��create_string_buffer�ReadFile�GetLastError�
ERROR_SUCCESS�ERROR_IO_PENDING�GetOverlappedResult�ERROR_OPERATION_ABORTED�raw�value�bytes)
r�sizer�r��n�buf�rc�read_ok�	result_ok�readrrrr�sH

�
���zSerial.readcCs|jst��t|�}|r�t��}t�|j|t|�t�	|�|j
�}|jdkr_|s:t��tj
tjfvr:td�t�����t�|j|j
t�	|�d�t��tjkrQ|jS|jt|�kr\td��|jS|rdtj
nt��}|tjtjtjfvrtdS|tj
tjfvr�t|�Std�t�����dS)z2Output the given byte string over the serial port.rzWriteFile failed ({!r})Tz
Write timeout)r#rrrr��	WriteFiler�lenr2r;rrNr�r�r�rr0r3r�r�r�r�ERROR_INVALID_USER_BUFFER�ERROR_NOT_ENOUGH_MEMORY)r�datar��success�	errorcoderrr�write/s0 

�zSerial.writecCs|jr
t�d�|jsdSdS)zb        Flush of file like objects. In this case, wait until all data
        is written.
        g�������?N)�out_waiting�time�sleepr�rrr�flushTs
�zSerial.flushcC�&|jst��t�|jtjtjB�dS)z9Clear input buffer, discarding all that is in the buffer.N)r#rrr=rr@rAr�rrr�reset_input_buffer_szSerial.reset_input_buffercCr�)zs        Clear output buffer, aborting the current output and discarding all
        that is in the buffer.
        N)r#rrr=rr>r?r�rrr�reset_output_buffereszSerial.reset_output_buffercCs2|jst��|jrt�|j�dSt�|j�dS)zBSet break: Controls TXD. When active, to transmitting is possible.N)r#r�_break_stater�SetCommBreakr�ClearCommBreakr�rrr�_update_break_statens
zSerial._update_break_statecC�.|jr
t�|jtj�dSt�|jtj�dS)z)Set terminal status line: Request To SendN)rxr�EscapeCommFunctionr�SETRTS�CLRRTSr�rrr�_update_rts_statew�zSerial._update_rts_statecCr�)z-Set terminal status line: Data Terminal ReadyN)r�rr�r�SETDTR�CLRDTRr�rrr�_update_dtr_state~r�zSerial._update_dtr_statecCs.|jst��t��}t�|jt�|��|jSr)	r#rrr��GetCommModemStatusrr2r;r�)r�statrrr�_GetCommModemStatus�s
zSerial._GetCommModemStatuscC�tj|��@dkS)z(Read terminal status line: Clear To Sendr)r�	MS_CTS_ONr�r�rrr�cts��z
Serial.ctscCr�)z)Read terminal status line: Data Set Readyr)r�	MS_DSR_ONr�r�rrr�dsr�r�z
Serial.dsrcCr�)z)Read terminal status line: Ring Indicatorr)r�
MS_RING_ONr�r�rrr�ri�r�z	Serial.ricCr�)z)Read terminal status line: Carrier Detectr)r�
MS_RLSD_ONr�r�rrr�cd�r�z	Serial.cdr!NcCs |dur|}t�|j||�dS)z�        Recommend a buffer size to the driver (device driver can ignore this
        value). Must be called after the port is opened.
        N)rr7r)r�rx_size�tx_sizerrr�set_buffer_size�szSerial.set_buffer_sizeTcCs8|jst��|rt�|jtj�dSt�|jtj�dS)a*        Manually control flow - when software flow control is enabled.
        This will do the same as if XON (true) or XOFF (false) are received
        from the other device and control the transmission accordingly.
        WARNING: this function is not portable to different platforms!
        N)r#rrr�r�SETXON�SETXOFF)r�enablerrr�set_output_flow_control�s
zSerial.set_output_flow_controlcCr�)z0Return how many bytes the in the outgoing bufferr�)rr�r�r�rr2r;rr0r3�cbOutQuer�rrrr��r�zSerial.out_waitingcCsXt��}t�|jt�|�t�|�d�}|s(t��tjtjfvr*t�	|j|�dSdSdS)�ACancel a blocking read operation, may be called from other threadFN)
rr�r�rr2r;r�r��ERROR_IO_INCOMPLETE�
CancelIoEx)r�
overlappedr��errrrr�_cancel_overlapped_io�s��zSerial._cancel_overlapped_iocC�|�|j�dS)r�N)r�rr�rrrr���zSerial.cancel_readcCr�)zBCancel a blocking write operation, may be called from other threadN)r�rr�rrrr��r�zSerial.cancel_writecCs.|dur
|s
td�|���tjj�||�dS)z$Change the exclusive access setting.Nz.win32 only supports exclusive access (not: {}))r(r0rXr�	exclusive�__set__)rr�rrrr��szSerial.exclusive)r )r!N)T)#�__name__�
__module__�__qualname__�__doc__�	BAUDRATESrrDr<rBr��propertyr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr��setter�
__classcell__rrrrr	sJA

)%		





	

r	)
�
__future__rr2r�rXr�serial.serialutilrrrrrr	rrrr�<module>s

Spamworldpro Mini