HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/internet/__pycache__/_win32serialport.cpython-38.pyc
U


W[��@s�dZddlmZmZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlZddlm
Z
dd	lmZGd
d�dee
j�ZdS)zB
Serial port support for Windows.

Requires PySerial and pywin32.
�)�division�absolute_import)�PARITY_NONE)�STOPBITS_ONE)�	EIGHTBITS)�to_bytesN)�abstract)�BaseSerialPortc@sZeZdZdZdZdeeeddfdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�ZdS)�
SerialPortz@A serial device, acting as a transport, that uses a win32 event.�i�%rc


Cs�|j|||||d||	d�|_|��|��||_||_g|_d|_d|_d|_	||_t
��|_t
�dddd�|j_t
��|_t
�dddd�|j_|j�|jj|d�|j�|jj|d�|j�|�|��dS)N)�baudrate�bytesize�parity�stopbitsZtimeout�xonxoff�rtsctsrr�serialReadEvent�serialWriteEvent)Z_serialFactory�_serialZ
flushInputZflushOutput�reactor�protocol�outQueue�closedZclosedNotifies�writeInProgress�	win32fileZ
OVERLAPPED�_overlappedRead�
win32eventZCreateEvent�hEvent�_overlappedWriteZaddEventZmakeConnection�_finishPortSetup)
�selfrZdeviceNameOrPortNumberrrr
rrrr�r!�C/usr/lib/python3/dist-packages/twisted/internet/_win32serialport.py�__init__!s6�

zSerialPort.__init__cCs0|��\}}t�|jjt�d�|j�\}|_dS)zn
        Finish setting up the serial port.

        This is a separate method to facilitate testing.
        rN)�_clearCommErrorr�ReadFiler�_port_handle�AllocateReadBufferr�read_buf)r �flags�comstat�rcr!r!r"r>s

�zSerialPort._finishPortSetupcCst�|jj�S)N)rZClearCommErrorrr&)r r!r!r"r$JszSerialPort._clearCommErrorcCs�t�|jj|jd�}t|jd|��}|��\}}|jr�t	�
|jj�t�|jjt�
|j�|j�\}}t�|jj|jd�}|j�|t|d|���n|j�|�t	�
|jj�t�|jjt�
d�|j�\}|_dS)Nrr)rZGetOverlappedResultrr&rrr(r$ZcbInQuerZ
ResetEventrr%r'rZdataReceived)r �n�firstr)r*r+Zbufr!r!r"rNs"

�
�zSerialPort.serialReadEventcCs6|r2|jr|j�|�nd|_t�|jj||j�dS)Nr)rr�appendr�	WriteFilerr&r)r �datar!r!r"�writegs
zSerialPort.writecCsFz|j�d�}Wntk
r,d|_YdSXt�|jj||j�dS)Nr)	r�pop�
IndexErrorrrr/rr&r)r ZdataToWriter!r!r"rpszSerialPort.serialWriteEventcCsH|j�|jj�|j�|jj�tj�||�|j�	�|j
�|�dS)z�
        Called when the serial port disconnects.

        Will call C{connectionLost} on the protocol that is handling the
        serial data.
        N)rZremoveEventrrrr�FileDescriptor�connectionLostr�closer)r �reasonr!r!r"r5zs

zSerialPort.connectionLostN)�__name__�
__module__�__qualname__�__doc__Z	connectedrrrr#rr$rr1rr5r!r!r!r"r
s�
	
r
)r;Z
__future__rr�serialrrrZserial.serialutilrrrZtwisted.internetrZtwisted.internet.serialportr	r4r
r!r!r!r"�<module>s