Skip to content

Commit c753455

Browse files
authored
Client/Server decoder renamed and moved to pdu. (#2390)
1 parent c868810 commit c753455

File tree

20 files changed

+167
-312
lines changed

20 files changed

+167
-312
lines changed

doc/source/roadmap.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ The following bullet points are what the maintainers focus on:
2121
- more typing in the core
2222
- 100% test coverage fixed for all new parts (currently transport and framer)
2323
- Updated PDU, moving client/server decoder into pdu
24-
- better broadcast handling
25-
- better broadcast handling
24+
- better client no_response handling
2625
- Simplify PDU classes
2726
- better retry handling (only disconnect when really needed)
2827
- 3.7.5, bug fix release, hopefully with:

examples/client_custom_msg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# Since the function code is already registered with the decoder factory,
2727
# this will be decoded as a read coil response. If you implement a new
2828
# method that is not currently implemented, you must register the request
29-
# and response with a ClientDecoder factory.
29+
# and response with a DecoderResponses factory.
3030
# --------------------------------------------------------------------------- #
3131

3232

examples/message_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
FramerRTU,
1818
FramerSocket,
1919
)
20-
from pymodbus.pdu import ClientDecoder, ServerDecoder
20+
from pymodbus.pdu import DecoderRequests, DecoderResponses
2121

2222

2323
_logger = logging.getLogger(__file__)
@@ -73,8 +73,8 @@ def decode(self, message):
7373
print(f"Decoding Message {value}")
7474
print("=" * 80)
7575
decoders = [
76-
self.framer(ServerDecoder()),
77-
self.framer(ClientDecoder()),
76+
self.framer(DecoderRequests()),
77+
self.framer(DecoderResponses()),
7878
]
7979
for decoder in decoders:
8080
print(f"{decoder.decoder.__class__.__name__}")

pymodbus/client/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pymodbus.exceptions import ConnectionException, ModbusIOException
1212
from pymodbus.framer import FRAMER_NAME_TO_CLASS, FramerBase, FramerType
1313
from pymodbus.logging import Log
14-
from pymodbus.pdu import ClientDecoder, ModbusPDU
14+
from pymodbus.pdu import DecoderResponses, ModbusPDU
1515
from pymodbus.transaction import SyncModbusTransactionManager
1616
from pymodbus.transport import CommParams
1717
from pymodbus.utilities import ModbusTransactionState
@@ -182,7 +182,7 @@ def __init__(
182182
self.slaves: list[int] = []
183183

184184
# Common variables.
185-
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(ClientDecoder())
185+
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(DecoderResponses())
186186
self.transaction = SyncModbusTransactionManager(
187187
self,
188188
self.retries,

pymodbus/client/modbusclientprotocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
FramerType,
1010
)
1111
from pymodbus.logging import Log
12-
from pymodbus.pdu import ClientDecoder
12+
from pymodbus.pdu import DecoderResponses
1313
from pymodbus.transaction import ModbusTransactionManager
1414
from pymodbus.transport import CommParams, ModbusProtocol
1515

@@ -35,7 +35,7 @@ def __init__(
3535
self.on_connect_callback = on_connect_callback
3636

3737
# Common variables.
38-
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(ClientDecoder())
38+
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(DecoderResponses())
3939
self.transaction = ModbusTransactionManager()
4040

4141
def _handle_response(self, reply):

pymodbus/framer/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from pymodbus.exceptions import ModbusIOException
1212
from pymodbus.logging import Log
13-
from pymodbus.pdu import ClientDecoder, ModbusPDU, ServerDecoder
13+
from pymodbus.pdu import DecoderRequests, DecoderResponses, ModbusPDU
1414

1515

1616
class FramerType(str, Enum):
@@ -30,7 +30,7 @@ class FramerBase:
3030

3131
def __init__(
3232
self,
33-
decoder: ClientDecoder | ServerDecoder,
33+
decoder: DecoderResponses | DecoderRequests,
3434
) -> None:
3535
"""Initialize a ADU (framer) instance."""
3636
self.decoder = decoder

pymodbus/pdu/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""Framer."""
22
__all__ = [
3-
"ClientDecoder",
3+
"DecoderRequests",
4+
"DecoderResponses",
45
"ExceptionResponse",
56
"ModbusExceptions",
67
"ModbusPDU",
7-
"ServerDecoder"
88
]
99

10-
from pymodbus.pdu.decoders import ClientDecoder, ServerDecoder
10+
from pymodbus.pdu.decoders import DecoderRequests, DecoderResponses
1111
from pymodbus.pdu.pdu import (
1212
ExceptionResponse,
1313
ModbusExceptions,

0 commit comments

Comments
 (0)