�
��^� � �d � d Z ddlmZ ddlZddlZ G d� de� Z G d� dej � Zy)z�The settings for RS485 are stored in a dedicated object that can be applied to
serial ports (where supported).
NOTE: Some implementations may only support a subset of the settings.
� )�absolute_importNc � � e Zd Z dd�Zy)�
RS485SettingsNc �J � || _ || _ || _ || _ || _ y �N)�rts_level_for_tx�rts_level_for_rx�loopback�delay_before_tx�delay_before_rx)�selfr r r
r r s �./usr/lib/python3/dist-packages/serial/rs485.py�__init__zRS485Settings.__init__ s+ � � !1��� 0��� ��
�.���.��� )TFFNN)�__name__�
__module__�__qualname__r � r r r r s � � "�"�� � �
/r r c �` � � e Zd ZdZ� fd�Z� fd�Zed� � Zej d� � Z� xZ S )�RS485a5 A subclass that replaces the write method with one that toggles RTS
according to the RS485 settings.
NOTE: This may work unreliably on some serial ports (control signals not
synchronized or delayed compared to data). Using delays may be
unreliable (varying times, larger than expected) as the OS may not
support very fine grained delays (no smaller than in the order of
tens of milliseconds).
NOTE: Some implementations support this natively. Better performance
can be expected when the native version is used.
NOTE: The loopback property is ignored by this implementation. The actual
behavior depends on the used hardware.
Usage:
ser = RS485(...)
ser.rs485_mode = RS485Settings(...)
ser.write(b'hello')
c �: �� t t | �
|i |�� d | _ y r )�superr r �_alternate_rs485_settings)r
�args�kwargs� __class__s �r r zRS485.__init__= s �� �
�e�T�#�T�4�V�4�)-��&r c � �� | j ��| j | j j � | j j �)t j
| j j � t t | �# |� t t | �' |