Skip to content

Commit

Permalink
Merge branch 'dev' to define v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Oct 12, 2022
2 parents 5f14caa + ca3d0da commit d7834ac
Show file tree
Hide file tree
Showing 40 changed files with 92 additions and 389 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
version 3.0.0
----------------------------------------------------------
* Solve multiple incomming frames. (#1107)
* Up coverage, tests are 100%. (#1098)
* Prepare for rc1. (#1097)
* Prepare 3.0.0dev5 (#1095)
* Adapt serial tests. (#1094)
* Allow windows. (#1093)

version 3.0.0dev5
----------------------------------------------------------
* Remove server sync code and combine with async code. (#1092)
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Supported versions

Version `2.5.3 <https://github.com/riptideio/pymodbus/releases/tag/v2.5.3>`_ is the last 2.x release (Supports python 2.7.x - 3.7).

Version `3.0.0dev5 <https://github.com/riptideio/pymodbus/releases/tag/v3.0.0dev5>`_ is the current prerelease of 3.0.0 (Supports Python >=3.8).
Version `3.0.0 <https://github.com/riptideio/pymodbus/releases/tag/v3.0.0>`_ is the latest release of 3.0.0 (Supports Python >=3.8).

Remark: "Supports" means that we only test with those versions, lower versions (e.g. 3.7) might work depending on the functionality used.

Expand Down Expand Up @@ -135,6 +135,8 @@ If you think, that something in the code is broken/not running well, please `ope
Pymodbus REPL (Read Evaluate Print Loop)
------------------------------------------------------------

**Warning** The Pymodbus REPL documentation is not updated.

~~~~~~~~~~~~~~~~~~~~~
Pymodbus REPL Client
~~~~~~~~~~~~~~~~~~~~~
Expand Down
13 changes: 0 additions & 13 deletions pymodbus/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,6 @@ def __init__(self, string=""):
ModbusException.__init__(self, message)


class TimeOutException(ModbusException):
"""Error resulting from modbus response timeout."""

def __init__(self, string=""):
"""Initialize the exception.
:param string: The message to append to the error
"""
message = f"[Timeout] {string}"
ModbusException.__init__(self, message)


# --------------------------------------------------------------------------- #
# Exported symbols
# --------------------------------------------------------------------------- #
Expand All @@ -130,5 +118,4 @@ def __init__(self, string=""):
"NoSuchSlaveException",
"InvalidMessageReceivedException",
"MessageRegisterException",
"TimeOutException",
]
28 changes: 16 additions & 12 deletions pymodbus/framer/rtu_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,25 @@ def processIncomingPacket(
unit = [unit]
self.addToFrame(data)
single = kwargs.get("single", False)
if self.isFrameReady():
if self.checkFrame():
if self._validate_unit_id(unit, single):
self._process(callback)
while True:
if self.isFrameReady():
if self.checkFrame():
if self._validate_unit_id(unit, single):
self._process(callback)
else:
header_txt = self._header["uid"]
txt = f"Not a valid unit id - {header_txt}, ignoring!!"
_logger.debug(txt)
self.resetFrame()
break
else:
header_txt = self._header["uid"]
txt = f"Not a valid unit id - {header_txt}, ignoring!!"
_logger.debug(txt)
_logger.debug("Frame check failed, ignoring!!")
self.resetFrame()
break
else:
_logger.debug("Frame check failed, ignoring!!")
self.resetFrame()
else:
txt = f"Frame - [{data}] not ready"
_logger.debug(txt)
txt = f"Frame - [{data}] not ready"
_logger.debug(txt)
break

def buildPacket(self, message):
"""Create a ready to send modbus packet.
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/repl/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pymodbus.framer.socket_framer import ModbusSocketFramer
from pymodbus.repl.server.cli import run_repl
from pymodbus.server.reactive.default_config import DEFUALT_CONFIG
from pymodbus.server.reactive.default_config import DEFAULT_CONFIG
from pymodbus.server.reactive.main import (
DEFAULT_FRAMER,
DEFUALT_HANDLERS,
Expand Down Expand Up @@ -161,7 +161,7 @@ def run(
with open(modbus_config) as my_file: # pylint: disable=unspecified-encoding
modbus_config = json.load(my_file)
else:
modbus_config = DEFUALT_CONFIG
modbus_config = DEFAULT_CONFIG

modbus_config = modbus_config.get(modbus_server, {})

Expand Down
2 changes: 1 addition & 1 deletion pymodbus/server/reactive/default_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Configuration for Pymodbus REPL Reactive Module."""

DEFUALT_CONFIG = { # pylint: disable=consider-using-namedtuple-or-dataclass
DEFAULT_CONFIG = { # pylint: disable=consider-using-namedtuple-or-dataclass
"tcp": {
"handler": "ModbusConnectedRequestHandler",
"allow_reuse_address": True,
Expand Down
12 changes: 8 additions & 4 deletions pymodbus/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ def __init__(self, package, major, minor, micro, pre=None):

def short(self):
"""Return a string in canonical short version format: <major>.<minor>.<micro>.<pre>."""
pre = ""
if self.pre:
return f"{self.major}.{self.minor}.{self.micro}.{self.pre}"
return f"{self.major}.{self.minor}.{self.micro}"
pre = f".{self.pre}"
return f"{self.major}.{self.minor}.{self.micro}{pre}"

def __str__(self):
"""Return a string representation of the object.
Expand All @@ -36,13 +37,16 @@ def __str__(self):
return f"[{self.package}, version {self.short()}]"


version = Version("pymodbus", 3, 0, 0, "dev5")
version = Version("pymodbus", 3, 0, 0, "rc1")
version.__name__ = ( # fix epydoc error # pylint: disable=attribute-defined-outside-init
"pymodbus"
)


# --------------------------------------------------------------------------- #
# Exported symbols
# --------------------------------------------------------------------------- #

__all__ = ["version"]
__all__ = [
"version"
]
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ url = https://github.com/riptideio/pymodbus/
classifiers =
Development Status :: 4 - Beta
Environment :: Console
Framework :: Twisted
Framework :: AsyncIO
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Expand Down
29 changes: 1 addition & 28 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import functools
import platform

from pkg_resources import parse_version
import pytest

from pymodbus.interfaces import IModbusSlaveContext
Expand All @@ -13,15 +12,6 @@ def pytest_configure():
pytest.IS_DARWIN = platform.system().lower() == "darwin"
pytest.IS_WINDOWS = platform.system().lower() == "windows"

if pytest.IS_DARWIN:
# check for SIERRA
if parse_version("10.12") < parse_version(platform.mac_ver()[0]):
pytest.SERIAL_PORT = "/dev/ptyp0"
else:
pytest.SERIAL_PORT = "/dev/ttyp0"
else:
pytest.SERIAL_PORT = "/dev/ptmx"


# -----------------------------------------------------------------------#
# Generic fixtures
Expand Down Expand Up @@ -81,9 +71,8 @@ def __len__(self):
"""Get length."""
return self.size

def __iter__(self): # pylint: disable=non-iterator-returned
def __iter__(self):
"""Iterate."""
return []


class mockSocket: # pylint: disable=invalid-name
Expand All @@ -110,10 +99,6 @@ def mock_retrieve(self, size):
self.data = None
return retval

def fileno(self):
"""File number."""
return 0

def close(self):
"""Close."""
return True
Expand All @@ -131,11 +116,6 @@ def send(self, msg):
self.mock_store(msg)
return len(msg)

def write(self, msg):
"""Write."""
self.mock_store(msg)
return len(msg)

def recvfrom(self, size):
"""Receive from."""
return [self.mock_retrieve(size)]
Expand All @@ -149,10 +129,6 @@ def setblocking(self, flag): # pylint: disable=unused-argument
"""Set blocking."""
return None

def in_waiting(self):
"""Do in waiting."""
return None


def run_coroutine(coro):
"""Run a coroutine as top-level task by iterating through all yielded steps."""
Expand All @@ -164,8 +140,6 @@ def run_coroutine(coro):
except StopIteration as exc:
# coro reached end pass on its return value:
return exc.value
except: # noqa: E722 pylint: disable=try-except-raise
raise


def _yielded_return(return_value, *args): # pylint: disable=unused-argument
Expand All @@ -174,7 +148,6 @@ def _yielded_return(return_value, *args): # pylint: disable=unused-argument
async def _():
"""Actual generator producing value."""
# yield
return return_value

# return new generator each time this function is called:
return _()
Expand Down
1 change: 0 additions & 1 deletion test/test_all_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test all messages."""
import unittest

Expand Down
8 changes: 0 additions & 8 deletions test/test_bit_read_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Bit Message Test Fixture.
This fixture tests the functionality of all the
Expand Down Expand Up @@ -135,10 +134,3 @@ def test_bit_read_message_get_response_pdu(self):
for request, expected in iter(requests.items()):
pdu_len = request.get_response_pdu_size()
self.assertEqual(pdu_len, expected)


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
8 changes: 0 additions & 8 deletions test/test_bit_write_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Bit Message Test Fixture.
This fixture tests the functionality of all the
Expand Down Expand Up @@ -133,10 +132,3 @@ def test_serializing_to_string(self):
for request in requests:
result = str(request)
self.assertTrue(result is not None and len(result))


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
7 changes: 0 additions & 7 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,6 @@ def test_client_modbusbaseclient():
with ModbusBaseClient(framer=ModbusAsciiFramer) as b_client:
str(b_client)
p_connect.return_value = False
with pytest.raises(ConnectionException), ModbusBaseClient(
framer=ModbusAsciiFramer
) as b_client:
str(b_client)


async def test_client_made_connection():
Expand Down Expand Up @@ -362,9 +358,6 @@ async def test_client_base_async():
p_connect.return_value.set_result(False)
p_close.return_value = loop.create_future()
p_close.return_value.set_result(False)
with pytest.raises(ConnectionException):
async with ModbusBaseClient(framer=ModbusAsciiFramer) as client:
str(client)


async def test_client_protocol():
Expand Down
8 changes: 0 additions & 8 deletions test/test_client_sync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test client sync."""
from itertools import count
import ssl
Expand Down Expand Up @@ -494,10 +493,3 @@ def test_serial_client_repr(self):
f"framer={client.framer}, timeout={client.params.timeout}>"
)
self.assertEqual(repr(client), rep)


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
8 changes: 0 additions & 8 deletions test/test_client_sync_diag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test client sync diag."""
from itertools import count
import socket
Expand Down Expand Up @@ -114,10 +113,3 @@ def test_tcp_diag_client_repr(self):
f"port={client.params.port}, timeout={client.params.timeout}>"
)
self.assertEqual(repr(client), rep)


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
8 changes: 0 additions & 8 deletions test/test_datastore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test datastore."""
import random
import unittest
Expand Down Expand Up @@ -460,10 +459,3 @@ def test_update_failure(self):
self.mock_type, self.mock_offset, self.mock_values
)
)


# --------------------------------------------------------------------------- #
# Main
# --------------------------------------------------------------------------- #
if __name__ == "__main__":
unittest.main()
8 changes: 0 additions & 8 deletions test/test_device.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test device."""
import unittest

Expand Down Expand Up @@ -356,10 +355,3 @@ def test_modbus_plus_statistics_helpers(self):
]
self.assertEqual(sorted(summary), sorted(stats_summary))
self.assertEqual(0x00, sum(sum(value[1]) for value in statistics))


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
8 changes: 0 additions & 8 deletions test/test_diag_messages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test diag messages."""
import unittest

Expand Down Expand Up @@ -199,10 +198,3 @@ def test_get_clear_modbus_plus_request_execute(self):
response = request.execute()
resp = [ModbusPlusOperation.GetStatistics]
self.assertEqual(response.message, resp + [0x00] * 55)


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
8 changes: 0 additions & 8 deletions test/test_events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Test events."""
import unittest

Expand Down Expand Up @@ -79,10 +78,3 @@ def test_communication_restart_event(self):
event.decode(b"\x00")
self.assertEqual(event.value, 0x00)
self.assertRaises(ParameterException, lambda: event.decode(b"\x04"))


# ---------------------------------------------------------------------------#
# Main
# ---------------------------------------------------------------------------#
if __name__ == "__main__":
unittest.main()
Loading

0 comments on commit d7834ac

Please sign in to comment.