slmp-connect-python 0.1.4__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.
- slmp_connect_python-0.1.4/LICENSE +21 -0
- slmp_connect_python-0.1.4/PKG-INFO +247 -0
- slmp_connect_python-0.1.4/README.md +213 -0
- slmp_connect_python-0.1.4/pyproject.toml +118 -0
- slmp_connect_python-0.1.4/setup.cfg +4 -0
- slmp_connect_python-0.1.4/slmp/__init__.py +119 -0
- slmp_connect_python-0.1.4/slmp/async_client.py +1368 -0
- slmp_connect_python-0.1.4/slmp/cli.py +6193 -0
- slmp_connect_python-0.1.4/slmp/client.py +1943 -0
- slmp_connect_python-0.1.4/slmp/constants.py +167 -0
- slmp_connect_python-0.1.4/slmp/core.py +975 -0
- slmp_connect_python-0.1.4/slmp/errors.py +25 -0
- slmp_connect_python-0.1.4/slmp/py.typed +1 -0
- slmp_connect_python-0.1.4/slmp/utils.py +893 -0
- slmp_connect_python-0.1.4/slmp_connect_python.egg-info/PKG-INFO +247 -0
- slmp_connect_python-0.1.4/slmp_connect_python.egg-info/SOURCES.txt +28 -0
- slmp_connect_python-0.1.4/slmp_connect_python.egg-info/dependency_links.txt +1 -0
- slmp_connect_python-0.1.4/slmp_connect_python.egg-info/entry_points.txt +20 -0
- slmp_connect_python-0.1.4/slmp_connect_python.egg-info/requires.txt +10 -0
- slmp_connect_python-0.1.4/slmp_connect_python.egg-info/top_level.txt +1 -0
- slmp_connect_python-0.1.4/tests/test_async_client.py +215 -0
- slmp_connect_python-0.1.4/tests/test_bugs_and_edges.py +32 -0
- slmp_connect_python-0.1.4/tests/test_device_vectors.py +28 -0
- slmp_connect_python-0.1.4/tests/test_live_sim.py +76 -0
- slmp_connect_python-0.1.4/tests/test_live_sim_3e.py +58 -0
- slmp_connect_python-0.1.4/tests/test_live_sim_exhaustive.py +124 -0
- slmp_connect_python-0.1.4/tests/test_live_sim_mixed_frames.py +80 -0
- slmp_connect_python-0.1.4/tests/test_live_sim_ultimate.py +129 -0
- slmp_connect_python-0.1.4/tests/test_slmp.py +2759 -0
- slmp_connect_python-0.1.4/tests/test_utils.py +466 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fa-yoshinobu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: slmp-connect-python
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: SLMP Connect Python: client library for Mitsubishi SLMP binary communication
|
|
5
|
+
Author: fa-yoshinobu
|
|
6
|
+
Project-URL: Homepage, https://github.com/fa-yoshinobu/plc-comm-slmp-python
|
|
7
|
+
Project-URL: Repository, https://github.com/fa-yoshinobu/plc-comm-slmp-python
|
|
8
|
+
Project-URL: Issues, https://github.com/fa-yoshinobu/plc-comm-slmp-python/issues
|
|
9
|
+
Keywords: slmp,melsec,mitsubishi,plc,3e,4e,binary
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: System :: Networking
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
27
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
32
|
+
Requires-Dist: twine>=5.1; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
[](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml)
|
|
36
|
+
[](https://fa-yoshinobu.github.io/plc-comm-slmp-python/)
|
|
37
|
+
[](https://www.python.org/downloads/)
|
|
38
|
+
[](LICENSE)
|
|
39
|
+
[](https://github.com/astral-sh/ruff)
|
|
40
|
+
|
|
41
|
+
# SLMP Protocol for Python
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
High-level SLMP helpers for Mitsubishi PLC communication over Binary 3E and 4E frames.
|
|
46
|
+
|
|
47
|
+
This repository now treats the high-level helper layer as the recommended user surface:
|
|
48
|
+
|
|
49
|
+
- `AsyncSlmpClient`
|
|
50
|
+
- `QueuedAsyncSlmpClient`
|
|
51
|
+
- `SlmpClient`
|
|
52
|
+
- `read_typed` / `write_typed`
|
|
53
|
+
- `read_words` / `read_dwords`
|
|
54
|
+
- `write_bit_in_word`
|
|
55
|
+
- `read_named` / `write_named`
|
|
56
|
+
- `poll`
|
|
57
|
+
|
|
58
|
+
Low-level protocol methods still exist for maintainers and validation work, but they are not the primary user path.
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install slmp-connect-python
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
Recommended async path:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import asyncio
|
|
72
|
+
|
|
73
|
+
from slmp import AsyncSlmpClient, read_named, write_typed
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def main() -> None:
|
|
77
|
+
async with AsyncSlmpClient(
|
|
78
|
+
"192.168.250.100",
|
|
79
|
+
port=1025,
|
|
80
|
+
plc_series="iqr",
|
|
81
|
+
frame_type="4e",
|
|
82
|
+
) as client:
|
|
83
|
+
before = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
84
|
+
print("before:", before)
|
|
85
|
+
|
|
86
|
+
await write_typed(client, "D100", "U", 42)
|
|
87
|
+
|
|
88
|
+
after = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
89
|
+
print("after:", after)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
asyncio.run(main())
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Choose the connection profile explicitly:
|
|
96
|
+
|
|
97
|
+
- `plc_series="iqr", frame_type="4e"` for iQ-R / iQ-F targets
|
|
98
|
+
- `plc_series="ql", frame_type="3e"` for Q / L targets
|
|
99
|
+
|
|
100
|
+
Recommended sync path:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from slmp import SlmpClient, read_named_sync, write_typed_sync
|
|
104
|
+
|
|
105
|
+
with SlmpClient(
|
|
106
|
+
"192.168.250.100",
|
|
107
|
+
port=1025,
|
|
108
|
+
plc_series="iqr",
|
|
109
|
+
frame_type="4e",
|
|
110
|
+
) as client:
|
|
111
|
+
print(read_named_sync(client, ["D100", "D200:F", "D50.3"]))
|
|
112
|
+
write_typed_sync(client, "D100", "U", 42)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## High-Level API Guide
|
|
116
|
+
|
|
117
|
+
### Single typed values
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from slmp import read_typed, write_typed
|
|
121
|
+
|
|
122
|
+
temperature = await read_typed(client, "D200", "F")
|
|
123
|
+
counter = await read_typed(client, "D300", "L")
|
|
124
|
+
await write_typed(client, "D100", "U", 1234)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Mixed reads with one call
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from slmp import read_named
|
|
131
|
+
|
|
132
|
+
snapshot = await read_named(
|
|
133
|
+
client,
|
|
134
|
+
[
|
|
135
|
+
"D100",
|
|
136
|
+
"D200:F",
|
|
137
|
+
"D300:L",
|
|
138
|
+
"D50.3",
|
|
139
|
+
],
|
|
140
|
+
)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Use `.bit` notation only with word devices such as `D50.3`.
|
|
144
|
+
Address bit devices directly as `M1000`, `M1001`, ... rather than `M1000.0`.
|
|
145
|
+
|
|
146
|
+
For long-device families in the high-level helpers:
|
|
147
|
+
|
|
148
|
+
- `LTN`, `LSTN`, and `LCN` default to 32-bit current-value reads and writes
|
|
149
|
+
- `LTS`, `LTC`, `LSTS`, and `LSTC` are resolved through the corresponding `LTN` / `LSTN` helper-backed 4-word decode instead of direct state reads
|
|
150
|
+
|
|
151
|
+
### Mixed writes with one call
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from slmp import write_named
|
|
155
|
+
|
|
156
|
+
await write_named(
|
|
157
|
+
client,
|
|
158
|
+
{
|
|
159
|
+
"D100": 42,
|
|
160
|
+
"D200:F": 3.14,
|
|
161
|
+
"D300:L": -200,
|
|
162
|
+
"D50.3": True,
|
|
163
|
+
},
|
|
164
|
+
)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The same default applies on writes: plain `LTN`, `LSTN`, and `LCN` addresses are treated as 32-bit current values in the high-level helper layer.
|
|
168
|
+
|
|
169
|
+
### Chunked word and dword reads
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from slmp import read_words, read_dwords
|
|
173
|
+
|
|
174
|
+
words = await read_words(client, "D0", 1000, allow_split=True)
|
|
175
|
+
dwords = await read_dwords(client, "D200", 120, allow_split=True)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Polling
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from slmp import poll
|
|
182
|
+
|
|
183
|
+
async for snapshot in poll(client, ["D100", "D200:F", "D50.3"], interval=1.0):
|
|
184
|
+
print(snapshot)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Shared connection for multiple coroutines
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from slmp import AsyncSlmpClient, QueuedAsyncSlmpClient
|
|
191
|
+
|
|
192
|
+
inner = AsyncSlmpClient("192.168.250.100", port=1025, plc_series="iqr", frame_type="4e")
|
|
193
|
+
async with QueuedAsyncSlmpClient(inner) as client:
|
|
194
|
+
first = await read_named(client, ["D100", "D200:F"])
|
|
195
|
+
second = await read_named(client, ["D300", "D50.3"])
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Sample Programs
|
|
199
|
+
|
|
200
|
+
The buildable sample files with the richest high-level examples are:
|
|
201
|
+
|
|
202
|
+
- [`samples/high_level_sync.py`](samples/high_level_sync.py)
|
|
203
|
+
- typed reads and writes
|
|
204
|
+
- chunked word and dword reads
|
|
205
|
+
- bit-in-word writes
|
|
206
|
+
- mixed `read_named_sync` / `write_named_sync`
|
|
207
|
+
- polling
|
|
208
|
+
- [`samples/high_level_async.py`](samples/high_level_async.py)
|
|
209
|
+
- explicit `AsyncSlmpClient`
|
|
210
|
+
- typed reads and writes
|
|
211
|
+
- chunked reads
|
|
212
|
+
- `read_named` / `write_named`
|
|
213
|
+
- polling
|
|
214
|
+
- shared queued connection example
|
|
215
|
+
|
|
216
|
+
Run them from the repository root:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
python samples/high_level_sync.py --host 192.168.250.100 --port 1025 --series iqr
|
|
220
|
+
python samples/high_level_async.py --host 192.168.250.100 --port 1025 --series iqr --frame-type 4e
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
More sample commands are listed in [docsrc/user/SAMPLES.md](docsrc/user/SAMPLES.md).
|
|
224
|
+
|
|
225
|
+
## Documentation
|
|
226
|
+
|
|
227
|
+
User-facing documents:
|
|
228
|
+
|
|
229
|
+
- [User Guide](docsrc/user/USER_GUIDE.md)
|
|
230
|
+
- [Samples](docsrc/user/SAMPLES.md)
|
|
231
|
+
- [Error Codes](docsrc/user/ERROR_CODES.md)
|
|
232
|
+
|
|
233
|
+
Maintainer and validation material remains in `docsrc/maintainer/` and `docsrc/validation/`.
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
run_ci.bat
|
|
239
|
+
build_docs.bat
|
|
240
|
+
release_check.bat
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
`run_ci.bat` validates the package and also builds the single-file CLI tool in `publish/`.
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
Distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
[](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml)
|
|
2
|
+
[](https://fa-yoshinobu.github.io/plc-comm-slmp-python/)
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://github.com/astral-sh/ruff)
|
|
6
|
+
|
|
7
|
+
# SLMP Protocol for Python
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
High-level SLMP helpers for Mitsubishi PLC communication over Binary 3E and 4E frames.
|
|
12
|
+
|
|
13
|
+
This repository now treats the high-level helper layer as the recommended user surface:
|
|
14
|
+
|
|
15
|
+
- `AsyncSlmpClient`
|
|
16
|
+
- `QueuedAsyncSlmpClient`
|
|
17
|
+
- `SlmpClient`
|
|
18
|
+
- `read_typed` / `write_typed`
|
|
19
|
+
- `read_words` / `read_dwords`
|
|
20
|
+
- `write_bit_in_word`
|
|
21
|
+
- `read_named` / `write_named`
|
|
22
|
+
- `poll`
|
|
23
|
+
|
|
24
|
+
Low-level protocol methods still exist for maintainers and validation work, but they are not the primary user path.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install slmp-connect-python
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Recommended async path:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import asyncio
|
|
38
|
+
|
|
39
|
+
from slmp import AsyncSlmpClient, read_named, write_typed
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def main() -> None:
|
|
43
|
+
async with AsyncSlmpClient(
|
|
44
|
+
"192.168.250.100",
|
|
45
|
+
port=1025,
|
|
46
|
+
plc_series="iqr",
|
|
47
|
+
frame_type="4e",
|
|
48
|
+
) as client:
|
|
49
|
+
before = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
50
|
+
print("before:", before)
|
|
51
|
+
|
|
52
|
+
await write_typed(client, "D100", "U", 42)
|
|
53
|
+
|
|
54
|
+
after = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
55
|
+
print("after:", after)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
asyncio.run(main())
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Choose the connection profile explicitly:
|
|
62
|
+
|
|
63
|
+
- `plc_series="iqr", frame_type="4e"` for iQ-R / iQ-F targets
|
|
64
|
+
- `plc_series="ql", frame_type="3e"` for Q / L targets
|
|
65
|
+
|
|
66
|
+
Recommended sync path:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from slmp import SlmpClient, read_named_sync, write_typed_sync
|
|
70
|
+
|
|
71
|
+
with SlmpClient(
|
|
72
|
+
"192.168.250.100",
|
|
73
|
+
port=1025,
|
|
74
|
+
plc_series="iqr",
|
|
75
|
+
frame_type="4e",
|
|
76
|
+
) as client:
|
|
77
|
+
print(read_named_sync(client, ["D100", "D200:F", "D50.3"]))
|
|
78
|
+
write_typed_sync(client, "D100", "U", 42)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## High-Level API Guide
|
|
82
|
+
|
|
83
|
+
### Single typed values
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from slmp import read_typed, write_typed
|
|
87
|
+
|
|
88
|
+
temperature = await read_typed(client, "D200", "F")
|
|
89
|
+
counter = await read_typed(client, "D300", "L")
|
|
90
|
+
await write_typed(client, "D100", "U", 1234)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Mixed reads with one call
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from slmp import read_named
|
|
97
|
+
|
|
98
|
+
snapshot = await read_named(
|
|
99
|
+
client,
|
|
100
|
+
[
|
|
101
|
+
"D100",
|
|
102
|
+
"D200:F",
|
|
103
|
+
"D300:L",
|
|
104
|
+
"D50.3",
|
|
105
|
+
],
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Use `.bit` notation only with word devices such as `D50.3`.
|
|
110
|
+
Address bit devices directly as `M1000`, `M1001`, ... rather than `M1000.0`.
|
|
111
|
+
|
|
112
|
+
For long-device families in the high-level helpers:
|
|
113
|
+
|
|
114
|
+
- `LTN`, `LSTN`, and `LCN` default to 32-bit current-value reads and writes
|
|
115
|
+
- `LTS`, `LTC`, `LSTS`, and `LSTC` are resolved through the corresponding `LTN` / `LSTN` helper-backed 4-word decode instead of direct state reads
|
|
116
|
+
|
|
117
|
+
### Mixed writes with one call
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from slmp import write_named
|
|
121
|
+
|
|
122
|
+
await write_named(
|
|
123
|
+
client,
|
|
124
|
+
{
|
|
125
|
+
"D100": 42,
|
|
126
|
+
"D200:F": 3.14,
|
|
127
|
+
"D300:L": -200,
|
|
128
|
+
"D50.3": True,
|
|
129
|
+
},
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The same default applies on writes: plain `LTN`, `LSTN`, and `LCN` addresses are treated as 32-bit current values in the high-level helper layer.
|
|
134
|
+
|
|
135
|
+
### Chunked word and dword reads
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from slmp import read_words, read_dwords
|
|
139
|
+
|
|
140
|
+
words = await read_words(client, "D0", 1000, allow_split=True)
|
|
141
|
+
dwords = await read_dwords(client, "D200", 120, allow_split=True)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Polling
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from slmp import poll
|
|
148
|
+
|
|
149
|
+
async for snapshot in poll(client, ["D100", "D200:F", "D50.3"], interval=1.0):
|
|
150
|
+
print(snapshot)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Shared connection for multiple coroutines
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
from slmp import AsyncSlmpClient, QueuedAsyncSlmpClient
|
|
157
|
+
|
|
158
|
+
inner = AsyncSlmpClient("192.168.250.100", port=1025, plc_series="iqr", frame_type="4e")
|
|
159
|
+
async with QueuedAsyncSlmpClient(inner) as client:
|
|
160
|
+
first = await read_named(client, ["D100", "D200:F"])
|
|
161
|
+
second = await read_named(client, ["D300", "D50.3"])
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Sample Programs
|
|
165
|
+
|
|
166
|
+
The buildable sample files with the richest high-level examples are:
|
|
167
|
+
|
|
168
|
+
- [`samples/high_level_sync.py`](samples/high_level_sync.py)
|
|
169
|
+
- typed reads and writes
|
|
170
|
+
- chunked word and dword reads
|
|
171
|
+
- bit-in-word writes
|
|
172
|
+
- mixed `read_named_sync` / `write_named_sync`
|
|
173
|
+
- polling
|
|
174
|
+
- [`samples/high_level_async.py`](samples/high_level_async.py)
|
|
175
|
+
- explicit `AsyncSlmpClient`
|
|
176
|
+
- typed reads and writes
|
|
177
|
+
- chunked reads
|
|
178
|
+
- `read_named` / `write_named`
|
|
179
|
+
- polling
|
|
180
|
+
- shared queued connection example
|
|
181
|
+
|
|
182
|
+
Run them from the repository root:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
python samples/high_level_sync.py --host 192.168.250.100 --port 1025 --series iqr
|
|
186
|
+
python samples/high_level_async.py --host 192.168.250.100 --port 1025 --series iqr --frame-type 4e
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
More sample commands are listed in [docsrc/user/SAMPLES.md](docsrc/user/SAMPLES.md).
|
|
190
|
+
|
|
191
|
+
## Documentation
|
|
192
|
+
|
|
193
|
+
User-facing documents:
|
|
194
|
+
|
|
195
|
+
- [User Guide](docsrc/user/USER_GUIDE.md)
|
|
196
|
+
- [Samples](docsrc/user/SAMPLES.md)
|
|
197
|
+
- [Error Codes](docsrc/user/ERROR_CODES.md)
|
|
198
|
+
|
|
199
|
+
Maintainer and validation material remains in `docsrc/maintainer/` and `docsrc/validation/`.
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
run_ci.bat
|
|
205
|
+
build_docs.bat
|
|
206
|
+
release_check.bat
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`run_ci.bat` validates the package and also builds the single-file CLI tool in `publish/`.
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
Distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "slmp-connect-python"
|
|
7
|
+
version = "0.1.4"
|
|
8
|
+
description = "SLMP Connect Python: client library for Mitsubishi SLMP binary communication"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = []
|
|
12
|
+
authors = [{ name = "fa-yoshinobu" }]
|
|
13
|
+
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
keywords = ["slmp", "melsec", "mitsubishi", "plc", "3e", "4e", "binary"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
|
+
"Topic :: System :: Networking",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/fa-yoshinobu/plc-comm-slmp-python"
|
|
32
|
+
Repository = "https://github.com/fa-yoshinobu/plc-comm-slmp-python"
|
|
33
|
+
Issues = "https://github.com/fa-yoshinobu/plc-comm-slmp-python/issues"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = [
|
|
37
|
+
"build>=1.2",
|
|
38
|
+
"mypy>=1.10",
|
|
39
|
+
"pre-commit>=3.7",
|
|
40
|
+
"pytest>=8.0",
|
|
41
|
+
"pytest-asyncio>=0.23",
|
|
42
|
+
"pytest-cov>=5.0",
|
|
43
|
+
"ruff>=0.6",
|
|
44
|
+
"twine>=5.1",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
slmp-connection-check = "slmp.cli:connection_check_main"
|
|
49
|
+
slmp-compatibility-probe = "slmp.cli:compatibility_probe_main"
|
|
50
|
+
slmp-compatibility-matrix-render = "slmp.cli:compatibility_matrix_render_main"
|
|
51
|
+
slmp-device-range-probe = "slmp.cli:device_range_probe_main"
|
|
52
|
+
slmp-register-boundary-probe = "slmp.cli:register_boundary_probe_main"
|
|
53
|
+
slmp-other-station-check = "slmp.cli:other_station_check_main"
|
|
54
|
+
slmp-open-items-recheck = "slmp.cli:open_items_recheck_main"
|
|
55
|
+
slmp-g-hg-extended-device-recheck = "slmp.cli:g_hg_extended_device_recheck_main"
|
|
56
|
+
slmp-g-hg-extended-device-coverage = "slmp.cli:g_hg_extended_device_coverage_main"
|
|
57
|
+
slmp-extended-device-recheck = "slmp.cli:extended_device_recheck_main"
|
|
58
|
+
slmp-pending-live-verification = "slmp.cli:pending_live_verification_main"
|
|
59
|
+
slmp-init-model-docs = "slmp.cli:init_model_docs_main"
|
|
60
|
+
slmp-device-access-matrix-sync = "slmp.cli:device_access_matrix_sync_main"
|
|
61
|
+
slmp-manual-write-verification = "slmp.cli:manual_write_verification_main"
|
|
62
|
+
slmp-manual-label-verification = "slmp.cli:manual_label_verification_main"
|
|
63
|
+
slmp-read-soak = "slmp.cli:read_soak_main"
|
|
64
|
+
slmp-mixed-read-load = "slmp.cli:mixed_read_load_main"
|
|
65
|
+
slmp-tcp-concurrency = "slmp.cli:tcp_concurrency_main"
|
|
66
|
+
slmp-regression-suite = "slmp.cli:regression_suite_main"
|
|
67
|
+
|
|
68
|
+
[tool.setuptools.packages.find]
|
|
69
|
+
include = ["slmp*"]
|
|
70
|
+
exclude = ["tests*", "scripts*", "docsrc/maintainer*", "docsrc/validation*"]
|
|
71
|
+
|
|
72
|
+
[tool.setuptools]
|
|
73
|
+
include-package-data = true
|
|
74
|
+
exclude-package-data = { "*" = ["TODO.md", ".pre-commit-config.yaml"] }
|
|
75
|
+
|
|
76
|
+
[tool.setuptools.package-data]
|
|
77
|
+
slmp = ["py.typed"]
|
|
78
|
+
|
|
79
|
+
[tool.ruff]
|
|
80
|
+
line-length = 120
|
|
81
|
+
target-version = "py310"
|
|
82
|
+
|
|
83
|
+
[tool.ruff.lint]
|
|
84
|
+
select = ["E", "F", "I", "B", "UP"]
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint.isort]
|
|
87
|
+
known-first-party = ["slmp"]
|
|
88
|
+
|
|
89
|
+
[tool.mypy]
|
|
90
|
+
files = ["slmp"]
|
|
91
|
+
warn_unused_configs = true
|
|
92
|
+
disallow_untyped_defs = true
|
|
93
|
+
check_untyped_defs = true
|
|
94
|
+
disallow_incomplete_defs = true
|
|
95
|
+
no_implicit_optional = true
|
|
96
|
+
warn_redundant_casts = true
|
|
97
|
+
warn_unused_ignores = true
|
|
98
|
+
warn_return_any = true
|
|
99
|
+
strict_equality = true
|
|
100
|
+
|
|
101
|
+
[tool.coverage.run]
|
|
102
|
+
source = ["slmp"]
|
|
103
|
+
branch = true
|
|
104
|
+
|
|
105
|
+
[tool.pytest.ini_options]
|
|
106
|
+
testpaths = ["tests"]
|
|
107
|
+
asyncio_mode = "auto"
|
|
108
|
+
|
|
109
|
+
[tool.coverage.report]
|
|
110
|
+
show_missing = true
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|