Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client/Server decoder renamed, typed and moved to pdu. #2390

Merged
merged 12 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions doc/source/roadmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ The following bullet points are what the maintainers focus on:
- more typing in the core
- 100% test coverage fixed for all new parts (currently transport and framer)
- Updated PDU, moving client/server decoder into pdu
- better broadcast handling
- better broadcast handling
- better client no_response handling
- Simplify PDU classes
- better retry handling (only disconnect when really needed)
- 3.7.5, bug fix release, hopefully with:
Expand Down
2 changes: 1 addition & 1 deletion examples/client_custom_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Since the function code is already registered with the decoder factory,
# this will be decoded as a read coil response. If you implement a new
# method that is not currently implemented, you must register the request
# and response with a ClientDecoder factory.
# and response with a DecoderResponses factory.
# --------------------------------------------------------------------------- #


Expand Down
6 changes: 3 additions & 3 deletions examples/message_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
FramerRTU,
FramerSocket,
)
from pymodbus.pdu import ClientDecoder, ServerDecoder
from pymodbus.pdu import DecoderRequests, DecoderResponses


_logger = logging.getLogger(__file__)
Expand Down Expand Up @@ -73,8 +73,8 @@ def decode(self, message):
print(f"Decoding Message {value}")
print("=" * 80)
decoders = [
self.framer(ServerDecoder()),
self.framer(ClientDecoder()),
self.framer(DecoderRequests()),
self.framer(DecoderResponses()),
]
for decoder in decoders:
print(f"{decoder.decoder.__class__.__name__}")
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pymodbus.exceptions import ConnectionException, ModbusIOException
from pymodbus.framer import FRAMER_NAME_TO_CLASS, FramerBase, FramerType
from pymodbus.logging import Log
from pymodbus.pdu import ClientDecoder, ModbusPDU
from pymodbus.pdu import DecoderResponses, ModbusPDU
from pymodbus.transaction import SyncModbusTransactionManager
from pymodbus.transport import CommParams
from pymodbus.utilities import ModbusTransactionState
Expand Down Expand Up @@ -182,7 +182,7 @@ def __init__(
self.slaves: list[int] = []

# Common variables.
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(ClientDecoder())
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(DecoderResponses())
self.transaction = SyncModbusTransactionManager(
self,
self.retries,
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/client/modbusclientprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
FramerType,
)
from pymodbus.logging import Log
from pymodbus.pdu import ClientDecoder
from pymodbus.pdu import DecoderResponses
from pymodbus.transaction import ModbusTransactionManager
from pymodbus.transport import CommParams, ModbusProtocol

Expand All @@ -35,7 +35,7 @@ def __init__(
self.on_connect_callback = on_connect_callback

# Common variables.
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(ClientDecoder())
self.framer: FramerBase = (FRAMER_NAME_TO_CLASS[framer])(DecoderResponses())
self.transaction = ModbusTransactionManager()

def _handle_response(self, reply):
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/framer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pymodbus.exceptions import ModbusIOException
from pymodbus.logging import Log
from pymodbus.pdu import ClientDecoder, ModbusPDU, ServerDecoder
from pymodbus.pdu import DecoderRequests, DecoderResponses, ModbusPDU


class FramerType(str, Enum):
Expand All @@ -30,7 +30,7 @@ class FramerBase:

def __init__(
self,
decoder: ClientDecoder | ServerDecoder,
decoder: DecoderResponses | DecoderRequests,
) -> None:
"""Initialize a ADU (framer) instance."""
self.decoder = decoder
Expand Down
6 changes: 3 additions & 3 deletions pymodbus/pdu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Framer."""
__all__ = [
"ClientDecoder",
"DecoderRequests",
"DecoderResponses",
"ExceptionResponse",
"ModbusExceptions",
"ModbusPDU",
"ServerDecoder"
]

from pymodbus.pdu.decoders import ClientDecoder, ServerDecoder
from pymodbus.pdu.decoders import DecoderRequests, DecoderResponses
from pymodbus.pdu.pdu import (
ExceptionResponse,
ModbusExceptions,
Expand Down
Loading