Skip to content

Commit 35503cb

Browse files
authored
All pdu (incl. function code) tests to pdu directory. (#2397)
1 parent 704929b commit 35503cb

20 files changed

+137
-133
lines changed

pymodbus/pdu/bit_read_message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def __init__(self, address=None, count=None, slave=1, transaction=0, skip_encode
141141
"""
142142
ReadBitsRequestBase.__init__(self, address, count, slave, transaction, skip_encode)
143143

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

212-
async def execute(self, context): # pragma: no cover
212+
async def update_datastore(self, context): # pragma: no cover
213213
"""Run a read discrete input request against a datastore.
214214
215215
Before running the request, we make sure that the request is in

pymodbus/pdu/bit_write_message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def decode(self, data):
7373
self.address, value = struct.unpack(">HH", data)
7474
self.value = value == ModbusStatus.ON
7575

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

202-
async def execute(self, context): # pragma: no cover
202+
async def update_datastore(self, context): # pragma: no cover
203203
"""Run a write coils request against a datastore.
204204
205205
:param context: The datastore to request from

pymodbus/pdu/diag_message.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class DiagnosticStatusResponse(ModbusPDU):
8686
8787
It works by performing all of the encoding and decoding of variable
8888
data and lets the higher classes define what extra data to append
89-
and how to execute a request
89+
and how to update_datastore a request
9090
"""
9191

9292
function_code = 0x08
@@ -145,7 +145,7 @@ class DiagnosticStatusSimpleRequest(DiagnosticStatusRequest):
145145
2 bytes of data.
146146
147147
If a function inherits this, they only need to implement
148-
the execute method
148+
the update_datastore method
149149
"""
150150

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

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

166166

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

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

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

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

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

304304
sub_function_code = 0x0002
305305

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

338338
sub_function_code = 0x0003
339339

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

373373
sub_function_code = 0x0004
374374

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

411411
sub_function_code = 0x000A
412412

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

442442
sub_function_code = 0x000B
443443

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

475475
sub_function_code = 0x000C
476476

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

508508
sub_function_code = 0x000D
509509

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

541541
sub_function_code = 0x000E
542542

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

574574
sub_function_code = 0x000F
575575

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

608608
sub_function_code = 0x0010
609609

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

642642
sub_function_code = 0x0011
643643

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

677677
sub_function_code = 0x0012
678678

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

710710
sub_function_code = 0x0013
711711

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

743743
sub_function_code = 0x0014
744744

745-
async def execute(self, *args): # pragma: no cover
746-
"""Execute the diagnostic request on the given device.
745+
async def update_datastore(self, *args): # pragma: no cover
746+
"""update_datastore the diagnostic request on the given device.
747747
748748
:returns: The initialized response message
749749
"""
@@ -794,8 +794,8 @@ def get_response_pdu_size(self):
794794
data = 0
795795
return 1 + 2 + 2 + 2 + data
796796

797-
async def execute(self, *args): # pragma: no cover
798-
"""Execute the diagnostic request on the given device.
797+
async def update_datastore(self, *args): # pragma: no cover
798+
"""update_datastore the diagnostic request on the given device.
799799
800800
:returns: The initialized response message
801801
"""

pymodbus/pdu/file_message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def decode(self, data):
130130
if decoded[0] == 0x06: # pragma: no cover
131131
self.records.append(record)
132132

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

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

365-
def execute(self, _context): # pragma: no cover
365+
def update_datastore(self, _context): # pragma: no cover
366366
"""Run a read exception status request against the store.
367367
368368
:returns: The populated response

pymodbus/pdu/mei_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def decode(self, data):
8080
params = struct.unpack(">BBB", data)
8181
self.sub_function_code, self.read_code, self.object_id = params
8282

83-
async def execute(self, _context): # pragma: no cover
83+
async def update_datastore(self, _context): # pragma: no cover
8484
"""Run a read exception status request against the store.
8585
8686
:returns: The populated response

pymodbus/pdu/other_message.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def decode(self, data):
4444
:param data: The incoming data
4545
"""
4646

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

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

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

376-
async def execute(self, context=None): # pragma: no cover
376+
async def update_datastore(self, context=None): # pragma: no cover
377377
"""Run a report slave id request against the store.
378378
379379
:returns: The populated response

pymodbus/pdu/register_read_message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(self, address=None, count=None, slave=1, transaction=0, skip_encode
133133
"""
134134
super().__init__(address, count, slave, transaction, skip_encode)
135135

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

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

310-
async def execute(self, context): # pragma: no cover
310+
async def update_datastore(self, context): # pragma: no cover
311311
"""Run a write single register request against a datastore.
312312
313313
:param context: The datastore to request from

pymodbus/pdu/register_write_message.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def decode(self, data):
4949
"""
5050
self.address, self.value = struct.unpack(">HH", data)
5151

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

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

319-
async def execute(self, context): # pragma: no cover
319+
async def update_datastore(self, context): # pragma: no cover
320320
"""Run a mask write register request against the store.
321321
322322
:param context: The datastore to request from

0 commit comments

Comments
 (0)