Skip to content

Commit

Permalink
Parameter "strict" is and was only used for serial server/client. (#1975
Browse files Browse the repository at this point in the history
)
  • Loading branch information
janiversen authored Feb 7, 2024
1 parent 3bfa2ad commit 6ca1b04
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def setup_async_client(description=None, cmdline=None):
# parity="N",
# stopbits=1,
# handle_local_echo=False,
# strict=True,
)
elif args.comm == "tls":
client = modbusClient.AsyncModbusTlsClient(
Expand All @@ -95,7 +96,6 @@ def setup_async_client(description=None, cmdline=None):
timeout=args.timeout,
# retries=3,
# retry_on_empty=False,
# strict=True,
# TLS setup parameters
# sslctx=sslctx,
certfile=helper.get_certificate("crt"),
Expand Down
2 changes: 1 addition & 1 deletion examples/client_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def setup_sync_client(description=None, cmdline=None):
# parity="N",
# stopbits=1,
# handle_local_echo=False,
# strict=True,
)
elif args.comm == "tls":
client = modbusClient.ModbusTlsClient(
Expand All @@ -101,7 +102,6 @@ def setup_sync_client(description=None, cmdline=None):
timeout=args.timeout,
# retries=3,
# retry_on_empty=False,
# strict=True,
# TLS setup parameters
# sslctx=None,
certfile=helper.get_certificate("crt"),
Expand Down
3 changes: 0 additions & 3 deletions examples/server_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ async def run_async_server(args):
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
# TBD strict=True, # use strict timing, t1.5 for Modbus RTU
)
elif args.comm == "udp":
address = (
Expand All @@ -174,7 +173,6 @@ async def run_async_server(args):
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
# TBD strict=True, # use strict timing, t1.5 for Modbus RTU
)
elif args.comm == "serial":
# socat -d -d PTY,link=/tmp/ptyp0,raw,echo=0,ispeed=9600
Expand Down Expand Up @@ -216,7 +214,6 @@ async def run_async_server(args):
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
# TBD strict=True, # use strict timing, t1.5 for Modbus RTU
)
return server

Expand Down
3 changes: 0 additions & 3 deletions examples/server_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def run_sync_server(args):
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
# TBD strict=True, # use strict timing, t1.5 for Modbus RTU
)
elif args.comm == "udp":
address = ("127.0.0.1", args.port) if args.port else None
Expand All @@ -84,7 +83,6 @@ def run_sync_server(args):
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
# TBD strict=True, # use strict timing, t1.5 for Modbus RTU
)
elif args.comm == "serial":
# socat -d -d PTY,link=/tmp/ptyp0,raw,echo=0,ispeed=9600
Expand Down Expand Up @@ -126,7 +124,6 @@ def run_sync_server(args):
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
# TBD strict=True, # use strict timing, t1.5 for Modbus RTU
)
return server

Expand Down
3 changes: 0 additions & 3 deletions examples/simple_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async def run_async_simple_client(comm, host, port, framer=Framer.SOCKET):
# timeout=10,
# retries=3,
# retry_on_empty=False,
# strict=True,
# source_address=("localhost", 0),
)
elif comm == "udp":
Expand All @@ -45,7 +44,6 @@ async def run_async_simple_client(comm, host, port, framer=Framer.SOCKET):
# timeout=10,
# retries=3,
# retry_on_empty=False,
# strict=True,
# source_address=None,
)
elif comm == "serial":
Expand All @@ -70,7 +68,6 @@ async def run_async_simple_client(comm, host, port, framer=Framer.SOCKET):
# timeout=10,
# retries=3,
# retry_on_empty=False,
# strict=True,
# sslctx=sslctx,
certfile="../examples/certificates/pymodbus.crt",
keyfile="../examples/certificates/pymodbus.key",
Expand Down
3 changes: 0 additions & 3 deletions examples/simple_sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def run_sync_simple_client(comm, host, port, framer=Framer.SOCKET):
# timeout=10,
# retries=3,
# retry_on_empty=False,y
# strict=True,
# source_address=("localhost", 0),
)
elif comm == "udp":
Expand All @@ -47,7 +46,6 @@ def run_sync_simple_client(comm, host, port, framer=Framer.SOCKET):
# timeout=10,
# retries=3,
# retry_on_empty=False,
# strict=True,
# source_address=None,
)
elif comm == "serial":
Expand All @@ -72,7 +70,6 @@ def run_sync_simple_client(comm, host, port, framer=Framer.SOCKET):
# timeout=10,
# retries=3,
# retry_on_empty=False,
# strict=True,
# sslctx=None,
certfile="../examples/certificates/pymodbus.crt",
keyfile="../examples/certificates/pymodbus.key",
Expand Down
6 changes: 1 addition & 5 deletions pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ class ModbusBaseSyncClient(ModbusClientMixin, ModbusProtocol):
:param timeout: Timeout for a request, in seconds.
:param retries: Max number of retries per request.
:param retry_on_empty: Retry on empty response.
:param strict: Strict timing, 1.5 character between requests.
:param broadcast_enable: True to treat id 0 as broadcast address.
:param reconnect_delay: Minimum delay in seconds.milliseconds before reconnecting.
:param reconnect_delay_max: Maximum delay in seconds.milliseconds before reconnecting.
Expand All @@ -302,21 +301,19 @@ class _params:

