embeddedci-openhtf 2.0.0__tar.gz → 2.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.
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/CHANGELOG.md +14 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/PKG-INFO +19 -7
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/README.md +17 -5
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/examples/flash_and_boot.py +1 -1
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/examples/serial_smoke.py +1 -1
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/examples/station.py +1 -1
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/pyproject.toml +2 -2
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/__init__.py +6 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/analog.py +61 -4
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/phases.py +1 -1
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/pins.py +3 -3
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/_fake.py +20 -10
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_analog.py +30 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_e2e_openhtf.py +21 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_pins.py +1 -1
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/.gitignore +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/LICENSE +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/examples/analog_loopback.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/measurements.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/plug.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/power.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/conftest.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_measurements.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_persistent.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_phases.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_plug.py +0 -0
- {embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/tests/test_power.py +0 -0
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog — `embeddedci-openhtf`
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
- 4-20 mA terminals: `current_out_phase` (and the `current_out` helper) holds a current on the
|
|
6
|
+
output (J9), and `current_in_phase` reads the loop current on the input (J8) and records it
|
|
7
|
+
as `current_in_a` with an optional `(low, high)` limit. Both work in amps.
|
|
8
|
+
`signal_generate_phase` and `dac_replay_phase` accept `dac_path="current_out"`. Needs
|
|
9
|
+
`embeddedci` 2.4 and firmware 3.4.0.
|
|
10
|
+
|
|
11
|
+
## 2.0.1
|
|
12
|
+
|
|
13
|
+
- Docs: LA channels are 1-14 on BenchPod v3 pods with firmware 3.1+ (LA13/LA14), which
|
|
14
|
+
`embeddedci` 2.1 accepts. Now requires `embeddedci>=2.1`, which is where those channels
|
|
15
|
+
became valid.
|
|
16
|
+
|
|
3
17
|
## 2.0.0 — ported to the frozen `embeddedci` 2.0 API
|
|
4
18
|
|
|
5
19
|
The version jumps from 0.1.0 to 2.0.0 to track `embeddedci` 2.x, which this release requires
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: embeddedci-openhtf
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: OpenHTF plug for driving an EmbeddedCI BenchPod directly over TCP or serial (no cloud)
|
|
5
5
|
Project-URL: Homepage, https://embeddedci.com
|
|
6
6
|
Project-URL: Repository, https://github.com/embeddedci-com/embeddedci-python
|
|
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Topic :: Software Development :: Testing
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
|
-
Requires-Dist: embeddedci<3,>=2.
|
|
21
|
+
Requires-Dist: embeddedci<3,>=2.4
|
|
22
22
|
Requires-Dist: openhtf>=1.6
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
@@ -157,7 +157,7 @@ test = htf.Test(
|
|
|
157
157
|
test.execute(test_start=lambda: "SN-0001")
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
LA channels are 1-
|
|
160
|
+
LA channels are 1-14 (the pod has 14 generic logic-analyzer channels and no
|
|
161
161
|
fixed-role pins — wire any DUT signal to any channel and name it here).
|
|
162
162
|
|
|
163
163
|
`flash_phase` needs `openocd` on PATH (the pod is the CMSIS-DAP probe; OpenOCD
|
|
@@ -186,7 +186,8 @@ def boot_and_rail(test, bench):
|
|
|
186
186
|
### Analog steps
|
|
187
187
|
|
|
188
188
|
The pod's DAC output and ADC input are exposed as phases (and low-level helpers).
|
|
189
|
-
Every analog quantity is in **volts**; limits are `(low, high)` volts.
|
|
189
|
+
Every analog quantity is in **volts**; limits are `(low, high)` volts. The two 4-20 mA
|
|
190
|
+
terminals work in **amps**.
|
|
190
191
|
|
|
191
192
|
```python
|
|
192
193
|
import openhtf as htf
|
|
@@ -209,6 +210,9 @@ test = htf.Test(
|
|
|
209
210
|
# a calibrated DC level and a single averaged reading
|
|
210
211
|
dac_output_phase(bench, path="5v", volts=2.5),
|
|
211
212
|
adc_read_phase(bench, source="ext", v_range=(2.4, 2.6)), # records ext_v
|
|
213
|
+
# 4-20 mA: hold 12 mA on the output (J9), read a loop on the input (J8)
|
|
214
|
+
current_out_phase(bench, current=0.012),
|
|
215
|
+
current_in_phase(bench, current_range=(0.0119, 0.0121)), # records current_in_a
|
|
212
216
|
)
|
|
213
217
|
```
|
|
214
218
|
|
|
@@ -216,14 +220,15 @@ test = htf.Test(
|
|
|
216
220
|
| --- | --- |
|
|
217
221
|
| `adc_capture_phase`, `loopback_measure_phase` | `<prefix>_mean_v`, `_pp_v`, `_rms_v`, `_min_v`, `_max_v` (V); samples attached as `adc.json` (`counts` + `volts`) |
|
|
218
222
|
| `adc_read_phase` | `<source>_v` (V) |
|
|
223
|
+
| `current_in_phase` | `current_in_a` (A): the loop current on the 4-20 mA input (J8) |
|
|
219
224
|
| `control_loop_phase` | `control_loop_v` (DAC code), `control_loop_i` (ADC code) |
|
|
220
|
-
| `signal_generate_phase`, `dac_output_phase`, `dac_replay_phase` | log only |
|
|
225
|
+
| `signal_generate_phase`, `dac_output_phase`, `current_out_phase`, `dac_replay_phase` | log only |
|
|
221
226
|
|
|
222
227
|
Notes:
|
|
223
228
|
|
|
224
229
|
- `source` routes the ADC: `"ext"` (front SMA — the default, and the input the
|
|
225
230
|
capture volts are calibrated for), `"cal1"` / `"cal2"` (the 5 V / 12 V DAC looped back
|
|
226
|
-
internally), `"
|
|
231
|
+
internally), `"current_in"`; `source=None` leaves the routing alone.
|
|
227
232
|
- Starting a waveform or a DC output re-applies that DAC path, which opens the internal
|
|
228
233
|
`cal1`/`cal2` loopback relays. Route the ADC **after** starting the DAC —
|
|
229
234
|
`loopback_measure_phase` does this for you.
|
|
@@ -233,12 +238,19 @@ Notes:
|
|
|
233
238
|
`replay_waveform` helpers) switch the pod to the gateware image they need — loop or deep replay —
|
|
234
239
|
automatically (~3 s, logged); pass `switch_image=False` to fail instead. A switch resets the FPGA,
|
|
235
240
|
so start waveforms, UART sessions and I2C sensor emulation after it.
|
|
241
|
+
- The 4-20 mA output (J9) is loop powered: it needs an external **floating** loop supply (8 V
|
|
242
|
+
plus 20 mA times the loop resistance, 30 V at most), and nothing in the loop may touch pod
|
|
243
|
+
ground, also not through a DUT that shares a ground with the pod. Do not wire J9 straight to
|
|
244
|
+
J8. The pod cannot see whether current flows. It shares the DAC with the voltage outputs:
|
|
245
|
+
`current_out_phase` switches them off, and a voltage waveform also moves the loop.
|
|
246
|
+
`signal_generate_phase` and `dac_replay_phase` take `dac_path="current_out"` for a waveform in
|
|
247
|
+
amps. Needs firmware 3.4.0.
|
|
236
248
|
- Use a TCP connection. The STM32 pod's USB serial console is a text shell without a JSON
|
|
237
249
|
mode, so over serial only `power_phase`, status and the LA voltage work; flashing, UART,
|
|
238
250
|
analog and replay phases need TCP (or the cloud).
|
|
239
251
|
|
|
240
252
|
The low-level helpers take a connected `BenchPod` or the injected plug:
|
|
241
|
-
`signal_generate`, `signal_stop`, `analog_path`, `dac_output`, `adc_read`,
|
|
253
|
+
`signal_generate`, `signal_stop`, `analog_path`, `dac_output`, `current_out`, `adc_read`,
|
|
242
254
|
`adc_capture`, `replay`, `replay_waveform`, `control_loop`, `fpga_image`.
|
|
243
255
|
|
|
244
256
|
### Pins, GPIO and timing
|
|
@@ -131,7 +131,7 @@ test = htf.Test(
|
|
|
131
131
|
test.execute(test_start=lambda: "SN-0001")
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
LA channels are 1-
|
|
134
|
+
LA channels are 1-14 (the pod has 14 generic logic-analyzer channels and no
|
|
135
135
|
fixed-role pins — wire any DUT signal to any channel and name it here).
|
|
136
136
|
|
|
137
137
|
`flash_phase` needs `openocd` on PATH (the pod is the CMSIS-DAP probe; OpenOCD
|
|
@@ -160,7 +160,8 @@ def boot_and_rail(test, bench):
|
|
|
160
160
|
### Analog steps
|
|
161
161
|
|
|
162
162
|
The pod's DAC output and ADC input are exposed as phases (and low-level helpers).
|
|
163
|
-
Every analog quantity is in **volts**; limits are `(low, high)` volts.
|
|
163
|
+
Every analog quantity is in **volts**; limits are `(low, high)` volts. The two 4-20 mA
|
|
164
|
+
terminals work in **amps**.
|
|
164
165
|
|
|
165
166
|
```python
|
|
166
167
|
import openhtf as htf
|
|
@@ -183,6 +184,9 @@ test = htf.Test(
|
|
|
183
184
|
# a calibrated DC level and a single averaged reading
|
|
184
185
|
dac_output_phase(bench, path="5v", volts=2.5),
|
|
185
186
|
adc_read_phase(bench, source="ext", v_range=(2.4, 2.6)), # records ext_v
|
|
187
|
+
# 4-20 mA: hold 12 mA on the output (J9), read a loop on the input (J8)
|
|
188
|
+
current_out_phase(bench, current=0.012),
|
|
189
|
+
current_in_phase(bench, current_range=(0.0119, 0.0121)), # records current_in_a
|
|
186
190
|
)
|
|
187
191
|
```
|
|
188
192
|
|
|
@@ -190,14 +194,15 @@ test = htf.Test(
|
|
|
190
194
|
| --- | --- |
|
|
191
195
|
| `adc_capture_phase`, `loopback_measure_phase` | `<prefix>_mean_v`, `_pp_v`, `_rms_v`, `_min_v`, `_max_v` (V); samples attached as `adc.json` (`counts` + `volts`) |
|
|
192
196
|
| `adc_read_phase` | `<source>_v` (V) |
|
|
197
|
+
| `current_in_phase` | `current_in_a` (A): the loop current on the 4-20 mA input (J8) |
|
|
193
198
|
| `control_loop_phase` | `control_loop_v` (DAC code), `control_loop_i` (ADC code) |
|
|
194
|
-
| `signal_generate_phase`, `dac_output_phase`, `dac_replay_phase` | log only |
|
|
199
|
+
| `signal_generate_phase`, `dac_output_phase`, `current_out_phase`, `dac_replay_phase` | log only |
|
|
195
200
|
|
|
196
201
|
Notes:
|
|
197
202
|
|
|
198
203
|
- `source` routes the ADC: `"ext"` (front SMA — the default, and the input the
|
|
199
204
|
capture volts are calibrated for), `"cal1"` / `"cal2"` (the 5 V / 12 V DAC looped back
|
|
200
|
-
internally), `"
|
|
205
|
+
internally), `"current_in"`; `source=None` leaves the routing alone.
|
|
201
206
|
- Starting a waveform or a DC output re-applies that DAC path, which opens the internal
|
|
202
207
|
`cal1`/`cal2` loopback relays. Route the ADC **after** starting the DAC —
|
|
203
208
|
`loopback_measure_phase` does this for you.
|
|
@@ -207,12 +212,19 @@ Notes:
|
|
|
207
212
|
`replay_waveform` helpers) switch the pod to the gateware image they need — loop or deep replay —
|
|
208
213
|
automatically (~3 s, logged); pass `switch_image=False` to fail instead. A switch resets the FPGA,
|
|
209
214
|
so start waveforms, UART sessions and I2C sensor emulation after it.
|
|
215
|
+
- The 4-20 mA output (J9) is loop powered: it needs an external **floating** loop supply (8 V
|
|
216
|
+
plus 20 mA times the loop resistance, 30 V at most), and nothing in the loop may touch pod
|
|
217
|
+
ground, also not through a DUT that shares a ground with the pod. Do not wire J9 straight to
|
|
218
|
+
J8. The pod cannot see whether current flows. It shares the DAC with the voltage outputs:
|
|
219
|
+
`current_out_phase` switches them off, and a voltage waveform also moves the loop.
|
|
220
|
+
`signal_generate_phase` and `dac_replay_phase` take `dac_path="current_out"` for a waveform in
|
|
221
|
+
amps. Needs firmware 3.4.0.
|
|
210
222
|
- Use a TCP connection. The STM32 pod's USB serial console is a text shell without a JSON
|
|
211
223
|
mode, so over serial only `power_phase`, status and the LA voltage work; flashing, UART,
|
|
212
224
|
analog and replay phases need TCP (or the cloud).
|
|
213
225
|
|
|
214
226
|
The low-level helpers take a connected `BenchPod` or the injected plug:
|
|
215
|
-
`signal_generate`, `signal_stop`, `analog_path`, `dac_output`, `adc_read`,
|
|
227
|
+
`signal_generate`, `signal_stop`, `analog_path`, `dac_output`, `current_out`, `adc_read`,
|
|
216
228
|
`adc_capture`, `replay`, `replay_waveform`, `control_loop`, `fpga_image`.
|
|
217
229
|
|
|
218
230
|
### Pins, GPIO and timing
|
|
@@ -24,7 +24,7 @@ from openhtf.output.callbacks import console_summary, json_factory
|
|
|
24
24
|
|
|
25
25
|
from embeddedci_openhtf import benchpod_plug, boot_banner_phase, flash_phase
|
|
26
26
|
|
|
27
|
-
# --- bench wiring (edit for your setup): LA channels 1-
|
|
27
|
+
# --- bench wiring (edit for your setup): LA channels 1-14 -------------------
|
|
28
28
|
LA_VOLTAGE = 3.3 # DUT I/O voltage in volts (1.8 or 3.3)
|
|
29
29
|
SWCLK, SWDIO = 11, 12 # SWD probe -> DUT (LA channels)
|
|
30
30
|
NRESET = True # DUT reset wired to the pod's pin, J1 pin 22
|
|
@@ -28,7 +28,7 @@ from embeddedci import benchpod
|
|
|
28
28
|
from embeddedci_openhtf import benchpod_plug, record_uart
|
|
29
29
|
|
|
30
30
|
LA_VOLTAGE = 3.3 # DUT I/O voltage — change to 1.8 for a 1V8 board
|
|
31
|
-
UART_RX, UART_TX = 1, 2 # edit for your wiring (LA channels 1-
|
|
31
|
+
UART_RX, UART_TX = 1, 2 # edit for your wiring (LA channels 1-14)
|
|
32
32
|
BOOT_BANNER = "APP_OK"
|
|
33
33
|
|
|
34
34
|
|
|
@@ -31,7 +31,7 @@ from embeddedci_openhtf import (
|
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
LA_VOLTAGE = 3.3 # DUT I/O voltage in volts (1.8 or 3.3)
|
|
34
|
-
UART_RX, UART_TX = 1, 2 # edit for your wiring (LA channels 1-
|
|
34
|
+
UART_RX, UART_TX = 1, 2 # edit for your wiring (LA channels 1-14)
|
|
35
35
|
BOOT_BANNER = "APP_OK"
|
|
36
36
|
|
|
37
37
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "embeddedci-openhtf"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.1.0"
|
|
8
8
|
description = "OpenHTF plug for driving an EmbeddedCI BenchPod directly over TCP or serial (no cloud)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -23,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
"Topic :: Software Development :: Testing",
|
|
24
24
|
]
|
|
25
25
|
dependencies = [
|
|
26
|
-
"embeddedci>=2.
|
|
26
|
+
"embeddedci>=2.4,<3",
|
|
27
27
|
"openhtf>=1.6",
|
|
28
28
|
]
|
|
29
29
|
|
|
@@ -32,6 +32,9 @@ from .analog import (
|
|
|
32
32
|
analog_path,
|
|
33
33
|
control_loop,
|
|
34
34
|
control_loop_phase,
|
|
35
|
+
current_in_phase,
|
|
36
|
+
current_out,
|
|
37
|
+
current_out_phase,
|
|
35
38
|
dac_output,
|
|
36
39
|
dac_output_phase,
|
|
37
40
|
dac_replay_phase,
|
|
@@ -78,6 +81,8 @@ __all__ = [
|
|
|
78
81
|
"boot_banner_phase",
|
|
79
82
|
"signal_generate_phase",
|
|
80
83
|
"dac_output_phase",
|
|
84
|
+
"current_out_phase",
|
|
85
|
+
"current_in_phase",
|
|
81
86
|
"adc_read_phase",
|
|
82
87
|
"adc_capture_phase",
|
|
83
88
|
"loopback_measure_phase",
|
|
@@ -98,6 +103,7 @@ __all__ = [
|
|
|
98
103
|
"signal_stop",
|
|
99
104
|
"analog_path",
|
|
100
105
|
"dac_output",
|
|
106
|
+
"current_out",
|
|
101
107
|
"adc_read",
|
|
102
108
|
"adc_capture",
|
|
103
109
|
"replay",
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"""Analog stimulus/acquisition helpers for OpenHTF phases.
|
|
2
2
|
|
|
3
3
|
The BenchPod's analog front end is a DAC output (routed to the 3V3/5V/12V SMA paths) and a
|
|
4
|
-
16-bit ADC input (front SMA, internal DAC loopbacks,
|
|
4
|
+
16-bit ADC input (front SMA, internal DAC loopbacks, 4-20 mA measurement terminal). These helpers and phase
|
|
5
5
|
factories wrap the :class:`~embeddedci.benchpod.BenchPod` analog API and turn its results into
|
|
6
6
|
OpenHTF measurements.
|
|
7
7
|
|
|
8
|
-
**Units are volts, seconds and hertz**, exactly as in the ``embeddedci`` SDK: ``amplitude`` /
|
|
8
|
+
**Units are volts, amps, seconds and hertz**, exactly as in the ``embeddedci`` SDK: ``amplitude`` /
|
|
9
9
|
``offset`` / ``volts`` are volts, ``duration`` / ``settle`` are seconds, ``freq_hz`` /
|
|
10
10
|
``sample_rate_hz`` are hertz, and every recorded analog measurement is in volts (units ``"V"``).
|
|
11
|
+
The two 4-20 mA terminals work in **amps** (``current``, units ``"A"``): 0.012 is 12 mA.
|
|
11
12
|
Invalid arguments raise :class:`ValueError`.
|
|
12
13
|
|
|
13
14
|
The ``bench`` argument to every helper is a connected :class:`~embeddedci.benchpod.BenchPod`
|
|
@@ -38,6 +39,7 @@ from embeddedci.benchpod import (
|
|
|
38
39
|
AnalogPathState,
|
|
39
40
|
Capture,
|
|
40
41
|
ControlLoopHandle,
|
|
42
|
+
CurrentOutput,
|
|
41
43
|
DacHandle,
|
|
42
44
|
DacOutput,
|
|
43
45
|
DacOutputPath,
|
|
@@ -61,6 +63,7 @@ __all__ = [
|
|
|
61
63
|
"signal_stop",
|
|
62
64
|
"analog_path",
|
|
63
65
|
"dac_output",
|
|
66
|
+
"current_out",
|
|
64
67
|
"adc_read",
|
|
65
68
|
"adc_capture",
|
|
66
69
|
"replay",
|
|
@@ -70,6 +73,8 @@ __all__ = [
|
|
|
70
73
|
# phase factories
|
|
71
74
|
"signal_generate_phase",
|
|
72
75
|
"dac_output_phase",
|
|
76
|
+
"current_out_phase",
|
|
77
|
+
"current_in_phase",
|
|
73
78
|
"adc_read_phase",
|
|
74
79
|
"adc_capture_phase",
|
|
75
80
|
"loopback_measure_phase",
|
|
@@ -81,7 +86,7 @@ __all__ = [
|
|
|
81
86
|
_Range = Optional[Tuple[float, float]]
|
|
82
87
|
|
|
83
88
|
#: ADC source -> the named analog path that routes it.
|
|
84
|
-
_ADC_SOURCE_PATH: Dict[str, str] = {"ext": "adc_ext", "cal1": "cal1", "cal2": "cal2", "
|
|
89
|
+
_ADC_SOURCE_PATH: Dict[str, str] = {"ext": "adc_ext", "cal1": "cal1", "cal2": "cal2", "current_in": "current_in"}
|
|
85
90
|
|
|
86
91
|
|
|
87
92
|
# -- low-level helpers (operate on a BenchPod or BenchPodPlug) ---------------
|
|
@@ -119,8 +124,18 @@ def dac_output(bench: Any, path: DacOutputPath, *, volts: Optional[float] = None
|
|
|
119
124
|
return bench.dac_output(path, volts=volts)
|
|
120
125
|
|
|
121
126
|
|
|
127
|
+
def current_out(bench: Any, current: float) -> CurrentOutput:
|
|
128
|
+
"""Hold ``current`` (amps, 0.004 to 0.020) on the 4-20 mA output, terminal J9. Returns a
|
|
129
|
+
:class:`~embeddedci.benchpod.CurrentOutput` (``current`` actually held, ``code``, the range).
|
|
130
|
+
|
|
131
|
+
The output is loop powered: it needs an external **floating** loop supply on J9, and nothing
|
|
132
|
+
in the loop may touch pod ground. It shares the DAC with the voltage outputs, which this
|
|
133
|
+
switches off. See :meth:`BenchPod.current_out <embeddedci.benchpod.BenchPod.current_out>`."""
|
|
134
|
+
return bench.current_out(current)
|
|
135
|
+
|
|
136
|
+
|
|
122
137
|
def adc_read(bench: Any, source: AdcSource = "ext") -> AdcReading:
|
|
123
|
-
"""Route an ADC ``source`` (``ext``/``cal1``/``cal2``/``
|
|
138
|
+
"""Route an ADC ``source`` (``ext``/``cal1``/``cal2``/``current_in``) and return one calibrated
|
|
124
139
|
:class:`~embeddedci.benchpod.AdcReading` (``voltage`` in volts, ``count``). ``ext`` applies
|
|
125
140
|
the front-SMA divider, so ``voltage`` is the true SMA voltage."""
|
|
126
141
|
return bench.adc_read(source)
|
|
@@ -249,6 +264,48 @@ def dac_output_phase(plug: type, *, path: DacOutputPath, volts: Optional[float]
|
|
|
249
264
|
return _out
|
|
250
265
|
|
|
251
266
|
|
|
267
|
+
def current_out_phase(plug: type, *, current: float, name: str = "current_out") -> object:
|
|
268
|
+
"""A setup phase that holds ``current`` (amps) on the 4-20 mA output, terminal J9, e.g. to
|
|
269
|
+
feed a DUT's loop input a known level. ``current=0.004`` returns the loop to its live zero.
|
|
270
|
+
|
|
271
|
+
The output needs an external floating loop supply; the pod cannot see whether current
|
|
272
|
+
flows, so pair this with a measurement on the DUT. It stays held after the phase."""
|
|
273
|
+
if not 0 < float(current) < 1:
|
|
274
|
+
raise ValueError(f"current is in amps (0.004 to 0.020), got {current!r}")
|
|
275
|
+
|
|
276
|
+
@htf.PhaseOptions(name=name)
|
|
277
|
+
@htf.plug(bench=plug)
|
|
278
|
+
def _out(test, bench):
|
|
279
|
+
out = current_out(bench, current)
|
|
280
|
+
test.logger.info("4-20 mA output -> %.3f mA (code %d)", out.current * 1000.0, out.code)
|
|
281
|
+
|
|
282
|
+
return _out
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def current_in_phase(plug: type, *, current_range: _Range = None,
|
|
286
|
+
name: str = "current_in") -> object:
|
|
287
|
+
"""A phase that reads the 4-20 mA input, terminal J8, and records the loop current as
|
|
288
|
+
``current_in_a`` (amps). Pass ``current_range=(low, high)`` in amps for a pass/fail limit,
|
|
289
|
+
e.g. ``(0.0119, 0.0121)`` for 12 mA ± 0.1 mA."""
|
|
290
|
+
_check_range("current_range", current_range)
|
|
291
|
+
meas = htf.Measurement("current_in_a").with_units("A")
|
|
292
|
+
if current_range is not None:
|
|
293
|
+
meas = meas.in_range(current_range[0], current_range[1])
|
|
294
|
+
|
|
295
|
+
@htf.PhaseOptions(name=name)
|
|
296
|
+
@htf.measures(meas)
|
|
297
|
+
@htf.plug(bench=plug)
|
|
298
|
+
def _rd(test, bench):
|
|
299
|
+
r = adc_read(bench, "current_in")
|
|
300
|
+
if r.current is None:
|
|
301
|
+
raise RuntimeError("this pod's firmware does not report the loop current on current_in; "
|
|
302
|
+
"update the firmware")
|
|
303
|
+
test.measurements["current_in_a"] = r.current
|
|
304
|
+
test.logger.info("4-20 mA input = %.3f mA (%.4f V across 249 ohm)", r.current * 1000.0, r.voltage)
|
|
305
|
+
|
|
306
|
+
return _rd
|
|
307
|
+
|
|
308
|
+
|
|
252
309
|
def adc_read_phase(plug: type, *, source: AdcSource = "ext", v_range: _Range = None,
|
|
253
310
|
name: str = "adc_read") -> object:
|
|
254
311
|
"""A phase that routes an ADC ``source`` and records the calibrated reading as
|
|
@@ -62,7 +62,7 @@ def flash_phase(plug: type, *, file: str, target: str,
|
|
|
62
62
|
**flash_kwargs) -> object:
|
|
63
63
|
"""A phase that flashes the DUT over SWD and records the result.
|
|
64
64
|
|
|
65
|
-
``swclk``/``swdio`` are LA channels (1-
|
|
65
|
+
``swclk``/``swdio`` are LA channels (1-14); ``nreset`` is a flag saying the
|
|
66
66
|
target's reset is wired to the pod's reset pin (DUT header J1 pin 22).
|
|
67
67
|
Records a ``flash_ok``
|
|
68
68
|
measurement and attaches the OpenOCD log. By default a failed flash stops the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""LA-pin helpers for OpenHTF phases: GPIO, and timing between two channels.
|
|
2
2
|
|
|
3
|
-
The pod's
|
|
3
|
+
The pod's 14 logic-analyzer channels (LA1-LA14) are its only pins, and each has exactly one
|
|
4
4
|
function at a time — high-Z "LA mode" by default, or claimed by GPIO, a UART proxy, SWD, the
|
|
5
5
|
emulated I2C sensor or a step train. :func:`gpio` claims a channel so the pod can drive or read it;
|
|
6
6
|
:func:`release_gpio` gives it back. Claiming a channel another function owns raises
|
|
@@ -8,7 +8,7 @@ emulated I2C sensor or a step train. :func:`gpio` claims a channel so the pod ca
|
|
|
8
8
|
GPIO channel before a UART session, a flash or sensor emulation uses it. Captures observe every
|
|
9
9
|
channel whatever owns it, which is what :func:`la_delay` measures with.
|
|
10
10
|
|
|
11
|
-
``la`` arguments are an LA channel (1-
|
|
11
|
+
``la`` arguments are an LA channel (1-14 or a :class:`~embeddedci.benchpod.Pin`) or a name from the
|
|
12
12
|
bench's wiring profile — ``benchpod_plug("192.168.1.50", wiring="bench.json")`` then
|
|
13
13
|
``gpio(bench, "TRIGGER")``.
|
|
14
14
|
|
|
@@ -37,7 +37,7 @@ __all__ = [
|
|
|
37
37
|
"la_delay_phase",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
|
-
#: An LA channel: 1-
|
|
40
|
+
#: An LA channel: 1-14, a :class:`Pin`, or a wiring-profile name.
|
|
41
41
|
_LaT = Union[Pin, int, str]
|
|
42
42
|
|
|
43
43
|
|
|
@@ -67,16 +67,18 @@ class FakeTransport(Transport):
|
|
|
67
67
|
self.commands: List[dict] = [] # raw `command` + `samples` requests seen
|
|
68
68
|
self.adc_samples = (adc_samples if adc_samples is not None
|
|
69
69
|
else [0, 64, 128, 192, 255, 192, 128, 64])
|
|
70
|
-
#: Raw
|
|
70
|
+
#: Raw 14-channel LA words a `la_capture` returns (bit n = LA{n+1}).
|
|
71
71
|
self.la_words = la_words if la_words is not None else []
|
|
72
72
|
self.fail_capture = fail_capture
|
|
73
73
|
self.closed = False
|
|
74
74
|
#: Capabilities the fake pod reports (the SDK gates GPIO, triggers and power profiles).
|
|
75
75
|
self.caps = ["la", "la_pins", "gpio_read", "capture_trigger", "power_profile"]
|
|
76
|
+
#: Loop current the fake 4-20 mA input (current_in) reads, in microamps.
|
|
77
|
+
self.loop_ua = 12000
|
|
76
78
|
# LA pin ownership, as the firmware keeps it.
|
|
77
|
-
self.function = {la: "none" for la in range(1,
|
|
78
|
-
self.mode: Dict[int, Any] = {la: None for la in range(1,
|
|
79
|
-
self.level: Dict[int, Any] = {la: None for la in range(1,
|
|
79
|
+
self.function = {la: "none" for la in range(1, 15)}
|
|
80
|
+
self.mode: Dict[int, Any] = {la: None for la in range(1, 15)}
|
|
81
|
+
self.level: Dict[int, Any] = {la: None for la in range(1, 15)}
|
|
80
82
|
#: Levels the "DUT" drives on channels the pod is not driving (bitmask, bit la-1).
|
|
81
83
|
self.inputs = 0
|
|
82
84
|
#: The statistics a power_profile reply carries (µA / mV / µJ / µC, as the firmware sends).
|
|
@@ -123,10 +125,18 @@ class FakeTransport(Transport):
|
|
|
123
125
|
"code": 128 if has_v else -1}
|
|
124
126
|
if cmd == "generate":
|
|
125
127
|
return {"cotrig": bool(req.get("on_capture", False))}
|
|
128
|
+
if cmd == "current_out":
|
|
129
|
+
rng = {"min_ua": 4016, "max_ua": 20078}
|
|
130
|
+
if "ua" not in req:
|
|
131
|
+
return rng
|
|
132
|
+
return {"ua": max(4016, req["ua"]), "code": max(0, round((req["ua"] - 4015.686) / 0.245098)), **rng}
|
|
126
133
|
if cmd == "adc_read":
|
|
127
134
|
src = req.get("source", "ext")
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
reply = {"source": src, "mv": 12034 if src == "ext" else 2502, "count": 63049,
|
|
136
|
+
"span": 3}
|
|
137
|
+
if src == "current_in":
|
|
138
|
+
reply.update(mv=2988, offset_mv=4, ua=self.loop_ua)
|
|
139
|
+
return reply
|
|
130
140
|
if cmd == "dac_control_loop":
|
|
131
141
|
return {"armed": True, "k": req.get("k"), "vmin": req.get("vmin"),
|
|
132
142
|
"vmax": req.get("vmax"), "tick_div": req.get("tick_div"), "curve_pts": 256}
|
|
@@ -138,7 +148,7 @@ class FakeTransport(Transport):
|
|
|
138
148
|
return {"image": self.image, "version": 27, "features": 1 if self.image == 0 else 2}
|
|
139
149
|
return {"image": req.get("image"), "version": 27, "features": 1}
|
|
140
150
|
if cmd == "la_pins":
|
|
141
|
-
return {"pins": [self._pin(la) for la in range(1,
|
|
151
|
+
return {"pins": [self._pin(la) for la in range(1, 15)], "levels": self._levels()}
|
|
142
152
|
if cmd == "gpio":
|
|
143
153
|
return self._gpio(req)
|
|
144
154
|
if cmd == "power_profile":
|
|
@@ -152,16 +162,16 @@ class FakeTransport(Transport):
|
|
|
152
162
|
|
|
153
163
|
def _levels(self) -> int:
|
|
154
164
|
mask = self.inputs
|
|
155
|
-
for la in range(1,
|
|
165
|
+
for la in range(1, 15):
|
|
156
166
|
if self.mode[la] in ("output", "open_drain") and self.level[la] is not None:
|
|
157
167
|
mask = (mask & ~(1 << (la - 1))) | (self.level[la] << (la - 1))
|
|
158
168
|
return mask
|
|
159
169
|
|
|
160
170
|
def _gpio(self, req: dict):
|
|
161
171
|
if "mode" not in req and "level" not in req:
|
|
162
|
-
return {"levels": self._levels(), "pins": [self._pin(la) for la in range(1,
|
|
172
|
+
return {"levels": self._levels(), "pins": [self._pin(la) for la in range(1, 15)]}
|
|
163
173
|
raw = req["la"]
|
|
164
|
-
las = list(range(1,
|
|
174
|
+
las = list(range(1, 15)) if raw == "all" else (raw if isinstance(raw, list) else [raw])
|
|
165
175
|
mode = req.get("mode")
|
|
166
176
|
if mode == "off":
|
|
167
177
|
for la in las:
|
|
@@ -18,6 +18,9 @@ from embeddedci_openhtf import (
|
|
|
18
18
|
benchpod_plug,
|
|
19
19
|
control_loop,
|
|
20
20
|
control_loop_phase,
|
|
21
|
+
current_in_phase,
|
|
22
|
+
current_out,
|
|
23
|
+
current_out_phase,
|
|
21
24
|
dac_output,
|
|
22
25
|
dac_output_phase,
|
|
23
26
|
fpga_image,
|
|
@@ -255,6 +258,33 @@ def test_dac_output_helper_returns_typed_result():
|
|
|
255
258
|
assert tx.commands[-1] == {"cmd": "dac_out", "path": "off"}
|
|
256
259
|
|
|
257
260
|
|
|
261
|
+
# -- the 4-20 mA terminals -----------------------------------------------------------------
|
|
262
|
+
|
|
263
|
+
def test_current_out_phase_holds_amps():
|
|
264
|
+
tx = FakeTransport()
|
|
265
|
+
tx.caps.append("current_out")
|
|
266
|
+
rec = _run(current_out_phase(benchpod_plug(transport=tx), current=0.012))
|
|
267
|
+
assert rec.outcome == tr.Outcome.PASS
|
|
268
|
+
assert tx.commands[-1] == {"cmd": "current_out", "ua": 12000}
|
|
269
|
+
out = current_out(benchpod_plug(transport=tx)(), 0.020)
|
|
270
|
+
assert out.current == pytest.approx(0.020) and out.max_current == pytest.approx(0.020078)
|
|
271
|
+
with pytest.raises(ValueError, match="amps"):
|
|
272
|
+
current_out_phase(benchpod_plug(transport=tx), current=12) # milliamps by mistake
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def test_current_in_phase_records_amps_and_applies_the_limit():
|
|
276
|
+
tx = FakeTransport()
|
|
277
|
+
rec = _run(current_in_phase(benchpod_plug(transport=tx), current_range=(0.0119, 0.0121)))
|
|
278
|
+
assert rec.outcome == tr.Outcome.PASS
|
|
279
|
+
assert tx.commands[-1] == {"cmd": "adc_read", "source": "current_in"}
|
|
280
|
+
assert _value(_phase(rec, "current_in"), "current_in_a") == pytest.approx(0.012)
|
|
281
|
+
tx.loop_ua = 3200 # a transmitter fault level
|
|
282
|
+
rec = _run(current_in_phase(benchpod_plug(transport=tx), current_range=(0.0119, 0.0121)))
|
|
283
|
+
assert rec.outcome == tr.Outcome.FAIL
|
|
284
|
+
with pytest.raises(ValueError, match="current_range"):
|
|
285
|
+
current_in_phase(benchpod_plug(transport=tx), current_range=(0.02, 0.004))
|
|
286
|
+
|
|
287
|
+
|
|
258
288
|
def test_adc_read_phase_records_volts():
|
|
259
289
|
tx = FakeTransport()
|
|
260
290
|
rec = _run(adc_read_phase(benchpod_plug(transport=tx), source="ext", v_range=(11.0, 13.0)))
|
|
@@ -21,6 +21,8 @@ from embeddedci_openhtf import ( # noqa: E402
|
|
|
21
21
|
adc_read_phase,
|
|
22
22
|
benchpod_plug,
|
|
23
23
|
boot_banner_phase,
|
|
24
|
+
current_in_phase,
|
|
25
|
+
current_out_phase,
|
|
24
26
|
dac_output_phase,
|
|
25
27
|
flash_phase,
|
|
26
28
|
power_phase,
|
|
@@ -54,6 +56,25 @@ def test_analog_phases_against_the_pod(benchpod_connection):
|
|
|
54
56
|
assert record.outcome == Outcome.PASS, failed
|
|
55
57
|
|
|
56
58
|
|
|
59
|
+
def test_current_loop_phases_against_the_pod(benchpod_connection):
|
|
60
|
+
"""The 4-20 mA phases with nothing wired: the output takes a level and returns to its live
|
|
61
|
+
zero (no loop supply is needed for the pod to accept it), and the open input reads 0 mA."""
|
|
62
|
+
from embeddedci.benchpod import BenchPod
|
|
63
|
+
|
|
64
|
+
with BenchPod(benchpod_connection, lease=False) as probe:
|
|
65
|
+
if not probe.capabilities.current_out:
|
|
66
|
+
pytest.skip("this pod's firmware has no current_out command")
|
|
67
|
+
if os.environ.get("BENCHPOD_E2E_J8_WIRED") == "1":
|
|
68
|
+
pytest.skip("BENCHPOD_E2E_J8_WIRED=1: something is connected to J8")
|
|
69
|
+
bench = benchpod_plug(benchpod_connection, la_voltage=LA_VOLTAGE)
|
|
70
|
+
record, failed = _run(
|
|
71
|
+
current_out_phase(bench, current=0.012),
|
|
72
|
+
current_out_phase(bench, current=0.004, name="current_out_zero"),
|
|
73
|
+
current_in_phase(bench, current_range=(-0.0001, 0.0001)),
|
|
74
|
+
)
|
|
75
|
+
assert record.outcome == Outcome.PASS, failed
|
|
76
|
+
|
|
77
|
+
|
|
57
78
|
def test_flash_and_boot_phases_against_the_dut(benchpod_connection, pytestconfig):
|
|
58
79
|
firmware = pytestconfig.getoption("benchpod_firmware")
|
|
59
80
|
if not firmware:
|
|
@@ -45,7 +45,7 @@ def _cmds(tx):
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
def la_words(pattern):
|
|
48
|
-
"""Turn ``{la: [0, 1, ...]}`` into packed
|
|
48
|
+
"""Turn ``{la: [0, 1, ...]}`` into packed 14-channel LA words."""
|
|
49
49
|
length = max(len(bits) for bits in pattern.values())
|
|
50
50
|
return [sum(bits[i] << (la - 1) for la, bits in pattern.items() if i < len(bits))
|
|
51
51
|
for i in range(length)]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{embeddedci_openhtf-2.0.0 → embeddedci_openhtf-2.1.0}/src/embeddedci_openhtf/measurements.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|