Skip to content

Commit

Permalink
All pdu (incl. function code) tests to pdu directory. (#2397)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Oct 21, 2024
1 parent 704929b commit 35503cb
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 133 deletions.
4 changes: 2 additions & 2 deletions pymodbus/pdu/bit_read_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(self, address=None, count=None, slave=1, transaction=0, skip_encode
"""
ReadBitsRequestBase.__init__(self, address, count, slave, transaction, skip_encode)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a read coils request against a datastore.
Before running the request, we make sure that the request is in
Expand Down Expand Up @@ -209,7 +209,7 @@ def __init__(self, address=None, count=None, slave=1, transaction=0, skip_encode
"""
ReadBitsRequestBase.__init__(self, address, count, slave, transaction, skip_encode)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a read discrete input request against a datastore.
Before running the request, we make sure that the request is in
Expand Down
4 changes: 2 additions & 2 deletions pymodbus/pdu/bit_write_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def decode(self, data):
self.address, value = struct.unpack(">HH", data)
self.value = value == ModbusStatus.ON

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a write coil request against a datastore.
:param context: The datastore to request from
Expand Down Expand Up @@ -199,7 +199,7 @@ def decode(self, data):
values = unpack_bitstring(data[5:])
self.values = values[:count]

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a write coils request against a datastore.
:param context: The datastore to request from
Expand Down
78 changes: 39 additions & 39 deletions pymodbus/pdu/diag_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DiagnosticStatusResponse(ModbusPDU):
It works by performing all of the encoding and decoding of variable
data and lets the higher classes define what extra data to append
and how to execute a request
and how to update_datastore a request
"""

function_code = 0x08
Expand Down Expand Up @@ -145,7 +145,7 @@ class DiagnosticStatusSimpleRequest(DiagnosticStatusRequest):
2 bytes of data.
If a function inherits this, they only need to implement
the execute method
the update_datastore method
"""

def __init__(self, data=0x0000, slave=1, transaction=0, skip_encode=False):
Expand All @@ -159,9 +159,9 @@ def __init__(self, data=0x0000, slave=1, transaction=0, skip_encode=False):
DiagnosticStatusRequest.__init__(self, slave=slave, transaction=transaction, skip_encode=skip_encode)
self.message = data

async def execute(self, *args): # pragma: no cover
async def update_datastore(self, *args): # pragma: no cover
"""Raise if not implemented."""
raise NotImplementedException("Diagnostic Message Has No Execute Method")
raise NotImplementedException("Diagnostic Message Has No update_datastore Method")


class DiagnosticStatusSimpleResponse(DiagnosticStatusResponse):
Expand Down Expand Up @@ -205,8 +205,8 @@ def __init__(self, message=b"\x00\x00", slave=1, transaction=0, skip_encode=Fals
raise ModbusException(f"message({type(message)}) must be bytes")
self.message = message

async def execute(self, *_args): # pragma: no cover
"""Execute the loopback request (builds the response).
async def update_datastore(self, *_args): # pragma: no cover
"""update_datastore the loopback request (builds the response).
:returns: The populated loopback response message
"""
Expand Down Expand Up @@ -245,7 +245,7 @@ class RestartCommunicationsOptionRequest(DiagnosticStatusRequest):
currently in Listen Only Mode, no response is returned. This function is
the only one that brings the port out of Listen Only Mode. If the port is
not currently in Listen Only Mode, a normal response is returned. This
occurs before the restart is executed.
occurs before the restart is update_datastored.
"""

sub_function_code = 0x0001
Expand All @@ -261,7 +261,7 @@ def __init__(self, toggle=False, slave=1, transaction=0, skip_encode=False):
else:
self.message = [ModbusStatus.OFF] # pragma: no cover

async def execute(self, *_args): # pragma: no cover
async def update_datastore(self, *_args): # pragma: no cover
"""Clear event log and restart.
:returns: The initialized response message
Expand All @@ -278,7 +278,7 @@ class RestartCommunicationsOptionResponse(DiagnosticStatusResponse):
currently in Listen Only Mode, no response is returned. This function is
the only one that brings the port out of Listen Only Mode. If the port is
not currently in Listen Only Mode, a normal response is returned. This
occurs before the restart is executed.
occurs before the restart is update_datastored.
"""

sub_function_code = 0x0001
Expand All @@ -303,8 +303,8 @@ class ReturnDiagnosticRegisterRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0002

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -337,8 +337,8 @@ class ChangeAsciiInputDelimiterRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0003

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -372,8 +372,8 @@ class ForceListenOnlyModeRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0004

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -410,8 +410,8 @@ class ClearCountersRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x000A

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -441,8 +441,8 @@ class ReturnBusMessageCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x000B

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -474,8 +474,8 @@ class ReturnBusCommunicationErrorCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x000C

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -507,8 +507,8 @@ class ReturnBusExceptionErrorCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x000D

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -540,8 +540,8 @@ class ReturnSlaveMessageCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x000E

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -573,8 +573,8 @@ class ReturnSlaveNoResponseCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x000F

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -607,8 +607,8 @@ class ReturnSlaveNAKCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0010

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -641,8 +641,8 @@ class ReturnSlaveBusyCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0011

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -676,8 +676,8 @@ class ReturnSlaveBusCharacterOverrunCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0012

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -709,8 +709,8 @@ class ReturnIopOverrunCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0013

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -742,8 +742,8 @@ class ClearOverrunCountRequest(DiagnosticStatusSimpleRequest):

sub_function_code = 0x0014

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down Expand Up @@ -794,8 +794,8 @@ def get_response_pdu_size(self):
data = 0
return 1 + 2 + 2 + 2 + data

async def execute(self, *args): # pragma: no cover
"""Execute the diagnostic request on the given device.
async def update_datastore(self, *args): # pragma: no cover
"""update_datastore the diagnostic request on the given device.
:returns: The initialized response message
"""
Expand Down
6 changes: 3 additions & 3 deletions pymodbus/pdu/file_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def decode(self, data):
if decoded[0] == 0x06: # pragma: no cover
self.records.append(record)

def execute(self, _context): # pragma: no cover
def update_datastore(self, _context): # pragma: no cover
"""Run a read exception status request against the store.
:returns: The populated response
Expand Down Expand Up @@ -257,7 +257,7 @@ def decode(self, data):
if decoded[0] == 0x06: # pragma: no cover
self.records.append(record)

def execute(self, _context): # pragma: no cover
def update_datastore(self, _context): # pragma: no cover
"""Run the write file record request against the context.
:returns: The populated response
Expand Down Expand Up @@ -362,7 +362,7 @@ def decode(self, data):
"""
self.address = struct.unpack(">H", data)[0]

def execute(self, _context): # pragma: no cover
def update_datastore(self, _context): # pragma: no cover
"""Run a read exception status request against the store.
:returns: The populated response
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/pdu/mei_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def decode(self, data):
params = struct.unpack(">BBB", data)
self.sub_function_code, self.read_code, self.object_id = params

async def execute(self, _context): # pragma: no cover
async def update_datastore(self, _context): # pragma: no cover
"""Run a read exception status request against the store.
:returns: The populated response
Expand Down
8 changes: 4 additions & 4 deletions pymodbus/pdu/other_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def decode(self, data):
:param data: The incoming data
"""

async def execute(self, _context=None): # pragma: no cover
async def update_datastore(self, _context=None): # pragma: no cover
"""Run a read exception status request against the store.
:returns: The populated response
Expand Down Expand Up @@ -143,7 +143,7 @@ def decode(self, data):
:param data: The incoming data
"""

async def execute(self, _context=None): # pragma: no cover
async def update_datastore(self, _context=None): # pragma: no cover
"""Run a read exception status request against the store.
:returns: The populated response
Expand Down Expand Up @@ -248,7 +248,7 @@ def decode(self, data):
:param data: The incoming data
"""

async def execute(self, _context=None): # pragma: no cover
async def update_datastore(self, _context=None): # pragma: no cover
"""Run a read exception status request against the store.
:returns: The populated response
Expand Down Expand Up @@ -373,7 +373,7 @@ def decode(self, data):
:param data: The incoming data
"""

async def execute(self, context=None): # pragma: no cover
async def update_datastore(self, context=None): # pragma: no cover
"""Run a report slave id request against the store.
:returns: The populated response
Expand Down
6 changes: 3 additions & 3 deletions pymodbus/pdu/register_read_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, address=None, count=None, slave=1, transaction=0, skip_encode
"""
super().__init__(address, count, slave, transaction, skip_encode)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a read holding request against a datastore.
:param context: The datastore to request from
Expand Down Expand Up @@ -195,7 +195,7 @@ def __init__(self, address=None, count=None, slave=1, transaction=0, skip_encode
"""
super().__init__(address, count, slave, transaction, skip_encode)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a read input request against a datastore.
:param context: The datastore to request from
Expand Down Expand Up @@ -307,7 +307,7 @@ def decode(self, data):
register = struct.unpack(">H", data[i : i + 2])[0]
self.write_registers.append(register)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a write single register request against a datastore.
:param context: The datastore to request from
Expand Down
6 changes: 3 additions & 3 deletions pymodbus/pdu/register_write_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def decode(self, data):
"""
self.address, self.value = struct.unpack(">HH", data)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a write single register request against a datastore.
:param context: The datastore to request from
Expand Down Expand Up @@ -195,7 +195,7 @@ def decode(self, data):
for idx in range(5, (self.count * 2) + 5, 2):
self.values.append(struct.unpack(">H", data[idx : idx + 2])[0])

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a write single register request against a datastore.
:param context: The datastore to request from
Expand Down Expand Up @@ -316,7 +316,7 @@ def decode(self, data):
"""
self.address, self.and_mask, self.or_mask = struct.unpack(">HHH", data)

async def execute(self, context): # pragma: no cover
async def update_datastore(self, context): # pragma: no cover
"""Run a mask write register request against the store.
:param context: The datastore to request from
Expand Down
Loading

0 comments on commit 35503cb

Please # to comment.