--- a/modbus/modbus.py Mon Mar 27 10:19:14 2023 +0200
+++ b/modbus/modbus.py Fri Oct 28 12:39:15 2022 +0800
@@ -23,7 +23,7 @@
# used in safety-critical situations without a full and competent review.
-from __future__ import absolute_import
+
import os
from six.moves import xrange
@@ -94,7 +94,7 @@
if element["name"] == "ModbusRequest":
for child in element["children"]:
if child["name"] == "Function":
- list = modbus_function_dict.keys()
+ list = list(modbus_function_dict.keys())
list.sort()
child["type"] = list
return infos
@@ -240,7 +240,7 @@
if element["name"] == "MemoryArea":
for child in element["children"]:
if child["name"] == "MemoryAreaType":
- list = modbus_memtype_dict.keys()
+ list = list(modbus_memtype_dict.keys())
list.sort()
child["type"] = list
return infos
@@ -618,7 +618,7 @@
if child["name"] == "Stop_Bits":
child["type"] = modbus_serial_stopbits_list
if child["name"] == "Parity":
- child["type"] = modbus_serial_parity_dict.keys()
+ child["type"] = list(modbus_serial_parity_dict.keys())
return infos
# Return the number of (modbus library) nodes this specific RTU client will need
@@ -709,7 +709,7 @@
if child["name"] == "Stop_Bits":
child["type"] = modbus_serial_stopbits_list
if child["name"] == "Parity":
- child["type"] = modbus_serial_parity_dict.keys()
+ child["type"] = list(modbus_serial_parity_dict.keys())
return infos
# Return the number of (modbus library) nodes this specific RTU slave will need
@@ -1026,7 +1026,7 @@
start_address = int(GetCTVal(subchild, 2))
relative_addr = absloute_address - start_address
# test if relative address in request specified range
- if relative_addr in xrange(int(GetCTVal(subchild, 1))):
+ if relative_addr in range(int(GetCTVal(subchild, 1))):
if str(iecvar["NAME"]) not in loc_vars_list:
loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &server_nodes[%d].mem_area.%s[%d];" % (
server_id, memarea, absloute_address))
@@ -1080,7 +1080,7 @@
start_address = int(GetCTVal(subchild, 2))
relative_addr = absloute_address - start_address
# test if relative address in request specified range
- if relative_addr in xrange(int(GetCTVal(subchild, 1))):
+ if relative_addr in range(int(GetCTVal(subchild, 1))):
if str(iecvar["NAME"]) not in loc_vars_list:
loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &server_nodes[%d].mem_area.%s[%d];" % (
server_id, memarea, absloute_address))
@@ -1116,7 +1116,7 @@
# two numbers are always '0.0', and the first two identify the request.
# In the following if, we check for this condition by checking
# if there are at least 4 or more number in the location's address.
- if ( relative_addr in xrange(int(GetCTVal(subchild, 2))) # condition (a) explained above
+ if ( relative_addr in range(int(GetCTVal(subchild, 2))) # condition (a) explained above
and len(iecvar["LOC"]) < 5): # condition (b) explained above
if str(iecvar["NAME"]) not in loc_vars_list:
loc_vars.append("u16 *" + str(iecvar["NAME"]) + " = &client_requests[%d].plcv_buffer[%d];" % (client_requestid, relative_addr))
@@ -1177,7 +1177,7 @@
# two numbers are always '0.0', and the first two identify the request.
# In the following if, we check for this condition by checking
# if there are at least 4 or more number in the location's address.
- if ( relative_addr in xrange(int(GetCTVal(subchild, 2))) # condition (a) explained above
+ if ( relative_addr in range(int(GetCTVal(subchild, 2))) # condition (a) explained above
and len(iecvar["LOC"]) < 5): # condition (b) explained above
if str(iecvar["NAME"]) not in loc_vars_list:
loc_vars.append(