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.
Files changed (30) hide show
  1. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/LICENSE +21 -21
  2. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/PKG-INFO +243 -163
  3. slmp_connect_python-0.1.15/README.md +209 -0
  4. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/pyproject.toml +111 -117
  5. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/setup.cfg +4 -4
  6. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/__init__.py +196 -160
  7. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/async_client.py +1478 -1368
  8. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/cli.py +5457 -6193
  9. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/client.py +2042 -1943
  10. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/constants.py +167 -167
  11. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/core.py +1309 -975
  12. slmp_connect_python-0.1.15/slmp/device_ranges.py +814 -0
  13. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/errors.py +25 -25
  14. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/py.typed +1 -1
  15. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp/utils.py +1556 -1333
  16. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/PKG-INFO +243 -163
  17. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/SOURCES.txt +3 -0
  18. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/entry_points.txt +0 -2
  19. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_async_client.py +395 -244
  20. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_bugs_and_edges.py +32 -32
  21. slmp_connect_python-0.1.15/tests/test_cpu_operation_state.py +59 -0
  22. slmp_connect_python-0.1.15/tests/test_device_ranges.py +204 -0
  23. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_device_vectors.py +30 -32
  24. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_shared_spec.py +131 -133
  25. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_slmp.py +2805 -2750
  26. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/tests/test_utils.py +675 -605
  27. slmp_connect_python-0.1.6/README.md +0 -129
  28. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/dependency_links.txt +0 -0
  29. {slmp_connect_python-0.1.6 → slmp_connect_python-0.1.15}/slmp_connect_python.egg-info/requires.txt +0 -0
  30. {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.6
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
- [![CI](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml)
36
- [![Documentation](https://img.shields.io/badge/docs-GitHub_Pages-blue.svg)](https://fa-yoshinobu.github.io/plc-comm-slmp-python/)
37
- [![PyPI](https://img.shields.io/pypi/v/slmp-connect-python.svg)](https://pypi.org/project/slmp-connect-python/)
38
- [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
39
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
40
- [![Static Analysis: Ruff](https://img.shields.io/badge/Lint-Ruff-black.svg)](https://github.com/astral-sh/ruff)
41
-
42
- # SLMP Protocol for Python
43
-
44
- ![Illustration](https://raw.githubusercontent.com/fa-yoshinobu/plc-comm-slmp-python/main/docsrc/assets/melsec.png)
45
-
46
- High-level SLMP helpers for Mitsubishi PLC communication over Binary 3E and 4E frames.
47
-
48
- This repository treats the high-level helper layer as the recommended user surface:
49
-
50
- - `SlmpConnectionOptions`
51
- - `open_and_connect` / `open_and_connect_sync`
52
- - `AsyncSlmpClient`
53
- - `QueuedAsyncSlmpClient`
54
- - `SlmpClient`
55
- - `normalize_address`
56
- - `read_typed` / `write_typed`
57
- - `read_words_single_request` / `read_dwords_single_request`
58
- - `read_words_chunked` / `read_dwords_chunked`
59
- - `write_bit_in_word`
60
- - `read_named` / `write_named`
61
- - `poll`
62
-
63
- ## Installation
64
-
65
- ```bash
66
- pip install slmp-connect-python
67
- ```
68
-
69
- The latest release lives at <https://pypi.org/project/slmp-connect-python/>, where wheel and tarball downloads and metadata are available.
70
-
71
- ## Quick Start
72
-
73
- Recommended async path:
74
-
75
- ```python
76
- import asyncio
77
-
78
- from slmp import SlmpConnectionOptions, open_and_connect, read_named, write_typed
79
-
80
-
81
- async def main() -> None:
82
- options = SlmpConnectionOptions(
83
- host="192.168.250.100",
84
- port=1025,
85
- plc_series="iqr",
86
- frame_type="4e",
87
- )
88
- async with await open_and_connect(options) as client:
89
- before = await read_named(client, ["D100", "D200:F", "D50.3"])
90
- print("before:", before)
91
-
92
- await write_typed(client, "D100", "U", 42)
93
-
94
- after = await read_named(client, ["D100", "D200:F", "D50.3"])
95
- print("after:", after)
96
-
97
-
98
- asyncio.run(main())
99
- ```
100
-
101
- Choose the connection profile explicitly:
102
-
103
- - `plc_series="iqr", frame_type="4e"` for iQ-R / iQ-F targets
104
- - `plc_series="ql", frame_type="3e"` for Q / L targets
105
-
106
- ## Supported PLC Registers
107
-
108
- Start with these public high-level families first:
109
-
110
- - word devices: `D`, `SD`, `R`, `ZR`, `TN`, `CN`
111
- - bit devices: `M`, `X`, `Y`, `SM`, `B`
112
- - typed forms: `D200:F`, `D300:L`, `D100:S`
113
- - mixed snapshot forms: `D50.3`, `D100`, `D200:F`
114
- - current-value long families: `LTN`, `LSTN`, `LCN`
115
-
116
- See the full public table in [Supported PLC Registers](docsrc/user/SUPPORTED_REGISTERS.md).
117
-
118
- ## Public Documentation
119
-
120
- - [Getting Started](docsrc/user/GETTING_STARTED.md)
121
- - [Supported PLC Registers](docsrc/user/SUPPORTED_REGISTERS.md)
122
- - [Latest Communication Verification](docsrc/user/LATEST_COMMUNICATION_VERIFICATION.md)
123
- - [User Guide](docsrc/user/USER_GUIDE.md)
124
- - [Samples](docsrc/user/SAMPLES.md)
125
- - [Error Codes](docsrc/user/ERROR_CODES.md)
126
-
127
- Maintainer-only notes and retained evidence live under `internal_docs/`.
128
-
129
- ## High-Level API Guide
130
-
131
- ### Address Normalization
132
-
133
- ```python
134
- from slmp import normalize_address
135
-
136
- print(normalize_address("x20")) # X20
137
- print(normalize_address("d200")) # D200
138
- ```
139
-
140
- ### Single Typed Values
141
-
142
- ```python
143
- from slmp import read_typed, write_typed
144
-
145
- temperature = await read_typed(client, "D200", "F")
146
- counter = await read_typed(client, "D300", "L")
147
- await write_typed(client, "D100", "U", 1234)
148
- ```
149
-
150
- Use `.bit` notation only with word devices such as `D50.3`.
151
- Address bit devices directly as `M1000`, `M1001`, `X20`, or `Y20`.
152
-
153
- ## Development
154
-
155
- ```bash
156
- run_ci.bat
157
- build_docs.bat
158
- release_check.bat
159
- ```
160
-
161
- ## License
162
-
163
- Distributed under the [MIT License](LICENSE).
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
+ [![CI](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml)
36
+ [![Documentation](https://img.shields.io/badge/docs-GitHub_Pages-blue.svg)](https://fa-yoshinobu.github.io/plc-comm-slmp-python/)
37
+ [![PyPI](https://img.shields.io/pypi/v/slmp-connect-python.svg)](https://pypi.org/project/slmp-connect-python/)
38
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
40
+ [![Static Analysis: Ruff](https://img.shields.io/badge/Lint-Ruff-black.svg)](https://github.com/astral-sh/ruff)
41
+
42
+ # SLMP Protocol for Python
43
+
44
+ ![Illustration](https://raw.githubusercontent.com/fa-yoshinobu/plc-comm-slmp-python/main/docsrc/assets/melsec.png)
45
+
46
+ [![Automated Release](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/automated-release.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/automated-release.yml)
47
+ [![Release](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/release.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/release.yml)
48
+
49
+ [![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white)](https://www.python.org/)
50
+ [![MkDocs](https://img.shields.io/badge/MkDocs-526CFE?logo=materialformkdocs&logoColor=white)](https://www.mkdocs.org/)
51
+ [![GitHub Pages](https://img.shields.io/badge/GitHub%20Pages-222222?logo=githubpages&logoColor=white)](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
+ [![CI](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/ci.yml)
2
+ [![Documentation](https://img.shields.io/badge/docs-GitHub_Pages-blue.svg)](https://fa-yoshinobu.github.io/plc-comm-slmp-python/)
3
+ [![PyPI](https://img.shields.io/pypi/v/slmp-connect-python.svg)](https://pypi.org/project/slmp-connect-python/)
4
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![Static Analysis: Ruff](https://img.shields.io/badge/Lint-Ruff-black.svg)](https://github.com/astral-sh/ruff)
7
+
8
+ # SLMP Protocol for Python
9
+
10
+ ![Illustration](https://raw.githubusercontent.com/fa-yoshinobu/plc-comm-slmp-python/main/docsrc/assets/melsec.png)
11
+
12
+ [![Automated Release](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/automated-release.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/automated-release.yml)
13
+ [![Release](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/release.yml/badge.svg)](https://github.com/fa-yoshinobu/plc-comm-slmp-python/actions/workflows/release.yml)
14
+
15
+ [![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white)](https://www.python.org/)
16
+ [![MkDocs](https://img.shields.io/badge/MkDocs-526CFE?logo=materialformkdocs&logoColor=white)](https://www.mkdocs.org/)
17
+ [![GitHub Pages](https://img.shields.io/badge/GitHub%20Pages-222222?logo=githubpages&logoColor=white)](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).