retries: int | None = None
retry_on_empty: bool | None = None
strict: bool | None = None
broadcast_enable: bool | None = None
reconnect_delay: int | None = None

source_address: tuple[str, int] | None = None

server_hostname: str | None = None

def __init__( # pylint: disable=too-many-arguments
def __init__(
self,
framer: Framer,
timeout: float = 3,
retries: int = 3,
retry_on_empty: bool = False,
strict: bool = True,
broadcast_enable: bool = False,
reconnect_delay: float = 0.1,
reconnect_delay_max: float = 300.0,
Expand Down Expand Up @@ -350,7 +347,6 @@ def __init__( # pylint: disable=too-many-arguments
self.params = self._params()
self.params.retries = int(retries)
self.params.retry_on_empty = bool(retry_on_empty)
self.params.strict = bool(strict)
self.params.broadcast_enable = bool(broadcast_enable)
self.retry_on_empty: int = 0
self.no_resend_on_retry = no_resend_on_retry
Expand Down
4 changes: 3 additions & 1 deletion pymodbus/client/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(
bytesize: int = 8,
parity: str = "N",
stopbits: int = 1,
strict: bool = True,
**kwargs: Any,
) -> None:
"""Initialize Modbus Serial Client."""
Expand All @@ -175,6 +176,7 @@ def __init__(
**kwargs,
)
self.socket = None
self.strict = bool(strict)

self.last_frame_end = None

Expand Down Expand Up @@ -211,7 +213,7 @@ def connect(self):
parity=self.comm_params.parity,
exclusive=True,
)
if self.params.strict:
if self.strict:
self.socket.interCharTimeout = self.inter_char_timeout
self.last_frame_end = None
except serial.SerialException as msg:
Expand Down
1 change: 0 additions & 1 deletion pymodbus/client/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class ModbusTcpClient(ModbusBaseSyncClient):
:param timeout: Timeout for a request, in seconds.
:param retries: Max number of retries per request.
:param retry_on_empty: Retry on empty response.
:param strict: Strict timing, 1.5 character between requests.
:param broadcast_enable: True to treat id 0 as broadcast address.
:param reconnect_delay: Minimum delay in seconds.milliseconds before reconnecting.
:param reconnect_delay_max: Maximum delay in seconds.milliseconds before reconnecting.
Expand Down
1 change: 0 additions & 1 deletion pymodbus/client/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class ModbusTlsClient(ModbusTcpClient):
:param timeout: Timeout for a request, in seconds.
:param retries: Max number of retries per request.
:param retry_on_empty: Retry on empty response.
:param strict: Strict timing, 1.5 character between requests.
:param broadcast_enable: True to treat id 0 as broadcast address.
:param reconnect_delay: Minimum delay in seconds.milliseconds before reconnecting.
:param reconnect_delay_max: Maximum delay in seconds.milliseconds before reconnecting.
Expand Down
1 change: 0 additions & 1 deletion pymodbus/client/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class ModbusUdpClient(ModbusBaseSyncClient):
:param timeout: Timeout for a request, in seconds.
:param retries: Max number of retries per request.
:param retry_on_empty: Retry on empty response.
:param strict: Strict timing, 1.5 character between requests.
:param broadcast_enable: True to treat id 0 as broadcast address.
:param reconnect_delay: Minimum delay in seconds.milliseconds before reconnecting.
:param reconnect_delay_max: Maximum delay in seconds.milliseconds before reconnecting.
Expand Down
2 changes: 0 additions & 2 deletions test/sub_client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def fake_execute(_self, request):
"timeout": 3 + 2,
"retries": 3 + 2,
"retry_on_empty": True,
"close_comm_on_error": True,
"strict": False,
"broadcast_enable": not False,
"reconnect_delay": 117,
Expand All @@ -131,7 +130,6 @@ def fake_execute(_self, request):
"timeout": 3,
"retries": 3,
"retry_on_empty": False,
"close_comm_on_error": False,
"strict": True,
"broadcast_enable": False,
"reconnect_delay": 100,
Expand Down

0 comments on commit 6ca1b04

Please sign in to comment.