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 pymodbus/pdu/mei_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def datastore_update(
_ = context
if not 0x00 <= self.object_id <= 0xFF:
return ExceptionResponse(self.function_code, ExcCodes.ILLEGAL_VALUE)
if not 0x00 <= self.read_code <= 0x04:
if not 0x01 <= self.read_code <= 0x04:
return ExceptionResponse(self.function_code, ExcCodes.ILLEGAL_VALUE)

information = DeviceInformationFactory.get(_MCB, self.read_code, self.object_id)
Expand Down
3 changes: 3 additions & 0 deletions test/pdu/test_mei_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ async def test_read_device_information_request_error(self, mock_server_context):
assert (await handle.datastore_update(context, 0)).function_code == 0xAB
handle.read_code = 0x05
assert (await handle.datastore_update(context, 0)).function_code == 0xAB
handle.read_code = 0x00
result = await handle.datastore_update(context, 0)
assert result.exception_code == ExcCodes.ILLEGAL_VALUE
handle.object_id = -1
assert (await handle.datastore_update(context, 0)).function_code == 0xAB
handle.object_id = 0x100
Expand Down
Loading