0x1949 Team - FAZEMRX - MANAGER
Edit File: serialwin32.cpython-310.pyc
o +�a_<O � @ s` d dl mZ d dlZd dlZd dlmZ d dlZd dlmZmZm Z m Z mZ G dd� de�ZdS )� )�absolute_importN)�win32)� SerialBase�SerialException�to_bytes�PortNotOpenError�SerialTimeoutExceptionc s e Zd ZdZdZ� fdd�Zdd� Zdd� Zd d � Zdd� Z e d d� �Zd;dd�Zdd� 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, iX i� i i` i� i�% i K i � i � i � c s, d | _ d | _d | _tt| �j|i |�� d S �N)�_port_handle�_overlapped_read�_overlapped_write�superr �__init__)�self�args�kwargs�� __class__� �4/usr/lib/python3/dist-packages/serial/serialwin32.pyr s zSerial.__init__c C s� | j du r td��| jrtd��| j}z|�� �d�r)t|dd� �dkr)d| }W n ty3 Y nw t� |tj tjB ddtjtj tjB d�| _| jtjkr]d| _td �| jt�� ���zMt�� | _t�dd dd�| j_t�� | _t�dddd�| j_t�| jdd� t�� | _t�| jt�| j�� | �� t� | jtj!tj"B tj#B tj$B � W n z | �%� W d| _� Y d| _� 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\\.\r zcould 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 �portr r r �open# sf "�� � ��� � zSerial.openc C s� | j std��t�� }| jdu rn| jdkrtj|_ntt| jd �d�|_ | jdkr;| j dur;tt| j d �d�|_| jdu rAn| jdkrKtj|_ntt| jd �d�|_t� | j t�|�� t�| j tj� t�� }t�| j t�|�� | 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| j t�|���s�td�t�U� ���dS )z,Set communication parameters on opened port.z'Can only operate on a valid port handleNr i� r � � � r z%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})Vr r r r8 �_timeout�MAXDWORD�ReadIntervalTimeout�maxr'