pyModbusTCP 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,10 @@
1
1
  Revision history for pyModbusTCP
2
2
 
3
+ 0.2.2 2024-07-31
4
+
5
+ - fix ModbusServer: wrong check of discrete inputs length in DataBank (thanks to OTnetproj).
6
+ - updated compatibility test (python versions): remove 3.7, add 3.12.
7
+
3
8
  0.2.1 2023-11-21
4
9
 
5
10
  - fix ModbusServer: wrong check of input registers length in DataBank (thanks to monsieurvor).
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyModbusTCP
3
+ Version: 0.2.2
4
+ Summary: A simple Modbus/TCP library for Python
5
+ Home-page: https://github.com/sourceperl/pyModbusTCP
6
+ Author: Loic Lefebvre
7
+ Author-email: loic.celine@free.fr
8
+ License: MIT
9
+ Platform: any
10
+ License-File: LICENSE
11
+
12
+ .. |badge_tests| image:: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml/badge.svg?branch=master
13
+ :target: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml
14
+
15
+ .. |badge_docs| image:: https://readthedocs.org/projects/pymodbustcp/badge/?version=latest
16
+ :target: http://pymodbustcp.readthedocs.io/
17
+
18
+ pyModbusTCP |badge_tests| |badge_docs|
19
+ ======================================
20
+
21
+ A simple Modbus/TCP client library for Python.
22
+ pyModbusTCP is pure Python code without any extension or external module dependency.
23
+
24
+ Since version 0.1.0, a server is also available.
25
+
26
+ Tests
27
+ -----
28
+
29
+ The module is currently test on Python 3.8, 3.9, 3.10, 3.11 and 3.12.
30
+
31
+ For Linux, Mac OS and Windows.
32
+
33
+ Documentation
34
+ -------------
35
+
36
+ Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.
37
+
38
+ Setup
39
+ -----
40
+
41
+ You can install this package from:
42
+
43
+ PyPI, the easy way:
44
+
45
+ .. code-block:: bash
46
+
47
+ # install the last available release (stable)
48
+ sudo pip install pyModbusTCP
49
+
50
+ .. code-block:: bash
51
+
52
+ # install a specific version (here release v0.1.10)
53
+ sudo pip install pyModbusTCP==v0.1.10
54
+
55
+ From GitHub:
56
+
57
+ .. code-block:: bash
58
+
59
+ # install a specific version (here release v0.1.10) directly from github servers
60
+ sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10
61
+
62
+ Note on the use of versions:
63
+
64
+ Over time, some things can change. So, it's a good practice that you always use a specific version of a package for
65
+ your project, instead of just relying on the default behavior. Without precision, the installation tools will always
66
+ install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP
67
+ automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just
68
+ doesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of
69
+ the change. Look at `CHANGES <https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES>`_ for details on versions
70
+ available.
71
+
72
+ Usage example
73
+ -------------
74
+
75
+ See examples/ for full scripts.
76
+
77
+ include (for all samples)
78
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
79
+
80
+ .. code-block:: python
81
+
82
+ from pyModbusTCP.client import ModbusClient
83
+
84
+ module init (TCP always open)
85
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
+
87
+ .. code-block:: python
88
+
89
+ # TCP auto connect on first modbus request
90
+ c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)
91
+
92
+ module init (TCP open/close for each request)
93
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
+
95
+ .. code-block:: python
96
+
97
+ # TCP auto connect on modbus request, close after it
98
+ c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)
99
+
100
+ Read 2x 16 bits registers at modbus address 0 :
101
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102
+
103
+ .. code-block:: python
104
+
105
+ regs = c.read_holding_registers(0, 2)
106
+
107
+ if regs:
108
+ print(regs)
109
+ else:
110
+ print("read error")
111
+
112
+ Write value 44 and 55 to registers at modbus address 10 :
113
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114
+
115
+ .. code-block:: python
116
+
117
+ if c.write_multiple_registers(10, [44,55]):
118
+ print("write ok")
119
+ else:
120
+ print("write error")
@@ -10,12 +10,12 @@ pyModbusTCP |badge_tests| |badge_docs|
10
10
  A simple Modbus/TCP client library for Python.
