Skip to content

Commit

Permalink
Pymodbus 3.7.x changes part 2, cherry picking changes from #18
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoomakethu committed Aug 10, 2024
1 parent ebc76e2 commit 0b5bb58
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
3 changes: 0 additions & 3 deletions pymodbus_repl/client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pymodbus.exceptions import ParameterException
from pymodbus.transaction import (
ModbusAsciiFramer,
ModbusBinaryFramer,
ModbusRtuFramer,
ModbusSocketFramer,
)
Expand Down Expand Up @@ -363,8 +362,6 @@ def serial( # pylint: disable=too-many-arguments
framer = ModbusAsciiFramer
elif method == "rtu":
framer = ModbusRtuFramer
elif method == "binary":
framer = ModbusBinaryFramer
elif method == "socket":
framer = ModbusSocketFramer
else:
Expand Down
8 changes: 4 additions & 4 deletions pymodbus_repl/client/mclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pymodbus.client import ModbusSerialClient as _ModbusSerialClient
from pymodbus.client import ModbusTcpClient as _ModbusTcpClient
from pymodbus.client.base import ModbusBaseSyncClient as _ModbusBaseSyncClient
from pymodbus.diag_message import (
from pymodbus.pdu.diag_message import (
ChangeAsciiInputDelimiterRequest,
ClearCountersRequest,
ClearOverrunCountRequest,
Expand All @@ -27,11 +27,11 @@
ReturnSlaveNoResponseCountRequest,
)
from pymodbus.exceptions import ModbusIOException
from pymodbus.mei_message import (
from pymodbus.pdu.mei_message import (
ReadDeviceInformationRequest,
ReadDeviceInformationResponse,
)
from pymodbus.other_message import (
from pymodbus.pdu.other_message import (
GetCommEventCounterRequest,
GetCommEventCounterResponse,
GetCommEventLogRequest,
Expand All @@ -42,7 +42,7 @@
ReportSlaveIdResponse,
)
from pymodbus.pdu import ExceptionResponse, ModbusExceptions
from pymodbus.register_write_message import MaskWriteRegisterResponse
from pymodbus.pdu.register_write_message import MaskWriteRegisterResponse


def make_response_dict(resp):
Expand Down
4 changes: 1 addition & 3 deletions pymodbus_repl/lib/reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
)
from pymodbus.transaction import (
ModbusAsciiFramer,
ModbusBinaryFramer,
ModbusRtuFramer,
ModbusSocketFramer,
ModbusTlsFramer,
Expand All @@ -56,8 +55,7 @@
"rtu": ModbusRtuFramer,
"tls": ModbusTlsFramer,
"udp": ModbusSocketFramer,
"ascii": ModbusAsciiFramer,
"binary": ModbusBinaryFramer,
"ascii": ModbusAsciiFramer
}

DEFAULT_MANIPULATOR = {
Expand Down
11 changes: 5 additions & 6 deletions pymodbus_repl/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import typer
from pymodbus import pymodbus_apply_logging_config
from pymodbus.framer.socket_framer import ModbusSocketFramer
from pymodbus.transaction import ModbusSocketFramer
from pymodbus.logging import Log
from typing_extensions import Annotated

Expand Down Expand Up @@ -44,12 +44,11 @@ class ModbusServerTypes(str, Enum):
class ModbusFramerTypes(str, Enum):
"""Framer types."""

# ["socket", "rtu", "tls", "ascii", "binary"]
# ["socket", "rtu", "tls", "ascii"]
socket = "socket" # pylint: disable=invalid-name
rtu = "rtu" # pylint: disable=invalid-name
tls = "tls" # pylint: disable=invalid-name
ascii = "ascii" # pylint: disable=invalid-name
binary = "binary" # pylint: disable=invalid-name


def _completer(incomplete: str, valid_values: List[str]) -> List[str]:
Expand All @@ -62,13 +61,13 @@ def _completer(incomplete: str, valid_values: List[str]) -> List[str]:


def framers(incomplete: str) -> List[str]:
"""Return an autocompleted list of supported clouds."""
_framers = ["socket", "rtu", "tls", "ascii", "binary"]
"""Return an autocompleted list of supported servers."""
_framers = ["socket", "rtu", "tls", "ascii"]
return _completer(incomplete, _framers)


def servers(incomplete: str) -> List[str]:
"""Return an autocompleted list of supported clouds."""
"""Return an autocompleted list of supported servers."""
_servers = ["tcp", "serial", "tls", "udp"]
return _completer(incomplete, _servers)

Expand Down

0 comments on commit 0b5bb58

Please sign in to comment.