File: //snap/core22/2133/usr/lib/python3/dist-packages/serial/__pycache__/serialcli.cpython-310.pyc
o
��^_�# � @ sL d dl mZ d dlZd dlZd dlT ejej Zdd� ZG dd� de �Z
dS )� )�absolute_importN)�*c C s t dd� | D ��S )Nc S s g | ]}t |��qS � )�ord)�.0�xr r �2/usr/lib/python3/dist-packages/serial/serialcli.py�
<listcomp> s z!as_byte_array.<locals>.<listcomp>)�sab)�stringr r r �
as_byte_array s r c @ s� e Zd ZdZdZdd� Zdd� Zdd� Zed d
� �Z d#dd
�Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zedd� �Zedd� �Zedd� �Zed d!� �Zd"S )$�Serialz)Serial port implementation for .NET/Mono.)�2 �K �n � � �� i, iX i� i i` i� i�% i K i � i � i � c
C s� | j du r td��| jrtd��ztjj�| j�| _W n t y3 } zd| _td| j|f ��d}~ww | j
du r<d| _
| jdu rDd| _| �� | j�
� d| _| jsW| �� | 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)�_port�SerialException�is_open�System�IO�Ports�
SerialPort�portstr�_port_handle� Exception�
_rts_state�
_dtr_state�_reconfigure_port�Open�_dsrdtr�_update_dtr_state�_rtscts�_update_rts_state�reset_input_buffer)�self�msgr r r �open s.
��
zSerial.openc
C sp | j std��| jdu rtjjjj| j _n t | jd �| j _| j
du r,tjjjj| j _n t | j
d �| j _z| j| j _
W n tyN } ztt|���d}~ww | jtkrYd| j _n%| jtkrcd| j _n| jtkrmd| j _n| jtkrwd| j _ntd| j ��| jtkr�ttjjjd �| j _n?| jtkr�tjjjj| j _n1| jtkr�tjjjj| j _n#| jtkr�tjjjj | j _n| jt!kr�tjjjj"| j _ntd
| j ��| j#t$kr�tjjj%j&| j _%n#| j#t'kr�tjjj%j(| j _%n| j#t)kr�tjjj%j*| j _%ntd| j# ��| j+�r| j,�rtjjj-j.| j _-dS | j+�rtjjj-j/| j _-dS | j,�r,tjjj-j0| j _-dS ttjjj-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)1r r �_timeoutr r r r �InfiniteTimeout�ReadTimeout�int�_write_timeout�WriteTimeout� _baudrate�BaudRate�IOError�
ValueError�str� _bytesize�FIVEBITS�DataBits�SIXBITS� SEVENBITS� EIGHTBITS�_parity�PARITY_NONE�getattr�Parity�PARITY_EVEN�Even�
PARITY_ODD�Odd�PARITY_MARK�Mark�PARITY_SPACE�Space� _stopbits�STOPBITS_ONE�StopBits�One�STOPBITS_ONE_POINT_FIVE�OnePointFive�STOPBITS_TWO�Twor$ �_xonxoff� Handshake�RequestToSendXOnXOff�
RequestToSend�XOnXOff)r'