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