Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pymodbus/transport/transport_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, loop, protocol, *args, **kwargs):
"""Initialize."""
super().__init__()
self.async_loop = loop
self._protocol = protocol
self._protocol: asyncio.BaseProtocol = protocol
self.sync_serial = serial.serial_for_url(*args, **kwargs)
self._closing = False
self._write_buffer = []
Expand All @@ -37,7 +37,7 @@ def __init__(self, loop, protocol, *args, **kwargs):
@property
def loop(self):
"""Return asyncio event loop."""
return self._protocol.loop
return self.async_loop

def get_protocol(self) -> asyncio.BaseProtocol:
"""Return protocol"""
Expand Down Expand Up @@ -95,7 +95,7 @@ def _read_ready(self):
try:
data = self.sync_serial.read(1024)
except serial.SerialException as exc:
self._protocol.loop.call_soon(self._call_connection_lost, exc)
self.async_loop.call_soon(self._call_connection_lost, exc)
self.close()
else:
if data:
Expand Down Expand Up @@ -130,7 +130,7 @@ def _write_ready(self):
except (BlockingIOError, InterruptedError):
self._write_buffer.append(data)
except serial.SerialException as exc:
self._protocol.loop.call_soon(self._call_connection_lost, exc)
self.async_loop.call_soon(self._call_connection_lost, exc)
self.abort()
else:
if nlen == len(data):
Expand Down