%PDF- %PDF-
Direktori : /snap/core20/2379/lib/python3/dist-packages/serial/__pycache__/ |
Current File : //snap/core20/2379/lib/python3/dist-packages/serial/__pycache__/serialjava.cpython-38.pyc |
U �;�V� � @ s@ d dl T dd� Zdd� Zeddg�Zdd � ZG d d� de�ZdS ) � )�*c C s2 t | �}| �d�}|dd � D ]}t||�}q|S )N�.� )� __import__�split�getattr)�name�modZ components�comp� r �3/usr/lib/python3/dist-packages/serial/serialjava.py� my_import s r c C sH | D ]6}zt |�}|j |W S ttfk r8 Y qX qtd��dS )z1try given list of modules and return that importsz/No Java Communications API implementation foundN)r � SerialPort�ImportError�AttributeError)�namesr r r r r �detect_java_comm s r z javax.commzgnu.ioc C sF t j�� }g }|�� r:|�� }|�� t jjkr|�|� q|| �� S )z%Turn a port number into a device name) �comm�CommPortIdentifierZgetPortIdentifiersZhasMoreElementsZnextElementZgetPortTypeZPORT_SERIAL�appendZgetName)Z portnumber�enumZportsZelr r r �device* s r c @ s� e Zd ZdZdd� Zdd� Zdd� Zedd � �Zd%dd�Z d d� Z dd� Zdd� Zd&dd�Z dd� Zdd� Zdd� Zedd� �Zedd� �Zed d!� �Zed"d#� �Zd$S )'�Serialz� Serial port class, implemented with Java Communications API and thus usable with jython and the appropriate java extension. c C s� | j dkrtd��| jr td��t| j �td�krBtj�| j �}ntj�t| j ��}z|�dd�| _ W n4 t k r� } zd| _ td| ��W 5 d}~X Y nX | �� | j �� | _ | j �� | _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.� zpython serial module� zCould not open port: %sT)Z_port�SerialException�is_open�typer r ZgetPortIdentifierr �open�sPort� Exception�_reconfigurePortZgetInputStream� _instreamZgetOutputStream� _outstream)�selfZportId�msgr r r r ; s zSerial.openc C s� | j std��| j �d� | jtkr.tjj}nJ| jtkrBtjj }n6| jt krVtjj}n"| jtkrjtjj }ntd| j ��| jtkr�tjj}n6| jtkr�tjj}n"| jtkr�tjj}ntd| j ��| jtkr�tjj}nb| jtkr�tjj}nN| jtkr�tjj}n:| jtk�rtjj}n$| jtk�r*tjj}ntd| j ��d }}| j�r`|tjjO }|tjjO }| j�r�|tjj O }|tjj!O }| j �"| j#|||� | j �$||B � | j%dk�r�| j �t&| j%d �� n | j �'� dS ) z,Set communication parameters on opened port.z'Can only operate on a valid port handle� zunsupported bytesize: %rz"unsupported number of stopbits: %rzunsupported parity type: %rr i� N)(r r ZenableReceiveTimeoutZ _bytesizeZFIVEBITSr r Z DATABITS_5ZSIXBITSZ DATABITS_6Z SEVENBITSZ DATABITS_7Z EIGHTBITSZ DATABITS_8� ValueErrorZ _stopbitsZSTOPBITS_ONEZ STOPBITS_1ZSTOPBITS_ONE_POINT_FIVEZSTOPBITS_1_5ZSTOPBITS_TWOZ STOPBITS_2Z_parityZPARITY_NONEZPARITY_EVENZ PARITY_ODDZPARITY_MARKZPARITY_SPACEZ_rtsctsZFLOWCONTROL_RTSCTS_INZFLOWCONTROL_RTSCTS_OUTZ_xonxoffZFLOWCONTROL_XONXOFF_INZFLOWCONTROL_XONXOFF_OUTZsetSerialPortParamsZ _baudrateZsetFlowControlModeZ_timeout�intZdisableReceiveTimeout)r$ Z jdatabitsZ jstopbitsZjparityZjflowinZjflowoutr r r r! R sT zSerial._reconfigurePortc C s: | j r6| jr0| j�� | j�� | j�� d| _d| _ dS )z Close portNF)r r r"