11
11
  pyModbusTCP is pure Python code without any extension or external module dependency.
12
12
 
13
- Since version 0.1.0, a server is also available for test purpose only (don't use in project).
13
+ Since version 0.1.0, a server is also available.
14
14
 
15
15
  Tests
16
16
  -----
17
17
 
18
- The module is currently test on Python 3.7, 3.8, 3.9, 3.10 and 3.11.
18
+ The module is currently test on Python 3.8, 3.9, 3.10, 3.11 and 3.12.
19
19
 
20
20
  For Linux, Mac OS and Windows.
21
21
 
@@ -1,7 +1,7 @@
1
1
  """ pyModbusTCP package constants definition """
2
2
 
3
3
  # Package version
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  # Modbus/TCP
6
6
  MODBUS_PORT = 502
7
7
  # Modbus function code
@@ -171,7 +171,7 @@ class DataBank:
171
171
  """
172
172
  # secure extract of data from list used by server thread
173
173
  with self._d_inputs_lock:
174
- if (address >= 0) and (address + number <= len(self._coils)):
174
+ if (address >= 0) and (address + number <= len(self._d_inputs)):
175
175
  return self._d_inputs[address: number + address]
176
176
  else:
177
177
  return None
@@ -191,7 +191,7 @@ class DataBank:
191
191
  bit_list = [bool(b) for b in bit_list]
192
192
  # ensure atomic update of internal data
193
193
  with self._d_inputs_lock:
194
- if (address >= 0) and (address + len(bit_list) <= len(self._coils)):
194
+ if (address >= 0) and (address + len(bit_list) <= len(self._d_inputs)):
195
195
  for offset, b_value in enumerate(bit_list):
196
196
  self._d_inputs[address + offset] = b_value
197
197
  else:
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyModbusTCP
3
+ Version: 0.2.2
4
+ Summary: A simple Modbus/TCP library for Python
5
+ Home-page: https://github.com/sourceperl/pyModbusTCP
6
+ Author: Loic Lefebvre
7
+ Author-email: loic.celine@free.fr
8
+ License: MIT
9
+ Platform: any
10
+ License-File: LICENSE
11
+
12
+ .. |badge_tests| image:: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml/badge.svg?branch=master
13
+ :target: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml
14
+
15
+ .. |badge_docs| image:: https://readthedocs.org/projects/pymodbustcp/badge/?version=latest
16
+ :target: http://pymodbustcp.readthedocs.io/
17
+
18
+ pyModbusTCP |badge_tests| |badge_docs|
19
+ ======================================
20
+
21
+ A simple Modbus/TCP client library for Python.
22
+ pyModbusTCP is pure Python code without any extension or external module dependency.
23
+
24
+ Since version 0.1.0, a server is also available.
25
+
26
+ Tests
27
+ -----
28
+
29
+ The module is currently test on Python 3.8, 3.9, 3.10, 3.11 and 3.12.
30
+
31
+ For Linux, Mac OS and Windows.
32
+
33
+ Documentation
34
+ -------------
35
+
36
+ Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.
37
+
38
+ Setup
39
+ -----
40
+
41
+ You can install this package from:
42
+
43
+ PyPI, the easy way:
44
+
45
+ .. code-block:: bash
46
+
47
+ # install the last available release (stable)
48
+ sudo pip install pyModbusTCP
49
+
50
+ .. code-block:: bash
51
+
52
+ # install a specific version (here release v0.1.10)
53
+ sudo pip install pyModbusTCP==v0.1.10
54
+
55
+ From GitHub:
56
+
57
+ .. code-block:: bash
58
+
59
+ # install a specific version (here release v0.1.10) directly from github servers
60
+ sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10
61
+
62
+ Note on the use of versions:
63
+
64
+ Over time, some things can change. So, it's a good practice that you always use a specific version of a package for
65
+ your project, instead of just relying on the default behavior. Without precision, the installation tools will always
66
+ install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP
67
+ automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just
68
+ doesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of
69
+ the change. Look at `CHANGES <https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES>`_ for details on versions
70
+ available.
71
+
72
+ Usage example
73
+ -------------
74
+
75
+ See examples/ for full scripts.
76
+
77
+ include (for all samples)
78
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
79
+
80
+ .. code-block:: python
81
+
82
+ from pyModbusTCP.client import ModbusClient
83
+
84
+ module init (TCP always open)
85
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
+
87
+ .. code-block:: python
88
+
89
+ # TCP auto connect on first modbus request
90
+ c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)
91
+
92
+ module init (TCP open/close for each request)
93
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
+
95
+ .. code-block:: python
96
+
97
+ # TCP auto connect on modbus request, close after it
98
+ c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)
99
+
100
+ Read 2x 16 bits registers at modbus address 0 :
101
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102
+
103
+ .. code-block:: python
104
+
105
+ regs = c.read_holding_registers(0, 2)
106
+
107
+ if regs:
108
+ print(regs)
109
+ else:
110
+ print("read error")
111
+
112
+ Write value 44 and 55 to registers at modbus address 10 :
113
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114
+
115
+ .. code-block:: python
116
+
117
+ if c.write_multiple_registers(10, [44,55]):
118
+ print("write ok")
119
+ else:
120
+ print("write error")
@@ -1,119 +0,0 @@
1
- Metadata-Version: 1.0
2
- Name: pyModbusTCP
3
- Version: 0.2.1
4
- Summary: A simple Modbus/TCP library for Python
5
- Home-page: https://github.com/sourceperl/pyModbusTCP
6
- Author: Loic Lefebvre
7
- Author-email: loic.celine@free.fr
8
- License: MIT
9
- Description: .. |badge_tests| image:: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml/badge.svg?branch=master
10
- :target: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml
11
-
12
- .. |badge_docs| image:: https://readthedocs.org/projects/pymodbustcp/badge/?version=latest
13
- :target: http://pymodbustcp.readthedocs.io/
14
-
15
- pyModbusTCP |badge_tests| |badge_docs|
16
- ======================================
17
-
18
- A simple Modbus/TCP client library for Python.
19
- pyModbusTCP is pure Python code without any extension or external module dependency.
20
-
21
- Since version 0.1.0, a server is also available for test purpose only (don't use in project).
22
-
23
- Tests
24
- -----
25
-
26
- The module is currently test on Python 3.7, 3.8, 3.9, 3.10 and 3.11.
27
-
28
- For Linux, Mac OS and Windows.
29
-
30
- Documentation
31
- -------------
32
-
33
- Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.
34
-
35
- Setup
36
- -----
37
-
38
- You can install this package from:
39
-
40
- PyPI, the easy way:
41
-
42
- .. code-block:: bash
43
-
44
- # install the last available release (stable)
45
- sudo pip install pyModbusTCP
46
-
47
- .. code-block:: bash
48
-
49
- # install a specific version (here release v0.1.10)
50
- sudo pip install pyModbusTCP==v0.1.10
51
-
52
- From GitHub:
53
-
54
- .. code-block:: bash
55
-
56
- # install a specific version (here release v0.1.10) directly from github servers
57
- sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10
58
-
59
- Note on the use of versions:
60
-
61
- Over time, some things can change. So, it's a good practice that you always use a specific version of a package for
62
- your project, instead of just relying on the default behavior. Without precision, the installation tools will always
63
- install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP
64
- automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just
65
- doesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of
66
- the change. Look at `CHANGES <https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES>`_ for details on versions
67
- available.
68
-
69
- Usage example
70
- -------------
71
-
72
- See examples/ for full scripts.
73
-
74
- include (for all samples)
75
- ~~~~~~~~~~~~~~~~~~~~~~~~~
76
-
77
- .. code-block:: python
78
-
79
- from pyModbusTCP.client import ModbusClient
80
-
81
- module init (TCP always open)
82
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83
-
84
- .. code-block:: python
85
-
86
- # TCP auto connect on first modbus request
87
- c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)
88
-
89
- module init (TCP open/close for each request)
90
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91
-
92
- .. code-block:: python
93
-
94
- # TCP auto connect on modbus request, close after it
95
- c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)
96
-
97
- Read 2x 16 bits registers at modbus address 0 :
98
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
-
100
- .. code-block:: python
101
-
102
- regs = c.read_holding_registers(0, 2)
103
-
104
- if regs:
105
- print(regs)
106
- else:
107
- print("read error")
108
-
109
- Write value 44 and 55 to registers at modbus address 10 :
110
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
-
112
- .. code-block:: python
113
-
114
- if c.write_multiple_registers(10, [44,55]):
115
- print("write ok")
116
- else:
117
- print("write error")
118
-
119
- Platform: any
@@ -1,119 +0,0 @@
1
- Metadata-Version: 1.0
2
- Name: pyModbusTCP
3
- Version: 0.2.1
4
- Summary: A simple Modbus/TCP library for Python
5
- Home-page: https://github.com/sourceperl/pyModbusTCP
6
- Author: Loic Lefebvre
7
- Author-email: loic.celine@free.fr
8
- License: MIT
9
- Description: .. |badge_tests| image:: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml/badge.svg?branch=master
10
- :target: https://github.com/sourceperl/pyModbusTCP/actions/workflows/tests.yml
11
-
12
- .. |badge_docs| image:: https://readthedocs.org/projects/pymodbustcp/badge/?version=latest
13
- :target: http://pymodbustcp.readthedocs.io/
14
-
15
- pyModbusTCP |badge_tests| |badge_docs|
16
- ======================================
17
-
18
- A simple Modbus/TCP client library for Python.
19
- pyModbusTCP is pure Python code without any extension or external module dependency.
20
-
21
- Since version 0.1.0, a server is also available for test purpose only (don't use in project).
22
-
23
- Tests
24
- -----
25
-
26
- The module is currently test on Python 3.7, 3.8, 3.9, 3.10 and 3.11.
27
-
28
- For Linux, Mac OS and Windows.
29
-
30
- Documentation
31
- -------------
32
-
33
- Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.
34
-
35
- Setup
36
- -----
37
-
38
- You can install this package from:
39
-
40
- PyPI, the easy way:
41
-
42
- .. code-block:: bash
43
-
44
- # install the last available release (stable)
45
- sudo pip install pyModbusTCP
46
-
47
- .. code-block:: bash
48
-
49
- # install a specific version (here release v0.1.10)
50
- sudo pip install pyModbusTCP==v0.1.10
51
-
52
- From GitHub:
53
-
54
- .. code-block:: bash
55
-
56
- # install a specific version (here release v0.1.10) directly from github servers
57
- sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10
58
-
59
- Note on the use of versions:
60
-
61
- Over time, some things can change. So, it's a good practice that you always use a specific version of a package for
62
- your project, instead of just relying on the default behavior. Without precision, the installation tools will always
63
- install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP
64
- automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just
65
- doesn't exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of
66
- the change. Look at `CHANGES <https://github.com/sourceperl/pyModbusTCP/blob/master/CHANGES>`_ for details on versions
67
- available.
68
-
69
- Usage example
70
- -------------
71
-
72
- See examples/ for full scripts.
73
-
74
- include (for all samples)
75
- ~~~~~~~~~~~~~~~~~~~~~~~~~
76
-
77
- .. code-block:: python
78
-
79
- from pyModbusTCP.client import ModbusClient
80
-
81
- module init (TCP always open)
82
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83
-
84
- .. code-block:: python
85
-
86
- # TCP auto connect on first modbus request
87
- c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)
88
-
89
- module init (TCP open/close for each request)
90
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91
-
92
- .. code-block:: python
93
-
94
- # TCP auto connect on modbus request, close after it
95
- c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)
96
-
97
- Read 2x 16 bits registers at modbus address 0 :
98
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
-
100
- .. code-block:: python
101
-
102
- regs = c.read_holding_registers(0, 2)
103
-
104
- if regs:
105
- print(regs)
106
- else:
107
- print("read error")
108
-
109
- Write value 44 and 55 to registers at modbus address 10 :
110
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
-
112
- .. code-block:: python
113
-
114
- if c.write_multiple_registers(10, [44,55]):
115
- print("write ok")
116
- else:
117
- print("write error")
118
-
119
- Platform: any
File without changes
File without changes
File without changes
File without changes