slmp-connect-python 0.1.6__tar.gz → 0.1.15__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.6 → slmp_connect_python-0.1.15}/LICENSE +21 -21
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/PKG-INFO +243 -163
- slmp_connect_python-0.1.15/README.md +209 -0
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/pyproject.toml +111 -117
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/setup.cfg +4 -4
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/__init__.py +196 -160
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/async_client.py +1478 -1368
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/cli.py +5457 -6193
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/client.py +2042 -1943
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/constants.py +167 -167
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/core.py +1309 -975
- slmp_connect_python-0.1.15/slmp/device_ranges.py +814 -0
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/errors.py +25 -25
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/py.typed +1 -1
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/utils.py +1556 -1333
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/PKG-INFO +243 -163
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/SOURCES.txt +3 -0
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/entry_points.txt +0 -2
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_async_client.py +395 -244
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_bugs_and_edges.py +32 -32
- slmp_connect_python-0.1.15/tests/test_cpu_operation_state.py +59 -0
- slmp_connect_python-0.1.15/tests/test_device_ranges.py +204 -0
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_device_vectors.py +30 -32
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_shared_spec.py +131 -133
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_slmp.py +2805 -2750
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_utils.py +675 -605
- slmp_connect_python-0.1.6/README.md +0 -129
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/dependency_links.txt +0 -0
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/requires.txt +0 -0
- {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/top_level.txt +0 -0
|
@@ -1,21 +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.
|
|
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.
|
|
@@ -1,163 +1,243 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: slmp-connect-python
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: SLMP Connect Python: client library for Mitsubishi SLMP binary communication
|
|
5
|
-
Author: fa-yoshinobu
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/fa-yoshinobu/plc-comm-slmp-python
|
|
8
|
-
Project-URL: Repository, https://github.com/fa-yoshinobu/plc-comm-slmp-python
|
|
9
|
-
Project-URL: Issues, https://github.com/fa-yoshinobu/plc-comm-slmp-python/issues
|
|
10
|
-
Keywords: slmp,melsec,mitsubishi,plc,3e,4e,binary
|
|
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://pypi.org/project/slmp-connect-python/)
|
|
38
|
-
[](https://www.python.org/downloads/)
|
|
39
|
-
[](LICENSE)
|
|
40
|
-
[](https://github.com/astral-sh/ruff)
|
|
41
|
-
|
|
42
|
-
# SLMP Protocol for Python
|
|
43
|
-
|
|
44
|
-

|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
- `
|
|
58
|
-
- `
|
|
59
|
-
- `
|
|
60
|
-
- `
|
|
61
|
-
- `
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
##
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
async
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: slmp-connect-python
|
|
3
|
+
Version: 0.1.15
|
|
4
|
+
Summary: SLMP Connect Python: client library for Mitsubishi SLMP binary communication
|
|
5
|
+
Author: fa-yoshinobu
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/fa-yoshinobu/plc-comm-slmp-python
|
|
8
|
+
Project-URL: Repository, https://github.com/fa-yoshinobu/plc-comm-slmp-python
|
|
9
|
+
Project-URL: Issues, https://github.com/fa-yoshinobu/plc-comm-slmp-python/issues
|
|
10
|
+
Keywords: slmp,melsec,mitsubishi,plc,3e,4e,binary
|
|
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://pypi.org/project/slmp-connect-python/)
|
|
38
|
+
[](https://www.python.org/downloads/)
|
|
39
|
+
[](LICENSE)
|
|
40
|
+
[](https://github.com/astral-sh/ruff)
|
|
41
|
+
|
|
42
|
+
# SLMP Protocol for Python
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
[](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/automated-release.yml)
|
|
47
|
+
[](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/release.yml)
|
|
48
|
+
|
|
49
|
+
[](https://www.python.org/)
|
|
50
|
+
[](https://www.mkdocs.org/)
|
|
51
|
+
[](https://pages.github.com/)
|
|
52
|
+
|
|
53
|
+
High-level SLMP helpers for Mitsubishi PLC communication over Binary 3E and 4E frames.
|
|
54
|
+
|
|
55
|
+
This repository treats the high-level helper layer as the recommended user surface:
|
|
56
|
+
|
|
57
|
+
- `SlmpConnectionOptions`
|
|
58
|
+
- `open_and_connect` / `open_and_connect_sync`
|
|
59
|
+
- `AsyncSlmpClient`
|
|
60
|
+
- `QueuedAsyncSlmpClient`
|
|
61
|
+
- `SlmpClient`
|
|
62
|
+
- `normalize_address`
|
|
63
|
+
- `parse_address` / `try_parse_address` / `format_address`
|
|
64
|
+
- `read_typed` / `write_typed`
|
|
65
|
+
- `read_words_single_request` / `read_dwords_single_request`
|
|
66
|
+
- `read_words_chunked` / `read_dwords_chunked`
|
|
67
|
+
- `write_bit_in_word`
|
|
68
|
+
- `read_named` / `write_named`
|
|
69
|
+
- `poll`
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install slmp-connect-python
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The latest release lives at <https://pypi.org/project/slmp-connect-python/>, where wheel and tarball downloads and metadata are available.
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
Recommended async path:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import asyncio
|
|
85
|
+
|
|
86
|
+
from slmp import SlmpConnectionOptions, open_and_connect, read_named, write_typed
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
async def main() -> None:
|
|
90
|
+
options = SlmpConnectionOptions(
|
|
91
|
+
host="192.168.250.100",
|
|
92
|
+
plc_family="iq-f",
|
|
93
|
+
port=1025,
|
|
94
|
+
)
|
|
95
|
+
async with await open_and_connect(options) as client:
|
|
96
|
+
before = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
97
|
+
print("before:", before)
|
|
98
|
+
|
|
99
|
+
await write_typed(client, "D100", "U", 42)
|
|
100
|
+
|
|
101
|
+
after = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
102
|
+
print("after:", after)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
asyncio.run(main())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Choose canonical `plc_family` explicitly.
|
|
109
|
+
In the recommended high-level helper layer, the only PLC selector is `plc_family`.
|
|
110
|
+
|
|
111
|
+
## High-Level PLC Selection
|
|
112
|
+
|
|
113
|
+
For normal application code:
|
|
114
|
+
|
|
115
|
+
- set `plc_family`
|
|
116
|
+
- let the library derive the fixed frame type, access profile, `X` / `Y` text rule, and device-range family
|
|
117
|
+
- do not pass raw `frame_type`, `plc_series`, or `device_family`
|
|
118
|
+
|
|
119
|
+
| `plc_family` | Derived `frame_type` | Derived `access_profile` | `X` / `Y` text | Derived range family | Notes |
|
|
120
|
+
| --- | --- | --- | --- | --- | --- |
|
|
121
|
+
| `iq-f` | `3e` | `ql` | octal | `iq-f` | live-validated |
|
|
122
|
+
| `iq-r` | `4e` | `iqr` | hexadecimal | `iq-r` | live-validated |
|
|
123
|
+
| `iq-l` | `4e` | `iqr` | hexadecimal | `iq-l` | live-validated on `L16HCPU` |
|
|
124
|
+
| `mx-f` | `4e` | `iqr` | hexadecimal | `mx-f` | provisional; review in `TODO.md` |
|
|
125
|
+
| `mx-r` | `4e` | `iqr` | hexadecimal | `mx-r` | provisional; review in `TODO.md` |
|
|
126
|
+
| `qcpu` | `3e` | `ql` | hexadecimal | `qcpu` | retained path |
|
|
127
|
+
| `lcpu` | `3e` | `ql` | hexadecimal | `lcpu` | retained path |
|
|
128
|
+
| `qnu` | `3e` | `ql` | hexadecimal | `qnu` | retained path |
|
|
129
|
+
| `qnudv` | `3e` | `ql` | hexadecimal | `qnudv` | retained path |
|
|
130
|
+
|
|
131
|
+
Low-level compatibility tools may still work with raw `frame_type` / `plc_series`, but that is not the normal public helper path.
|
|
132
|
+
|
|
133
|
+
High-level accepted `plc_family` values:
|
|
134
|
+
|
|
135
|
+
| Canonical | Typical target | Notes |
|
|
136
|
+
| --- | --- | --- |
|
|
137
|
+
| `iq-f` | FX5 / iQ-F | `X` / `Y` use manual octal text |
|
|
138
|
+
| `iq-r` | iQ-R | `X` / `Y` use hexadecimal text |
|
|
139
|
+
| `iq-l` | iQ-L | independent iQ-L range rules; live-validated on `L16HCPU` |
|
|
140
|
+
| `mx-f` | MX-F | pending live validation |
|
|
141
|
+
| `mx-r` | MX-R | pending live validation |
|
|
142
|
+
| `qcpu` | QCPU | `3e/ql` fixed profile |
|
|
143
|
+
| `lcpu` | LCPU | `3e/ql` fixed profile |
|
|
144
|
+
| `qnu` | QnU | `3e/ql` fixed profile |
|
|
145
|
+
| `qnudv` | QnUDV | `3e/ql` fixed profile |
|
|
146
|
+
|
|
147
|
+
Practical rules:
|
|
148
|
+
|
|
149
|
+
- non-`iQ-F` `X` / `Y`: text such as `X20` / `Y20` is interpreted as hexadecimal
|
|
150
|
+
- `iQ-F` / FX5 `X` / `Y`: text such as `X100` / `Y100` is interpreted as manual octal notation and encoded to the binary numeric value
|
|
151
|
+
- example: `X100` on `iQ-F` becomes binary device number `0x40`
|
|
152
|
+
- if you pass a numeric `DeviceRef`, string notation is already resolved, so `plc_family` is not needed for that one address
|
|
153
|
+
- short aliases such as `iqf`, `iqr`, `q`, `l`, and `qnudvcpu` are rejected
|
|
154
|
+
|
|
155
|
+
## Supported PLC Registers
|
|
156
|
+
|
|
157
|
+
Start with these public high-level families first:
|
|
158
|
+
|
|
159
|
+
- word devices: `D`, `SD`, `R`, `ZR`, `TN`, `CN`
|
|
160
|
+
- bit devices: `M`, `X`, `Y`, `SM`, `B`
|
|
161
|
+
- typed forms: `D200:F`, `D300:L`, `D100:S`
|
|
162
|
+
- mixed snapshot forms: `D50.3`, `D100`, `D200:F`
|
|
163
|
+
- current-value long families: `LTN`, `LSTN`, `LCN`
|
|
164
|
+
- 32-bit index register: `LZ`
|
|
165
|
+
|
|
166
|
+
Long-family route notes:
|
|
167
|
+
|
|
168
|
+
- `LTN`, `LSTN`, `LCN`, and `LZ` default to 32-bit `:D` access in high-level helpers.
|
|
169
|
+
- `LCN` current-value reads and writes use random dword access in the high-level helpers.
|
|
170
|
+
- `LTS`, `LTC`, `LSTS`, and `LSTC` state reads use the long timer 4-word decode helpers.
|
|
171
|
+
- `LCS` and `LCC` state reads use direct bit read.
|
|
172
|
+
- High-level state writes for `LTS`/`LTC`/`LSTS`/`LSTC`/`LCS`/`LCC` use random bit write (`0x1402`).
|
|
173
|
+
- Low-level direct bit writes and direct word writes to these long-family logical forms are guarded before transport.
|
|
174
|
+
|
|
175
|
+
See the full public table in [Supported PLC Registers](docsrc/user/SUPPORTED_REGISTERS.md).
|
|
176
|
+
|
|
177
|
+
## Public Documentation
|
|
178
|
+
|
|
179
|
+
- [Getting Started](docsrc/user/GETTING_STARTED.md)
|
|
180
|
+
- [Supported PLC Registers](docsrc/user/SUPPORTED_REGISTERS.md)
|
|
181
|
+
- [Latest Communication Verification](docsrc/user/LATEST_COMMUNICATION_VERIFICATION.md)
|
|
182
|
+
- [User Guide](docsrc/user/USER_GUIDE.md)
|
|
183
|
+
- [Samples](docsrc/user/SAMPLES.md)
|
|
184
|
+
- [Error Codes](docsrc/user/ERROR_CODES.md)
|
|
185
|
+
|
|
186
|
+
Maintainer-only notes and retained evidence live under `internal_docs/`.
|
|
187
|
+
|
|
188
|
+
## High-Level API Guide
|
|
189
|
+
|
|
190
|
+
### Address Normalization
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
from slmp import format_address, normalize_address, parse_address
|
|
194
|
+
|
|
195
|
+
print(normalize_address("x20")) # X20
|
|
196
|
+
print(normalize_address("d200")) # D200
|
|
197
|
+
print(normalize_address("x100", plc_family="iq-f")) # X100
|
|
198
|
+
|
|
199
|
+
parsed = parse_address("d200:f")
|
|
200
|
+
print(parsed.base_device, parsed.dtype) # D200 F
|
|
201
|
+
print(format_address(parsed)) # D200:F
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Single Typed Values
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from slmp import read_typed, write_typed
|
|
208
|
+
|
|
209
|
+
temperature = await read_typed(client, "D200", "F")
|
|
210
|
+
counter = await read_typed(client, "D300", "L")
|
|
211
|
+
await write_typed(client, "D100", "U", 1234)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Use `.bit` notation only with word devices such as `D50.3`.
|
|
215
|
+
Address bit devices directly as `M1000`, `M1001`, `X20`, or `Y20`.
|
|
216
|
+
For communication, `X` / `Y` string addresses require explicit `plc_family`.
|
|
217
|
+
|
|
218
|
+
### Device Range Catalog
|
|
219
|
+
|
|
220
|
+
Use `plc_family` and read the derived family SD block once.
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
from slmp import SlmpClient
|
|
224
|
+
|
|
225
|
+
with SlmpClient("192.168.250.100", 1025, plc_family="qnu") as client:
|
|
226
|
+
catalog = client.read_device_range_catalog()
|
|
227
|
+
for entry in catalog.entries:
|
|
228
|
+
print(entry.device, entry.point_count, entry.address_range)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
This path does not call `read_type_name()`. The client uses the fixed range family derived from `plc_family`.
|
|
232
|
+
|
|
233
|
+
## Development
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
run_ci.bat
|
|
237
|
+
build_docs.bat
|
|
238
|
+
release_check.bat
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
Distributed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,209 @@
|
|
|
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://pypi.org/project/slmp-connect-python/)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/astral-sh/ruff)
|
|
7
|
+
|
|
8
|
+
# SLMP Protocol for Python
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
[](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/automated-release.yml)
|
|
13
|
+
[](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/release.yml)
|
|
14
|
+
|
|
15
|
+
[](https://www.python.org/)
|
|
16
|
+
[](https://www.mkdocs.org/)
|
|
17
|
+
[](https://pages.github.com/)
|
|
18
|
+
|
|
19
|
+
High-level SLMP helpers for Mitsubishi PLC communication over Binary 3E and 4E frames.
|
|
20
|
+
|
|
21
|
+
This repository treats the high-level helper layer as the recommended user surface:
|
|
22
|
+
|
|
23
|
+
- `SlmpConnectionOptions`
|
|
24
|
+
- `open_and_connect` / `open_and_connect_sync`
|
|
25
|
+
- `AsyncSlmpClient`
|
|
26
|
+
- `QueuedAsyncSlmpClient`
|
|
27
|
+
- `SlmpClient`
|
|
28
|
+
- `normalize_address`
|
|
29
|
+
- `parse_address` / `try_parse_address` / `format_address`
|
|
30
|
+
- `read_typed` / `write_typed`
|
|
31
|
+
- `read_words_single_request` / `read_dwords_single_request`
|
|
32
|
+
- `read_words_chunked` / `read_dwords_chunked`
|
|
33
|
+
- `write_bit_in_word`
|
|
34
|
+
- `read_named` / `write_named`
|
|
35
|
+
- `poll`
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install slmp-connect-python
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The latest release lives at <https://pypi.org/project/slmp-connect-python/>, where wheel and tarball downloads and metadata are available.
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
Recommended async path:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import asyncio
|
|
51
|
+
|
|
52
|
+
from slmp import SlmpConnectionOptions, open_and_connect, read_named, write_typed
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
async def main() -> None:
|
|
56
|
+
options = SlmpConnectionOptions(
|
|
57
|
+
host="192.168.250.100",
|
|
58
|
+
plc_family="iq-f",
|
|
59
|
+
port=1025,
|
|
60
|
+
)
|
|
61
|
+
async with await open_and_connect(options) as client:
|
|
62
|
+
before = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
63
|
+
print("before:", before)
|
|
64
|
+
|
|
65
|
+
await write_typed(client, "D100", "U", 42)
|
|
66
|
+
|
|
67
|
+
after = await read_named(client, ["D100", "D200:F", "D50.3"])
|
|
68
|
+
print("after:", after)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
asyncio.run(main())
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Choose canonical `plc_family` explicitly.
|
|
75
|
+
In the recommended high-level helper layer, the only PLC selector is `plc_family`.
|
|
76
|
+
|
|
77
|
+
## High-Level PLC Selection
|
|
78
|
+
|
|
79
|
+
For normal application code:
|
|
80
|
+
|
|
81
|
+
- set `plc_family`
|
|
82
|
+
- let the library derive the fixed frame type, access profile, `X` / `Y` text rule, and device-range family
|
|
83
|
+
- do not pass raw `frame_type`, `plc_series`, or `device_family`
|
|
84
|
+
|
|
85
|
+
| `plc_family` | Derived `frame_type` | Derived `access_profile` | `X` / `Y` text | Derived range family | Notes |
|
|
86
|
+
| --- | --- | --- | --- | --- | --- |
|
|
87
|
+
| `iq-f` | `3e` | `ql` | octal | `iq-f` | live-validated |
|
|
88
|
+
| `iq-r` | `4e` | `iqr` | hexadecimal | `iq-r` | live-validated |
|
|
89
|
+
| `iq-l` | `4e` | `iqr` | hexadecimal | `iq-l` | live-validated on `L16HCPU` |
|
|
90
|
+
| `mx-f` | `4e` | `iqr` | hexadecimal | `mx-f` | provisional; review in `TODO.md` |
|
|
91
|
+
| `mx-r` | `4e` | `iqr` | hexadecimal | `mx-r` | provisional; review in `TODO.md` |
|
|
92
|
+
| `qcpu` | `3e` | `ql` | hexadecimal | `qcpu` | retained path |
|
|
93
|
+
| `lcpu` | `3e` | `ql` | hexadecimal | `lcpu` | retained path |
|
|
94
|
+
| `qnu` | `3e` | `ql` | hexadecimal | `qnu` | retained path |
|
|
95
|
+
| `qnudv` | `3e` | `ql` | hexadecimal | `qnudv` | retained path |
|
|
96
|
+
|
|
97
|
+
Low-level compatibility tools may still work with raw `frame_type` / `plc_series`, but that is not the normal public helper path.
|
|
98
|
+
|
|
99
|
+
High-level accepted `plc_family` values:
|
|
100
|
+
|
|
101
|
+
| Canonical | Typical target | Notes |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| `iq-f` | FX5 / iQ-F | `X` / `Y` use manual octal text |
|
|
104
|
+
| `iq-r` | iQ-R | `X` / `Y` use hexadecimal text |
|
|
105
|
+
| `iq-l` | iQ-L | independent iQ-L range rules; live-validated on `L16HCPU` |
|
|
106
|
+
| `mx-f` | MX-F | pending live validation |
|
|
107
|
+
| `mx-r` | MX-R | pending live validation |
|
|
108
|
+
| `qcpu` | QCPU | `3e/ql` fixed profile |
|
|
109
|
+
| `lcpu` | LCPU | `3e/ql` fixed profile |
|
|
110
|
+
| `qnu` | QnU | `3e/ql` fixed profile |
|
|
111
|
+
| `qnudv` | QnUDV | `3e/ql` fixed profile |
|
|
112
|
+
|
|
113
|
+
Practical rules:
|
|
114
|
+
|
|
115
|
+
- non-`iQ-F` `X` / `Y`: text such as `X20` / `Y20` is interpreted as hexadecimal
|
|
116
|
+
- `iQ-F` / FX5 `X` / `Y`: text such as `X100` / `Y100` is interpreted as manual octal notation and encoded to the binary numeric value
|
|
117
|
+
- example: `X100` on `iQ-F` becomes binary device number `0x40`
|
|
118
|
+
- if you pass a numeric `DeviceRef`, string notation is already resolved, so `plc_family` is not needed for that one address
|
|
119
|
+
- short aliases such as `iqf`, `iqr`, `q`, `l`, and `qnudvcpu` are rejected
|
|
120
|
+
|
|
121
|
+
## Supported PLC Registers
|
|
122
|
+
|
|
123
|
+
Start with these public high-level families first:
|
|
124
|
+
|
|
125
|
+
- word devices: `D`, `SD`, `R`, `ZR`, `TN`, `CN`
|
|
126
|
+
- bit devices: `M`, `X`, `Y`, `SM`, `B`
|
|
127
|
+
- typed forms: `D200:F`, `D300:L`, `D100:S`
|
|
128
|
+
- mixed snapshot forms: `D50.3`, `D100`, `D200:F`
|
|
129
|
+
- current-value long families: `LTN`, `LSTN`, `LCN`
|
|
130
|
+
- 32-bit index register: `LZ`
|
|
131
|
+
|
|
132
|
+
Long-family route notes:
|
|
133
|
+
|
|
134
|
+
- `LTN`, `LSTN`, `LCN`, and `LZ` default to 32-bit `:D` access in high-level helpers.
|
|
135
|
+
- `LCN` current-value reads and writes use random dword access in the high-level helpers.
|
|
136
|
+
- `LTS`, `LTC`, `LSTS`, and `LSTC` state reads use the long timer 4-word decode helpers.
|
|
137
|
+
- `LCS` and `LCC` state reads use direct bit read.
|
|
138
|
+
- High-level state writes for `LTS`/`LTC`/`LSTS`/`LSTC`/`LCS`/`LCC` use random bit write (`0x1402`).
|
|
139
|
+
- Low-level direct bit writes and direct word writes to these long-family logical forms are guarded before transport.
|
|
140
|
+
|
|
141
|
+
See the full public table in [Supported PLC Registers](docsrc/user/SUPPORTED_REGISTERS.md).
|
|
142
|
+
|
|
143
|
+
## Public Documentation
|
|
144
|
+
|
|
145
|
+
- [Getting Started](docsrc/user/GETTING_STARTED.md)
|
|
146
|
+
- [Supported PLC Registers](docsrc/user/SUPPORTED_REGISTERS.md)
|
|
147
|
+
- [Latest Communication Verification](docsrc/user/LATEST_COMMUNICATION_VERIFICATION.md)
|
|
148
|
+
- [User Guide](docsrc/user/USER_GUIDE.md)
|
|
149
|
+
- [Samples](docsrc/user/SAMPLES.md)
|
|
150
|
+
- [Error Codes](docsrc/user/ERROR_CODES.md)
|
|
151
|
+
|
|
152
|
+
Maintainer-only notes and retained evidence live under `internal_docs/`.
|
|
153
|
+
|
|
154
|
+
## High-Level API Guide
|
|
155
|
+
|
|
156
|
+
### Address Normalization
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from slmp import format_address, normalize_address, parse_address
|
|
160
|
+
|
|
161
|
+
print(normalize_address("x20")) # X20
|
|
162
|
+
print(normalize_address("d200")) # D200
|
|
163
|
+
print(normalize_address("x100", plc_family="iq-f")) # X100
|
|
164
|
+
|
|
165
|
+
parsed = parse_address("d200:f")
|
|
166
|
+
print(parsed.base_device, parsed.dtype) # D200 F
|
|
167
|
+
print(format_address(parsed)) # D200:F
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Single Typed Values
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from slmp import read_typed, write_typed
|
|
174
|
+
|
|
175
|
+
temperature = await read_typed(client, "D200", "F")
|
|
176
|
+
counter = await read_typed(client, "D300", "L")
|
|
177
|
+
await write_typed(client, "D100", "U", 1234)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Use `.bit` notation only with word devices such as `D50.3`.
|
|
181
|
+
Address bit devices directly as `M1000`, `M1001`, `X20`, or `Y20`.
|
|
182
|
+
For communication, `X` / `Y` string addresses require explicit `plc_family`.
|
|
183
|
+
|
|
184
|
+
### Device Range Catalog
|
|
185
|
+
|
|
186
|
+
Use `plc_family` and read the derived family SD block once.
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from slmp import SlmpClient
|
|
190
|
+
|
|
191
|
+
with SlmpClient("192.168.250.100", 1025, plc_family="qnu") as client:
|
|
192
|
+
catalog = client.read_device_range_catalog()
|
|
193
|
+
for entry in catalog.entries:
|
|
194
|
+
print(entry.device, entry.point_count, entry.address_range)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
This path does not call `read_type_name()`. The client uses the fixed range family derived from `plc_family`.
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
run_ci.bat
|
|
203
|
+
build_docs.bat
|
|
204
|
+
release_check.bat
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
Distributed under the [MIT License](LICENSE).
|