44
55from serial_asyncio import create_serial_connection
66
7- from pymodbus .client .base import ModbusClientProtocol
87from pymodbus .framer import ModbusFramer
9- from pymodbus .transaction import ModbusRtuFramer
10- from pymodbus .client .base import ModbusBaseClient
8+ from pymodbus .framer . rtu_framer import ModbusRtuFramer
9+ from pymodbus .client .base import ModbusBaseClient , ModbusClientProtocol
1110from pymodbus .constants import Defaults
1211
1312_logger = logging .getLogger (__name__ )
@@ -67,7 +66,7 @@ def __init__(
6766
6867 async def close (self ): # pylint: disable=invalid-overridden-method
6968 """Stop connection."""
70- if self ._connected and self .protocol and self .protocol .transport :
69+ if self .connected and self .protocol and self .protocol .transport :
7170 self .protocol .transport .close ()
7271
7372 def _create_protocol (self ):
@@ -77,7 +76,7 @@ def _create_protocol(self):
7776 return protocol
7877
7978 @property
80- def _connected (self ):
79+ def connected (self ):
8180 """Connect internal."""
8281 return self ._connected_event .is_set ()
8382
@@ -108,15 +107,15 @@ async def connect(self): # pylint: disable=invalid-overridden-method
108107 def protocol_made_connection (self , protocol ):
109108 """Notify successful connection."""
110109 _logger .info ("Serial connected." )
111- if not self ._connected :
110+ if not self .connected :
112111 self ._connected_event .set ()
113112 self .protocol = protocol
114113 else :
115114 _logger .error ("Factory protocol connect callback called while connected." )
116115
117116 def protocol_lost_connection (self , protocol ):
118117 """Notify lost connection."""
119- if self ._connected :
118+ if self .connected :
120119 _logger .info ("Serial lost connection." )
121120 if protocol is not self .protocol :
122121 _logger .error (
0 commit comments