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
4 changes: 4 additions & 0 deletions API_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ API changes
===========
Versions (X.Y.Z) where Z > 0 e.g. 3.0.1 do NOT have API changes!

API changes 3.12.0
------------------
- when using no_response_expected=, the call returns None

API changes 3.11.0
------------------
- Revert wrong byte handling in v3.10.0
Expand Down
3 changes: 1 addition & 2 deletions examples/client_async_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ async def async_execute_diagnostic_requests(client):
rr = await client.diag_getclear_modbus_response(device_id=DEVICE_ID)
assert not rr.isError() # test that call was OK
rr = await client.diag_force_listen_only(device_id=DEVICE_ID, no_response_expected=True)
assert rr.isError() # test that call was OK, error indicate no response

assert not rr

# ------------------------
# Run the calls in groups.
Expand Down
6 changes: 3 additions & 3 deletions pymodbus/transaction/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pymodbus.exceptions import ConnectionException, ModbusIOException
from pymodbus.framer import FramerAscii, FramerBase, FramerRTU
from pymodbus.logging import Log
from pymodbus.pdu import ExceptionResponse, ModbusPDU
from pymodbus.pdu import ModbusPDU
from pymodbus.transport import CommParams, ModbusProtocol


Expand Down Expand Up @@ -127,7 +127,7 @@ def sync_execute(self, no_response_expected: bool, request: ModbusPDU) -> Modbus
while count_retries <= self.retries:
self.pdu_send(request)
if no_response_expected:
return ExceptionResponse(0xff)
return None # type: ignore[return-value]
try:
response = self.sync_get_response(request.dev_id, request.transaction_id)
if response.dev_id != request.dev_id:
Expand Down Expand Up @@ -170,7 +170,7 @@ async def execute(self, no_response_expected: bool, request: ModbusPDU) -> Modbu
self.response_future = asyncio.Future()
self.pdu_send(request)
if no_response_expected:
return ExceptionResponse(0xff)
return None # type: ignore[return-value]
try:
response = await asyncio.wait_for(
self.response_future, timeout=self.comm_params.timeout_connect
Expand Down
5 changes: 2 additions & 3 deletions test/transaction/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ async def test_client_protocol_execute_outside(self, use_clc, no_resp):
transact.data_received(data)
if no_resp:
result = await resp
assert result.isError()
assert isinstance(result, ExceptionResponse)
assert not result
else:
with pytest.raises(ModbusIOException):
await resp
Expand Down Expand Up @@ -599,7 +598,7 @@ def test_sync_client_protocol_execute_outside(self, use_clc, no_resp):
transact.sync_client.send = mock.Mock()
result = transact.sync_execute(no_resp, request)
if no_resp:
assert result.isError()
assert not result
else:
assert not result.isError()
assert isinstance(response, ReadCoilsResponse)
Expand Down