|
@@ -33,12 +33,15 @@ def read_coils(start, end):
|
33
|
33
|
connect()
|
34
|
34
|
res = []
|
35
|
35
|
|
|
36
|
+ address = -1
|
|
37
|
+ qty = -1
|
|
38
|
+
|
36
|
39
|
try:
|
37
|
40
|
for address in range(start, end + 1, 125):
|
38
|
41
|
qty = 125 if (end - address) >= 125 else (end - address)
|
39
|
42
|
if not qty:
|
40
|
43
|
break
|
41
|
|
- print(start, end, address, qty)
|
|
44
|
+
|
42
|
45
|
req_adu = rtu.read_coils(
|
43
|
46
|
slave_id=1,
|
44
|
47
|
starting_address=address,
|
|
@@ -48,6 +51,8 @@ def read_coils(start, end):
|
48
|
51
|
res.extend(resp)
|
49
|
52
|
except umodbus.exceptions.IllegalDataAddressError as e:
|
50
|
53
|
print(e)
|
|
54
|
+ print(f'{address} {qty}')
|
|
55
|
+
|
51
|
56
|
return res
|
52
|
57
|
|
53
|
58
|
|
|
@@ -57,12 +62,15 @@ def read_holding_registers(start, end):
|
57
|
62
|
connect()
|
58
|
63
|
res = []
|
59
|
64
|
|
|
65
|
+ address = -1
|
|
66
|
+ qty = -1
|
|
67
|
+
|
60
|
68
|
try:
|
61
|
69
|
for address in range(start, end + 1, 125):
|
62
|
70
|
qty = 125 if (end - address) >= 125 else (end - address)
|
63
|
71
|
if not qty:
|
64
|
72
|
break
|
65
|
|
- print(start, end, address, qty)
|
|
73
|
+
|
66
|
74
|
req_adu = rtu.read_holding_registers(
|
67
|
75
|
slave_id=1,
|
68
|
76
|
starting_address=address,
|
|
@@ -72,6 +80,8 @@ def read_holding_registers(start, end):
|
72
|
80
|
res.extend(resp)
|
73
|
81
|
except umodbus.exceptions.IllegalDataAddressError as e:
|
74
|
82
|
print(e)
|
|
83
|
+ print(f'{address} {qty}')
|
|
84
|
+
|
75
|
85
|
return res
|
76
|
86
|
|
77
|
87
|
if __name__ == '__main__':
|