Skip to content
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
2 changes: 1 addition & 1 deletion check_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
codespell
ruff check --fix --exit-non-zero-on-fix .
pylint --recursive=y examples pymodbus test
zuban pymodbus examples
zuban check pymodbus examples
pytest -x --cov --numprocesses auto
echo "Ready to push"
23 changes: 11 additions & 12 deletions examples/package_test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,30 @@ def callback_new_connection(self) -> ModbusProtocol:
new_stub.stub_handle_data = self.stub_handle_data
return new_stub


TEST_PORT = 5004

class ClientTester: # pylint: disable=too-few-public-methods
"""Main program."""

TEST_PORT = 5004

def __init__(self, comm: CommType):
"""Initialize runtime tester."""
global TEST_PORT # pylint: disable=global-statement
self.comm = comm
host = NULLMODEM_HOST
self.client: modbusClient.AsyncModbusTcpClient | modbusClient.AsyncModbusSerialClient
if comm == CommType.TCP:
self.client = modbusClient.AsyncModbusTcpClient(
host,
port=TEST_PORT,
port=self.TEST_PORT,
)
else: # if comm == CommType.SERIAL:
host = f"{NULLMODEM_HOST}:{TEST_PORT}"
host = f"{NULLMODEM_HOST}:{self.TEST_PORT}"
self.client = modbusClient.AsyncModbusSerialClient(
host,
)
server_params = self.client.ctx.comm_params.copy()
server_params.source_address = (host, TEST_PORT)
server_params.source_address = (host, self.TEST_PORT)
self.stub = TransportStub(server_params, True, simulate_server)
TEST_PORT += 1
self.TEST_PORT += 1


async def run(self):
Expand All @@ -146,9 +144,10 @@ async def run(self):
class ServerTester: # pylint: disable=too-few-public-methods
"""Main program."""

TEST_PORT = 5020

def __init__(self, comm: CommType):
"""Initialize runtime tester."""
global TEST_PORT # pylint: disable=global-statement
self.comm = comm
self.store = ModbusDeviceContext(
di=ModbusSequentialDataBlock(0, [17] * 100),
Expand All @@ -166,19 +165,19 @@ def __init__(self, comm: CommType):
self.context,
framer=FramerType.SOCKET,
identity=self.identity,
address=(NULLMODEM_HOST, TEST_PORT),
address=(NULLMODEM_HOST, self.TEST_PORT),
)
else: # if comm == CommType.SERIAL:
self.server = modbusServer.ModbusSerialServer(
self.context,
framer=FramerType.SOCKET,
identity=self.identity,
port=f"{NULLMODEM_HOST}:{TEST_PORT}",
port=f"{NULLMODEM_HOST}:{self.TEST_PORT}",
)
client_params = self.server.comm_params.copy()
client_params.timeout_connect = 1.0
self.stub = TransportStub(client_params, False, simulate_client)
TEST_PORT += 1
self.TEST_PORT += 1


async def run(self):
Expand Down