Skip to content

Commit

Permalink
Merge pull request #21 from pymodbus-dev/pymodbus-3.7-changes
Browse files Browse the repository at this point in the history
Sync with Pymodbus 3.7.x
  • Loading branch information
dhoomakethu authored Aug 11, 2024
2 parents 0808283 + 0b5bb58 commit b2e8d4c
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 426 deletions.
846 changes: 460 additions & 386 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 0 additions & 21 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 @@ -222,26 +221,11 @@ def run(self):
@click.group("pymodbus-repl")
@click.version_option(str(pymodbus_version), message=TITLE)
@click.option("--verbose", is_flag=True, default=False, help="Verbose logs")
@click.option(
"--broadcast-support",
is_flag=True,
default=False,
help="Support broadcast messages",
)
@click.option(
"--retry-on-empty", is_flag=True, default=False, help="Retry on empty response"
)
@click.option(
"--retry-on-error", is_flag=True, default=False, help="Retry on error response"
)
@click.option("--retries", default=3, help="Retry count")
@click.pass_context
def main(
ctx,
verbose,
broadcast_support,
retry_on_empty,
retry_on_error,
retries,
):
"""Run Main."""
Expand All @@ -253,9 +237,6 @@ def main(
logging.basicConfig(format=use_format)
_logger.setLevel(logging.DEBUG)
ctx.obj = {
"broadcast_enable": broadcast_support,
"retry_on_empty": retry_on_empty,
"retry_on_invalid": retry_on_error,
"retries": retries,
}

Expand Down Expand Up @@ -381,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
17 changes: 6 additions & 11 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 Expand Up @@ -101,9 +100,6 @@ def server(
ctx: typer.Context,
host: str = typer.Option("localhost", "--host", help="Host address"),
web_port: int = typer.Option(8080, "--web-port", help="Web app port"),
broadcast_support: bool = typer.Option(
False, "-b", help="Support broadcast messages"
),
repl: bool = typer.Option(True, help="Enable/Disable repl for server"),
verbose: bool = typer.Option(
False, help="Run with debug logs enabled for pymodbus"
Expand All @@ -116,8 +112,7 @@ def server(
ctx.obj = {
"repl": repl,
"host": host,
"web_port": web_port,
"broadcast_enable": broadcast_support,
"web_port": web_port
}


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages = [{include = "pymodbus_repl"}]
repository = "https://github.com/pymodbus-dev/repl"

[tool.poetry.dependencies]
python = "^3.8"
python = ">=3.9.0,<4.0"
typer = {extras = ["all"], version = "^0.9.0"}
prompt-toolkit = "^3.0.43"
pygments = "^2.17.2"
Expand Down

0 comments on commit b2e8d4c

Please sign in to comment.