scietex.hal.dmm 0.1.0__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 (50) hide show
  1. scietex_hal_dmm-0.1.0/CHANGELOG.md +50 -0
  2. scietex_hal_dmm-0.1.0/LICENSE +21 -0
  3. scietex_hal_dmm-0.1.0/MANIFEST.in +6 -0
  4. scietex_hal_dmm-0.1.0/PKG-INFO +171 -0
  5. scietex_hal_dmm-0.1.0/README.md +139 -0
  6. scietex_hal_dmm-0.1.0/pyproject.toml +71 -0
  7. scietex_hal_dmm-0.1.0/setup.cfg +4 -0
  8. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/__init__.py +15 -0
  9. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/base/__init__.py +103 -0
  10. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/base/capabilities.py +307 -0
  11. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/base/data.py +108 -0
  12. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/base/errors.py +84 -0
  13. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/base/protocol.py +348 -0
  14. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/base/transport.py +108 -0
  15. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/py.typed +0 -0
  16. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/registry.py +71 -0
  17. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/rigol/__init__.py +22 -0
  18. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/rigol/dm3000/__init__.py +47 -0
  19. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/rigol/dm3000/dialect.py +471 -0
  20. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/rigol/dm3000/dm3058e.py +66 -0
  21. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/rigol/dm3000/driver.py +557 -0
  22. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/rigol/dm3000/ranges.py +166 -0
  23. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/transport/__init__.py +42 -0
  24. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/transport/framing.py +81 -0
  25. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/transport/reenumerate.py +167 -0
  26. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/transport/usbtmc.py +552 -0
  27. scietex_hal_dmm-0.1.0/src/scietex/hal/dmm/version.py +1 -0
  28. scietex_hal_dmm-0.1.0/src/scietex.hal.dmm.egg-info/PKG-INFO +171 -0
  29. scietex_hal_dmm-0.1.0/src/scietex.hal.dmm.egg-info/SOURCES.txt +48 -0
  30. scietex_hal_dmm-0.1.0/src/scietex.hal.dmm.egg-info/dependency_links.txt +1 -0
  31. scietex_hal_dmm-0.1.0/src/scietex.hal.dmm.egg-info/entry_points.txt +2 -0
  32. scietex_hal_dmm-0.1.0/src/scietex.hal.dmm.egg-info/requires.txt +12 -0
  33. scietex_hal_dmm-0.1.0/src/scietex.hal.dmm.egg-info/top_level.txt +1 -0
  34. scietex_hal_dmm-0.1.0/tests/base/test_capabilities.py +244 -0
  35. scietex_hal_dmm-0.1.0/tests/base/test_data.py +175 -0
  36. scietex_hal_dmm-0.1.0/tests/base/test_errors.py +70 -0
  37. scietex_hal_dmm-0.1.0/tests/base/test_protocol.py +171 -0
  38. scietex_hal_dmm-0.1.0/tests/conftest.py +37 -0
  39. scietex_hal_dmm-0.1.0/tests/fakes.py +337 -0
  40. scietex_hal_dmm-0.1.0/tests/hardware/test_dm3058e_hardware.py +321 -0
  41. scietex_hal_dmm-0.1.0/tests/rigol/dm3000/test_dialect.py +368 -0
  42. scietex_hal_dmm-0.1.0/tests/rigol/dm3000/test_dm3058e.py +113 -0
  43. scietex_hal_dmm-0.1.0/tests/rigol/dm3000/test_driver.py +565 -0
  44. scietex_hal_dmm-0.1.0/tests/rigol/dm3000/test_entry_point.py +49 -0
  45. scietex_hal_dmm-0.1.0/tests/rigol/dm3000/test_ranges.py +159 -0
  46. scietex_hal_dmm-0.1.0/tests/test_registry.py +141 -0
  47. scietex_hal_dmm-0.1.0/tests/test_version.py +12 -0
  48. scietex_hal_dmm-0.1.0/tests/transport/test_framing.py +86 -0
  49. scietex_hal_dmm-0.1.0/tests/transport/test_reenumerate.py +169 -0
  50. scietex_hal_dmm-0.1.0/tests/transport/test_usbtmc.py +679 -0
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-12-05
11
+
12
+ ### Added
13
+
14
+ - Packaging for `scietex.hal.dmm` with implicit namespace parents under `src/`.
15
+ - Capability model: measurement functions, integration rates, range tables,
16
+ input impedance, command-set dialects and static model specifications.
17
+ - Frozen `msgspec` snapshots (`Identity`, `DmmState`, `Reading`) whose `None`
18
+ fields mean "the driver cannot report this", never zero or `False`.
19
+ - Error hierarchy rooted at `DmmError`, including a SCPI error that keeps the
20
+ numeric code, the device message and the offending command.
21
+ - Transport contract (`TransportProtocol`) for atomic write-then-read queries,
22
+ plus the message-size and error-drain limits.
23
+ - `DigitalMultimeterProtocol`: the transport-agnostic driver contract, with
24
+ capability-derived `supports_*` and `can_*` properties.
25
+ - Pure SCPI framing helpers: command encoding and response splitting that
26
+ discards the padding the kernel `usbtmc` driver leaves past the terminator.
27
+ - Driver registry over the `scietex.hal.dmm.drivers` entry point group; one
28
+ broken entry point does not abort discovery of the rest.
29
+ - `UsbtmcDevice`: a stdlib-only USBTMC transport over `/dev/usbtmcN` with a
30
+ single worker thread, one in-flight read, a 4.5 s guard below the kernel's
31
+ 5 s timeout, padding-tolerant framing and a dead state that only `reset()`
32
+ clears.
33
+ - Sysfs re-enumeration helpers that cycle the USB `authorized` flag and wait
34
+ for the node to reappear.
35
+ - RIGOL DM3000 SCPI dialect: explicit setter, query and reply token tables,
36
+ because `:FUNCtion?` answers with short tokens while the setter takes long
37
+ ones, and `:RATE:<fn>?` answers with full words.
38
+ - `DM3058E` driver: 11 measurement functions, verified range tables, F/M/S
39
+ rate, manual/auto ranging, DC input impedance, identity, error-queue drain
40
+ and transport recovery.
41
+ - Vendor reference in `docs/rigol-dm3058e-scpi.md` extracted from the RIGOL
42
+ programming guide and user's guide and corrected against the instrument.
43
+ - `docs/usbtmc-device.md` covering the device node, udev rule, timeout trap and
44
+ recovery procedure.
45
+
46
+ ### Fixed
47
+
48
+ - USBTMC: terminal failures now force a sysfs power-cycle on the next reset;
49
+ a cancelled query and a blocked `close()` mark the transport dead, and
50
+ `reset()` refuses a never-opened or cleanly closed transport.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anton Bondarenko
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,6 @@
1
+ include LICENSE
2
+ include README.md
3
+ include CHANGELOG.md
4
+ include pyproject.toml
5
+ graft tests
6
+ global-exclude __pycache__ *.py[cod] .pytest_cache
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: scietex.hal.dmm
3
+ Version: 0.1.0
4
+ Summary: Scietex digital multimeter HAL package
5
+ Author-email: Anton Bondarenko <bond.anton@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/bond-anton/scietex.hal.dmm
8
+ Project-URL: Repository, https://github.com/bond-anton/scietex.hal.dmm
9
+ Project-URL: Bug Tracker, https://github.com/bond-anton/scietex.hal.dmm/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: msgspec~=0.20.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: tox>=4.46.0; extra == "dev"
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest; extra == "test"
27
+ Requires-Dist: pytest-asyncio; extra == "test"
28
+ Provides-Extra: lint
29
+ Requires-Dist: ruff; extra == "lint"
30
+ Requires-Dist: ty; extra == "lint"
31
+ Dynamic: license-file
32
+
33
+ # scietex.hal.dmm
34
+
35
+ Hardware abstraction layer for digital multimeters.
36
+
37
+ One driver contract ([`DigitalMultimeterProtocol`](src/scietex/hal/dmm/base/protocol.py)),
38
+ one transport-independent capability model, and vendor drivers behind an
39
+ entry-point registry. The first supported instrument is the RIGOL DM3058E over
40
+ USB-TMC, using the Linux kernel `usbtmc` driver directly with no VISA, no PyUSB
41
+ and no serial dependency.
42
+
43
+ ## Supported instruments
44
+
45
+ | Model | Interface | Status |
46
+ |---|---|---|
47
+ | RIGOL DM3058E | USB-TMC (`/dev/usbtmcN`) | implemented |
48
+ | RIGOL DM3058 | GPIB / LAN / USB-TMC | planned, shares the DM3000 dialect |
49
+ | RIGOL DM3068 | GPIB / LAN / USB-TMC | planned, shares the DM3000 dialect |
50
+
51
+ ## Scope
52
+
53
+ Implemented:
54
+
55
+ - measurement: DCV, ACV, DCI, ACI, 2-wire and 4-wire resistance, frequency,
56
+ period, capacitance, continuity, diode
57
+ - configuration: function select, fixed range by index (`MIN`/`MAX`/`DEF`
58
+ accepted), auto/manual ranging, rate F/M/S, DC input impedance 10 MΩ / 10 GΩ
59
+ where the meter accepts it
60
+ - instrument identity, error-queue drain, `*RST`, `*CLS`, transport recovery
61
+
62
+ Not implemented (v1):
63
+
64
+ - buffered/burst acquisition, `CALCulate` math, dB/dBm, relative (REL), limit
65
+ compare, display text
66
+ - RS-232, LAN and GPIB transports
67
+ - the AGILENT and FLUKE command dialects
68
+
69
+ A driver never substitutes a value. An unreportable field is `None`; an
70
+ unsupported operation raises `NotImplementedError` and is advertised as absent
71
+ in `capabilities`. `None` never means zero.
72
+
73
+ ## Install
74
+
75
+ ```sh
76
+ pip install scietex.hal.dmm
77
+ ```
78
+
79
+ Requires Python 3.10+. The only runtime dependency is `msgspec`.
80
+
81
+ ## Hardware access
82
+
83
+ The device node is root-owned by default; install a udev rule rather than
84
+ running as root. See [docs/usbtmc-device.md](docs/usbtmc-device.md) for the rule,
85
+ the kernel-timeout trap and the re-enumeration recovery drill.
86
+
87
+ ```sh
88
+ lsusb | grep -i rigol # 1ab1:09c4 Rigol Technologies DM3000 SERIES
89
+ ls -l /dev/usbtmc0
90
+ ```
91
+
92
+ ## Usage
93
+
94
+ ```python
95
+ import asyncio
96
+
97
+ from scietex.hal.dmm.base import MeasurementFunction, Rate
98
+ from scietex.hal.dmm.rigol.dm3000 import DM3058E
99
+ from scietex.hal.dmm.transport import UsbtmcDevice
100
+
101
+
102
+ async def main() -> None:
103
+ dmm = DM3058E(UsbtmcDevice("/dev/usbtmc0"))
104
+ if await dmm.connect() is not True:
105
+ raise SystemExit("device did not identify as a DM3058E")
106
+ try:
107
+ print(await dmm.identify())
108
+ await dmm.set_function(MeasurementFunction.DCV)
109
+ await dmm.set_range(2) # 20 V
110
+ await dmm.set_rate(Rate.SLOW) # 2.5 rdg/s, 5.5 digits
111
+ reading = await dmm.measure()
112
+ print(reading.value, reading.unit, reading.overload)
113
+ print("errors:", await dmm.read_errors())
114
+ finally:
115
+ await dmm.close()
116
+
117
+
118
+ asyncio.run(main())
119
+ ```
120
+
121
+ Drivers are also discoverable through the `scietex.hal.dmm.drivers` entry-point
122
+ group:
123
+
124
+ ```python
125
+ from scietex.hal.dmm import resolve_driver
126
+
127
+ driver = resolve_driver("rigol_dm3058e")
128
+ ```
129
+
130
+ For high-rate polling, select the function once and call `measure()` with no
131
+ argument: `measure(function)` sends the function selection and an error-queue
132
+ drain before reading, which costs roughly four times a bare measurement query.
133
+
134
+ ## Capabilities
135
+
136
+ `DM3058E.capabilities` is a frozen dataclass known before the device is opened:
137
+
138
+ ```python
139
+ from scietex.hal.dmm.rigol.dm3000 import DM3058E
140
+
141
+ caps = DM3058E.capabilities
142
+ caps.measurement.functions # all 11 functions
143
+ caps.measurement.ranges_for(f) # tuple[Range, ...] for function f
144
+ caps.measurement.auto_range # write-only: the meter has no range-mode query
145
+ caps.input_impedance.options # (MEG10, GIG10)
146
+ caps.measurement.rate.read # True; the reply is FAST/MEDIUM/SLOW
147
+ ```
148
+
149
+ Check `caps` before calling an optional accessor instead of catching
150
+ `NotImplementedError`.
151
+
152
+ ## Documentation
153
+
154
+ - [docs/rigol-dm3058e-scpi.md](docs/rigol-dm3058e-scpi.md) — SCPI reference
155
+ extracted from the vendor manuals and verified against the instrument: range
156
+ tables, rates, accuracy, error model, gotchas for driver authors
157
+ - [docs/usbtmc-device.md](docs/usbtmc-device.md) — device node, permissions,
158
+ timeout behaviour, recovery procedure
159
+
160
+ ## Testing
161
+
162
+ ```sh
163
+ pytest # offline: fakes and pty-backed transport tests
164
+ RUN_HARDWARE_TESTS=1 pytest -m hardware # against a connected DM3058E
165
+ ```
166
+
167
+ Set `DMM_USBTMC_DEVICE` to point at a node other than `/dev/usbtmc0`.
168
+
169
+ ## License
170
+
171
+ MIT.
@@ -0,0 +1,139 @@
1
+ # scietex.hal.dmm
2
+
3
+ Hardware abstraction layer for digital multimeters.
4
+
5
+ One driver contract ([`DigitalMultimeterProtocol`](src/scietex/hal/dmm/base/protocol.py)),
6
+ one transport-independent capability model, and vendor drivers behind an
7
+ entry-point registry. The first supported instrument is the RIGOL DM3058E over
8
+ USB-TMC, using the Linux kernel `usbtmc` driver directly with no VISA, no PyUSB
9
+ and no serial dependency.
10
+
11
+ ## Supported instruments
12
+
13
+ | Model | Interface | Status |
14
+ |---|---|---|
15
+ | RIGOL DM3058E | USB-TMC (`/dev/usbtmcN`) | implemented |
16
+ | RIGOL DM3058 | GPIB / LAN / USB-TMC | planned, shares the DM3000 dialect |
17
+ | RIGOL DM3068 | GPIB / LAN / USB-TMC | planned, shares the DM3000 dialect |
18
+
19
+ ## Scope
20
+
21
+ Implemented:
22
+
23
+ - measurement: DCV, ACV, DCI, ACI, 2-wire and 4-wire resistance, frequency,
24
+ period, capacitance, continuity, diode
25
+ - configuration: function select, fixed range by index (`MIN`/`MAX`/`DEF`
26
+ accepted), auto/manual ranging, rate F/M/S, DC input impedance 10 MΩ / 10 GΩ
27
+ where the meter accepts it
28
+ - instrument identity, error-queue drain, `*RST`, `*CLS`, transport recovery
29
+
30
+ Not implemented (v1):
31
+
32
+ - buffered/burst acquisition, `CALCulate` math, dB/dBm, relative (REL), limit
33
+ compare, display text
34
+ - RS-232, LAN and GPIB transports
35
+ - the AGILENT and FLUKE command dialects
36
+
37
+ A driver never substitutes a value. An unreportable field is `None`; an
38
+ unsupported operation raises `NotImplementedError` and is advertised as absent
39
+ in `capabilities`. `None` never means zero.
40
+
41
+ ## Install
42
+
43
+ ```sh
44
+ pip install scietex.hal.dmm
45
+ ```
46
+
47
+ Requires Python 3.10+. The only runtime dependency is `msgspec`.
48
+
49
+ ## Hardware access
50
+
51
+ The device node is root-owned by default; install a udev rule rather than
52
+ running as root. See [docs/usbtmc-device.md](docs/usbtmc-device.md) for the rule,
53
+ the kernel-timeout trap and the re-enumeration recovery drill.
54
+
55
+ ```sh
56
+ lsusb | grep -i rigol # 1ab1:09c4 Rigol Technologies DM3000 SERIES
57
+ ls -l /dev/usbtmc0
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ ```python
63
+ import asyncio
64
+
65
+ from scietex.hal.dmm.base import MeasurementFunction, Rate
66
+ from scietex.hal.dmm.rigol.dm3000 import DM3058E
67
+ from scietex.hal.dmm.transport import UsbtmcDevice
68
+
69
+
70
+ async def main() -> None:
71
+ dmm = DM3058E(UsbtmcDevice("/dev/usbtmc0"))
72
+ if await dmm.connect() is not True:
73
+ raise SystemExit("device did not identify as a DM3058E")
74
+ try:
75
+ print(await dmm.identify())
76
+ await dmm.set_function(MeasurementFunction.DCV)
77
+ await dmm.set_range(2) # 20 V
78
+ await dmm.set_rate(Rate.SLOW) # 2.5 rdg/s, 5.5 digits
79
+ reading = await dmm.measure()
80
+ print(reading.value, reading.unit, reading.overload)
81
+ print("errors:", await dmm.read_errors())
82
+ finally:
83
+ await dmm.close()
84
+
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ Drivers are also discoverable through the `scietex.hal.dmm.drivers` entry-point
90
+ group:
91
+
92
+ ```python
93
+ from scietex.hal.dmm import resolve_driver
94
+
95
+ driver = resolve_driver("rigol_dm3058e")
96
+ ```
97
+
98
+ For high-rate polling, select the function once and call `measure()` with no
99
+ argument: `measure(function)` sends the function selection and an error-queue
100
+ drain before reading, which costs roughly four times a bare measurement query.
101
+
102
+ ## Capabilities
103
+
104
+ `DM3058E.capabilities` is a frozen dataclass known before the device is opened:
105
+
106
+ ```python
107
+ from scietex.hal.dmm.rigol.dm3000 import DM3058E
108
+
109
+ caps = DM3058E.capabilities
110
+ caps.measurement.functions # all 11 functions
111
+ caps.measurement.ranges_for(f) # tuple[Range, ...] for function f
112
+ caps.measurement.auto_range # write-only: the meter has no range-mode query
113
+ caps.input_impedance.options # (MEG10, GIG10)
114
+ caps.measurement.rate.read # True; the reply is FAST/MEDIUM/SLOW
115
+ ```
116
+
117
+ Check `caps` before calling an optional accessor instead of catching
118
+ `NotImplementedError`.
119
+
120
+ ## Documentation
121
+
122
+ - [docs/rigol-dm3058e-scpi.md](docs/rigol-dm3058e-scpi.md) — SCPI reference
123
+ extracted from the vendor manuals and verified against the instrument: range
124
+ tables, rates, accuracy, error model, gotchas for driver authors
125
+ - [docs/usbtmc-device.md](docs/usbtmc-device.md) — device node, permissions,
126
+ timeout behaviour, recovery procedure
127
+
128
+ ## Testing
129
+
130
+ ```sh
131
+ pytest # offline: fakes and pty-backed transport tests
132
+ RUN_HARDWARE_TESTS=1 pytest -m hardware # against a connected DM3058E
133
+ ```
134
+
135
+ Set `DMM_USBTMC_DEVICE` to point at a node other than `/dev/usbtmc0`.
136
+
137
+ ## License
138
+
139
+ MIT.
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scietex.hal.dmm"
7
+ dynamic = ["version"]
8
+ description = "Scietex digital multimeter HAL package"
9
+ authors = [{ name = "Anton Bondarenko", email = "bond.anton@gmail.com" }]
10
+ license = "MIT"
11
+ license-files = ["LICEN[CS]E*"]
12
+ readme = "README.md"
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Typing :: Typed",
23
+ ]
24
+ requires-python = ">=3.10"
25
+ dependencies = [
26
+ "msgspec ~= 0.20.0",
27
+ ]
28
+
29
+ [project.urls]
30
+ "Homepage" = "https://github.com/bond-anton/scietex.hal.dmm"
31
+ "Repository" = "https://github.com/bond-anton/scietex.hal.dmm"
32
+ "Bug Tracker" = "https://github.com/bond-anton/scietex.hal.dmm/issues"
33
+
34
+ [project.optional-dependencies]
35
+ dev = ["tox>=4.46.0"]
36
+ test = ["pytest", "pytest-asyncio"]
37
+ lint = ["ruff", "ty"]
38
+
39
+ [project.entry-points."scietex.hal.dmm.drivers"]
40
+ rigol_dm3058e = "scietex.hal.dmm.rigol.dm3000:DM3058E"
41
+
42
+ [tool.setuptools.dynamic]
43
+ version = { attr = "scietex.hal.dmm.version.__version__" }
44
+
45
+ [tool.setuptools.package-data]
46
+ "scietex.hal.dmm" = ["py.typed"]
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
50
+
51
+ [tool.pytest.ini_options]
52
+ pythonpath = ["src"]
53
+ testpaths = ["tests"]
54
+ markers = [
55
+ "hardware: requires a connected RIGOL DM3058E on the configured usbtmc node (set RUN_HARDWARE_TESTS=1)",
56
+ ]
57
+ asyncio_default_fixture_loop_scope = "function"
58
+
59
+ [tool.ruff]
60
+ line-length = 88
61
+ target-version = "py310"
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E4", "E7", "E9", "F", "W", "I", "B", "C4", "SIM", "UP", "PLC0415", "PLR0913", "PLR0917"]
65
+ ignore = ["E501"]
66
+
67
+ [tool.ruff.format]
68
+ quote-style = "double"
69
+
70
+ [tool.ty.environment]
71
+ python-version = "3.10"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ """Scietex digital multimeter HAL package.
2
+
3
+ A digital multimeter measures voltage, current, resistance, frequency,
4
+ capacitance, continuity and diode drop, one function at a time. This package
5
+ defines the capability model that tells a caller which of those functions, ranges
6
+ and switches a given meter supports, the frozen snapshots it reports, the
7
+ transport and driver contracts a concrete instrument implements, and the registry
8
+ that resolves a driver by name.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from .version import __version__
14
+
15
+ __all__ = ["__version__"]
@@ -0,0 +1,103 @@
1
+ """
2
+ Base digital multimeter subpackage.
3
+
4
+ Holds the transport-agnostic pieces every driver shares: the capability model
5
+ that advertises what a meter can do, the frozen snapshots it reports, the error
6
+ hierarchy, the transport contract, and the driver contract concrete protocols
7
+ implement.
8
+
9
+ Modules:
10
+ capabilities: Defines the capability model and the SCPI spelling enums.
11
+ data: Defines the identity, state and reading structs.
12
+ errors: Defines the errors shared by drivers.
13
+ protocol: Defines the `DigitalMultimeterProtocol` driver contract.
14
+ transport: Defines the `TransportProtocol` byte-pipe contract and the
15
+ message-size limits.
16
+
17
+ Exports:
18
+ Access: Whether a setting can be read and whether it can be written.
19
+ CommandSet: The SCPI dialect a meter speaks.
20
+ DigitalMultimeterProtocol: The contract every digital multimeter driver
21
+ implements.
22
+ DmmCapabilities: The complete capability set for one meter.
23
+ DmmError: Base class for every error raised by this package.
24
+ DmmSpecifications: Static limit data for one model.
25
+ DmmState: The function, range and switches a meter currently reports.
26
+ FramingError: A response is not one terminated SCPI message.
27
+ FunctionCapabilities: The supported functions and their range tables.
28
+ Identity: The vendor, model, serial and firmware strings of one meter.
29
+ InputImpedance: The selectable DC voltage input impedance.
30
+ InputImpedanceCapabilities: The input impedance switch and its options.
31
+ MAX_ERROR_DRAIN: Largest number of error-queue entries a drain may read.
32
+ MAX_MESSAGE_BYTES: Largest single response a transport may return.
33
+ MeasurementFunction: The measurement functions a meter can select.
34
+ RATE_READINGS_PER_SECOND: Readings per second for each integration rate.
35
+ Range: One fixed measurement range.
36
+ RangeSelector: The range selection sentinels accepted by a command.
37
+ Rate: The integration rate the meter applies to one reading.
38
+ Reading: One measurement value with its unit and function.
39
+ ScpiError: The device reported a SCPI error for a command.
40
+ TransportClosed: The transport was used after it was closed.
41
+ TransportError: The byte pipe failed.
42
+ TransportProtocol: A byte pipe to one instrument.
43
+ TransportTimeout: A transport operation exceeded its deadline.
44
+ UnexpectedResponse: A response cannot belong to the command it answers.
45
+ """
46
+
47
+ from __future__ import annotations
48
+
49
+ from .capabilities import (
50
+ RATE_READINGS_PER_SECOND,
51
+ Access,
52
+ CommandSet,
53
+ DmmCapabilities,
54
+ DmmSpecifications,
55
+ FunctionCapabilities,
56
+ InputImpedance,
57
+ InputImpedanceCapabilities,
58
+ MeasurementFunction,
59
+ Range,
60
+ RangeSelector,
61
+ Rate,
62
+ )
63
+ from .data import DmmState, Identity, Reading
64
+ from .errors import (
65
+ DmmError,
66
+ FramingError,
67
+ ScpiError,
68
+ TransportClosed,
69
+ TransportError,
70
+ TransportTimeout,
71
+ UnexpectedResponse,
72
+ )
73
+ from .protocol import DigitalMultimeterProtocol
74
+ from .transport import MAX_ERROR_DRAIN, MAX_MESSAGE_BYTES, TransportProtocol
75
+
76
+ __all__ = [
77
+ "Access",
78
+ "CommandSet",
79
+ "DigitalMultimeterProtocol",
80
+ "DmmCapabilities",
81
+ "DmmError",
82
+ "DmmSpecifications",
83
+ "DmmState",
84
+ "FramingError",
85
+ "FunctionCapabilities",
86
+ "Identity",
87
+ "InputImpedance",
88
+ "InputImpedanceCapabilities",
89
+ "MAX_ERROR_DRAIN",
90
+ "MAX_MESSAGE_BYTES",
91
+ "MeasurementFunction",
92
+ "RATE_READINGS_PER_SECOND",
93
+ "Range",
94
+ "RangeSelector",
95
+ "Rate",
96
+ "Reading",
97
+ "ScpiError",
98
+ "TransportClosed",
99
+ "TransportError",
100
+ "TransportProtocol",
101
+ "TransportTimeout",
102
+ "UnexpectedResponse",
103
+ ]