embeddedci 0.2.2__tar.gz → 0.2.3__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 (75) hide show
  1. embeddedci-0.2.3/.gitignore +20 -0
  2. embeddedci-0.2.3/LICENSE +202 -0
  3. {embeddedci-0.2.2 → embeddedci-0.2.3}/PKG-INFO +124 -19
  4. {embeddedci-0.2.2 → embeddedci-0.2.3}/README.md +117 -16
  5. {embeddedci-0.2.2 → embeddedci-0.2.3}/docs/event-uart-design.md +1 -1
  6. {embeddedci-0.2.2 → embeddedci-0.2.3}/pyproject.toml +9 -3
  7. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/__init__.py +50 -0
  8. embeddedci-0.2.3/src/embeddedci/benchpod/can.py +253 -0
  9. embeddedci-0.2.3/src/embeddedci/benchpod/capabilities.py +275 -0
  10. embeddedci-0.2.3/src/embeddedci/benchpod/capture.py +169 -0
  11. embeddedci-0.2.3/src/embeddedci/benchpod/ci.py +297 -0
  12. embeddedci-0.2.3/src/embeddedci/benchpod/client.py +1042 -0
  13. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/connection.py +29 -0
  14. embeddedci-0.2.3/src/embeddedci/benchpod/control_loop.py +136 -0
  15. embeddedci-0.2.3/src/embeddedci/benchpod/decode.py +259 -0
  16. embeddedci-0.2.3/src/embeddedci/benchpod/discovery.py +101 -0
  17. embeddedci-0.2.3/src/embeddedci/benchpod/dsp.py +269 -0
  18. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/errors.py +17 -0
  19. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/i2c.py +17 -0
  20. embeddedci-0.2.3/src/embeddedci/benchpod/lease.py +185 -0
  21. embeddedci-0.2.3/src/embeddedci/benchpod/pytest_plugin.py +412 -0
  22. embeddedci-0.2.3/src/embeddedci/benchpod/replay.py +113 -0
  23. embeddedci-0.2.3/src/embeddedci/benchpod/results.py +152 -0
  24. embeddedci-0.2.3/src/embeddedci/benchpod/server_api.py +176 -0
  25. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/transport/base.py +21 -9
  26. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/transport/cloud.py +9 -1
  27. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/transport/serial.py +10 -11
  28. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/transport/tcp.py +81 -15
  29. embeddedci-0.2.3/src/embeddedci/benchpod/waveforms.py +165 -0
  30. embeddedci-0.2.3/tests/examples/test_can_ecu_demo.py +138 -0
  31. embeddedci-0.2.3/tests/examples/test_can_loopback_hil.py +91 -0
  32. embeddedci-0.2.3/tests/test_adc_fft_hw.py +72 -0
  33. embeddedci-0.2.3/tests/test_can.py +300 -0
  34. embeddedci-0.2.3/tests/test_capabilities.py +65 -0
  35. embeddedci-0.2.3/tests/test_capture.py +85 -0
  36. embeddedci-0.2.3/tests/test_capture_replay_hw.py +67 -0
  37. embeddedci-0.2.3/tests/test_ci.py +92 -0
  38. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_cloud.py +5 -5
  39. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_connection.py +40 -0
  40. embeddedci-0.2.3/tests/test_control_loop.py +200 -0
  41. embeddedci-0.2.3/tests/test_control_loop_hw.py +82 -0
  42. embeddedci-0.2.3/tests/test_decode.py +97 -0
  43. embeddedci-0.2.3/tests/test_dsp.py +114 -0
  44. embeddedci-0.2.3/tests/test_i2c_parity.py +89 -0
  45. embeddedci-0.2.3/tests/test_lease.py +71 -0
  46. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_protocol.py +2 -2
  47. embeddedci-0.2.3/tests/test_replay.py +103 -0
  48. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_serial_json.py +2 -2
  49. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_tcp_transport.py +67 -7
  50. embeddedci-0.2.3/tests/test_waveforms.py +104 -0
  51. embeddedci-0.2.3/tests/testdata/i2c_decode_vectors.json +332 -0
  52. embeddedci-0.2.2/.gitignore +0 -13
  53. embeddedci-0.2.2/src/embeddedci/benchpod/client.py +0 -355
  54. embeddedci-0.2.2/src/embeddedci/benchpod/pytest_plugin.py +0 -189
  55. {embeddedci-0.2.2 → embeddedci-0.2.3}/examples/README.md +0 -0
  56. {embeddedci-0.2.2 → embeddedci-0.2.3}/examples/test_bmp280.py +0 -0
  57. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/__init__.py +0 -0
  58. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/cloud_auth.py +0 -0
  59. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/constants.py +0 -0
  60. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/flash.py +0 -0
  61. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/protocol.py +0 -0
  62. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/sensor.py +0 -0
  63. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/transport/__init__.py +0 -0
  64. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/benchpod/uart.py +0 -0
  65. {embeddedci-0.2.2 → embeddedci-0.2.3}/src/embeddedci/py.typed +0 -0
  66. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/conftest.py +0 -0
  67. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/examples/test_bmp280_hil.py +0 -0
  68. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/examples/test_smoke.py +0 -0
  69. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_flash_bridge.py +0 -0
  70. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_i2c_decode.py +0 -0
  71. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_integration.py +0 -0
  72. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_sensor.py +0 -0
  73. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_timed_power.py +0 -0
  74. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_uart_capture.py +0 -0
  75. {embeddedci-0.2.2 → embeddedci-0.2.3}/tests/test_uart_session.py +0 -0
@@ -0,0 +1,20 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .pytest_cache/
6
+
7
+ # Build artifacts
8
+ build/
9
+ dist/
10
+
11
+ # Virtualenvs
12
+ .venv/
13
+ venv/
14
+
15
+ # ADC FFT capture outputs (scripts/adc_fft_capture.py)
16
+ adc_capture_*.csv
17
+ adc_capture_*.json
18
+ adc_capture_*.png
19
+
20
+ .DS_Store
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -1,16 +1,16 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: embeddedci
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: BenchPod pytest client for EmbeddedCI hardware-in-the-loop testing
5
5
  Project-URL: Homepage, https://embeddedci.com
6
6
  Project-URL: Repository, https://github.com/embeddedci-com/embeddedci-python
7
7
  Project-URL: Issues, https://github.com/embeddedci-com/embeddedci-python/issues
8
8
  Author: EmbeddedCI
9
- License: Apache-2.0
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
10
11
  Keywords: benchpod,embedded,hardware-in-the-loop,openocd,pytest,swd
11
12
  Classifier: Development Status :: 3 - Alpha
12
13
  Classifier: Framework :: Pytest
13
- Classifier: License :: OSI Approved :: Apache Software License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Programming Language :: Python :: 3
16
16
  Classifier: Programming Language :: Python :: 3.9
@@ -21,11 +21,15 @@ Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Topic :: Software Development :: Testing
22
22
  Requires-Python: >=3.9
23
23
  Requires-Dist: pyserial>=3.5
24
+ Provides-Extra: analysis
25
+ Requires-Dist: numpy>=1.21; extra == 'analysis'
24
26
  Provides-Extra: cloud
25
27
  Requires-Dist: websocket-client>=1.6; extra == 'cloud'
26
28
  Provides-Extra: dev
27
29
  Requires-Dist: pytest>=7.0; extra == 'dev'
28
30
  Requires-Dist: websocket-client>=1.6; extra == 'dev'
31
+ Provides-Extra: discovery
32
+ Requires-Dist: zeroconf>=0.131; extra == 'discovery'
29
33
  Description-Content-Type: text/markdown
30
34
 
31
35
  # embeddedci (BenchPod pytest library)
@@ -66,23 +70,22 @@ with benchpod.BenchPod("192.168.1.213") as bp: # or "/dev/ttyACM0", or "serial
66
70
  pip install embeddedci
67
71
  # for the cloud (embeddedci:<device>) destination, add the cloud extra:
68
72
  pip install "embeddedci[cloud]"
73
+ # optional: numpy-backed FFT helpers on captures (Capture.fft / dominant_frequency)
74
+ pip install "embeddedci[analysis]"
69
75
  ```
70
76
 
71
77
  The `[cloud]` extra pulls in a WebSocket client used only by the `embeddedci:` destination;
72
- local wifi/serial use needs nothing extra.
78
+ local wifi/serial use needs nothing extra. The `[analysis]` extra adds numpy for the FFT helpers
79
+ — the mean/rms/peak-to-peak reductions are pure-Python and always available.
73
80
 
74
81
  ### OpenOCD (required for flashing)
75
82
 
76
- Flashing shells out to **OpenOCD**, which must be on your `PATH`. It drives the pod's SWD probe
77
- through OpenOCD's `remote_bitbang` adapter in **SWD** mode — and **SWD support for `remote_bitbang`
78
- only exists in OpenOCD *master* (post‑0.12.0)**. The stock packages (`apt install openocd`,
79
- `brew install open-ocd`) are **0.12.0**, whose `remote_bitbang` is `jtag_only`; flashing with them
80
- fails immediately:
81
-
82
- ```
83
- Info : only one transport option; autoselect 'jtag'
84
- Error: Can't change session's transport after the initial selection was made
85
- ```
83
+ Flashing shells out to **OpenOCD**, which must be on your `PATH`. The pod runs a **CMSIS-DAP**
84
+ processor locally; the library drives it through OpenOCD's `cmsis-dap` adapter using its **TCP
85
+ backend** (`cmsis_dap_tcp`), shipping whole DAP transfers rather than per-bit toggles. That backend
86
+ **only exists in OpenOCD *master* (post‑0.12.0)**. The stock packages (`apt install openocd`,
87
+ `brew install open-ocd`) are **0.12.0** and lack it; flashing with them fails up front with a clear
88
+ message.
86
89
 
87
90
  Install a master snapshot instead — the easiest is **xPack OpenOCD**:
88
91
 
@@ -92,11 +95,11 @@ npm install -g @xpack-dev-tools/openocd
92
95
  # or: https://github.com/xpack-dev-tools/openocd-xpack/releases (extract, add bin/ to PATH)
93
96
  ```
94
97
 
95
- Verify your OpenOCD can do SWD over `remote_bitbang`:
98
+ Verify your OpenOCD has the CMSIS-DAP TCP backend:
96
99
 
97
100
  ```bash
98
- openocd -c "adapter driver remote_bitbang" -c "transport list" -c "exit"
99
- # must list: jtag swd (if only 'jtag', it's too old)
101
+ openocd -c "adapter driver cmsis-dap" -c "cmsis-dap backend tcp" -c "exit"
102
+ # must NOT error on the 'backend tcp' line (if it errors, the build is too old)
100
103
  ```
101
104
 
102
105
  ## Named constants (no magic numbers)
@@ -200,11 +203,113 @@ the **token request itself failed**.
200
203
  | Connect (wifi + serial) | ✅ |
201
204
  | Connect (cloud via GitHub OIDC) | ✅ server + SDK; device firmware tunnel pending on-hardware bring-up |
202
205
  | Power on/off (+ scheduled delay) | ✅ |
203
- | Flash + assert ok/not ok | ✅ (pure-Python OpenOCD `remote_bitbang` bridge) |
206
+ | Flash + assert ok/not ok | ✅ (pure-Python OpenOCD `cmsis-dap` TCP bridge) |
204
207
  | Emulated I2C sensor (BMP280) | ✅ wifi + serial (serial via `json` console mode) |
205
208
  | I2C bus decode (`benchpod.i2c`) | ✅ START/STOP, R/W, ACK, register reads |
209
+ | Protocol decode I2C / UART / SPI (`bp.decode`) | ✅ off-device, parity-checked vs the server |
206
210
  | UART capture (`capture_uart`) | ✅ wifi + serial |
207
- | Signal helpers (`capture`, `gpio_set`) | ✅ minimal, TCP transport only |
211
+ | ADC scope capture → calibrated volts (`scope_capture`) | ✅ LAN + cloud tunnel |
212
+ | Raw 12-ch LA capture (`capture_la`) | ✅ LAN + cloud tunnel |
213
+ | Correlated ADC + LA capture (`capture_analog`) | ✅ one hardware trigger, aligned |
214
+ | DAC generate / DC / replay (`generate`, `dac_set`, `replay`) | ✅ looping, concurrent-with-capture (gw v18) |
215
+ | Cloud waveform library + replay (`bp.waveforms`, `replay_waveform`) | ✅ cloud (OIDC) or an API key on LAN (see below) |
216
+ | DAC↔capture co-trigger + auto-stop (`replay(..., on_capture=True)`, `capture_*(stop_dac_after_us=…)`) | ✅ phase-locked to capture t0 (gw v27 / v21) |
217
+ | Closed-loop DAC control — panel/MPPT emulator (`control_loop`, `loop_probe`) | ✅ needs the loop gateware image (`fpga_image`) |
218
+ | Runtime gateware image swap (`fpga_image`) | ✅ loop ↔ deep-replay, no reflash |
219
+ | Signal helpers (`la_step`) | ✅ minimal, TCP transport only |
220
+
221
+ ## Scope, logic analyzer, and DAC replay
222
+
223
+ Every capture returns data with the scaling already applied — an ADC `scope_capture` gives you
224
+ **calibrated volts** (the same affine front-end model the web UI uses), so you assert on real
225
+ voltages, not raw counts. It all works over any transport: a LAN/serial pod **or** a cloud device
226
+ over the byte tunnel.
227
+
228
+ ```python
229
+ from embeddedci import benchpod
230
+
231
+ with benchpod.BenchPod("embeddedci:my-bench") as bp:
232
+ # ADC scope — calibrated volts + summary helpers
233
+ cap = bp.scope_capture(4096, sample_rate_mhz=1)
234
+ assert 3.2 < cap.mean() < 3.4 # a 3.3 V rail
235
+ print(cap.rms(), cap.peak_to_peak(), cap.dominant_frequency()) # fft needs the [analysis] extra
236
+
237
+ # Raw logic analyzer + off-device decode (i2c / uart / spi)
238
+ la = bp.capture_la(8192, sample_rate_mhz=1)
239
+ txns = la.decode("i2c", sda=2, scl=1)
240
+ frames = bp.decode(la, "uart", rx=5, baud=115200)
241
+
242
+ # Correlated ADC + LA from one trigger (aligned timebases)
243
+ both = bp.capture_analog(adc_samples=2048, adc_rate_mhz=0.4, la_samples=2048, la_rate_mhz=1)
244
+
245
+ # DAC replay — loops until stopped, and (gateware v18) can run *while* you capture
246
+ with bp.replay(cap, dac_path="5v"): # replay the captured waveform back out
247
+ alongside = bp.capture_la(8192, sample_rate_mhz=1) # DAC + LA at the same time
248
+ ```
249
+
250
+ `bp.replay(...)` accepts a `Capture` (its volts are replayed), a list of volts, or raw DAC codes
251
+ (`are_codes=True`); `mapping="faithful"` reproduces the voltage (clipping outside the path range),
252
+ `"fit"` auto-scales. Inject a fault with `fault=benchpod.Fault("flatline", start=…, width=…)`.
253
+
254
+ ### DAC ↔ capture co-trigger and auto-stop
255
+
256
+ For a *deterministic* stimulus→response run, phase-lock the DAC to the capture instead of racing
257
+ them from the host. `on_capture=True` arms the DAC to fire on the next capture's hardware t0, and
258
+ `stop_dac_after_us=` cuts it at a sample-precise offset from that same t0:
259
+
260
+ ```python
261
+ # armed, not yet driving — the following capture starts it at t0 and cuts it at 2 ms
262
+ with bp.replay(cap, dac_path="5v", on_capture=True) as r:
263
+ assert r.cotrig # device armed the co-trigger (gw v27)
264
+ a = bp.capture_analog(adc_samples=4096, adc_rate_mhz=0.4,
265
+ la_samples=0, stop_dac_after_us=2000) # DAC fires at t0, off at 2 ms
266
+ ```
267
+
268
+ ### Closed-loop DAC control (solar-panel / MPPT emulator)
269
+
270
+ On the **loop gateware image**, the iCE40 runs a control loop in fabric: each tick it reads the ADC
271
+ (a load "current"), looks it up in a panel I-V curve, damps and clamps, then drives the DAC — no
272
+ host in the loop. Switch to that image with `fpga_image(0)` (deep-replay is `fpga_image(1)`):
273
+
274
+ ```python
275
+ if not bp.capabilities.dac_control_loop:
276
+ bp.fpga_image(0) # swap to the loop image (~10 ms, no reflash)
277
+
278
+ curve = benchpod.build_panel_curve(voc_code=52000, sharpness=6) # a solar panel I-V table
279
+ with bp.control_loop(curve=curve, vmax=52000) as loop: # or voc_code=… to synthesise
280
+ pt = loop.probe() # IVPoint(i=<ADC current>, v=<DAC voltage>)
281
+ print(pt.i, pt.v)
282
+ ```
283
+
284
+ ## Cloud waveform library (load + replay stored recordings)
285
+
286
+ Save a captured waveform to the cloud library and replay it later — on this pod or another:
287
+
288
+ ```python
289
+ with benchpod.BenchPod("embeddedci:my-bench", api_key="eci_…") as bp:
290
+ cap = bp.scope_capture(8192, sample_rate_mhz=0.4)
291
+ wf = bp.save_capture_as_recording(cap, "golden-startup") # stored raw in S3
292
+
293
+ for w in bp.waveforms.list():
294
+ print(w.id, w.name, w.kind)
295
+
296
+ handle = bp.replay_waveform(wf.id, dac_path="5v", mapping="faithful")
297
+ ...
298
+ handle.stop()
299
+ ```
300
+
301
+ > **Auth note.** The cloud waveform library and server-side replay carry the `benchpod:control`
302
+ > capability. Over the cloud destination (`embeddedci:<device>`) the SDK reuses the connection's
303
+ > session token — including the **GitHub Actions OIDC** token minted in CI — so no API key is
304
+ > needed: a workflow that already drives the device can also load/save library waveforms and run
305
+ > server-side replay, scoped to the devices/org the OIDC token is allowed to drive. On a
306
+ > **LAN/serial** connection there is no session token, so pass an API key (`api_key=` /
307
+ > `--benchpod-api-key` / `BENCHPOD_API_KEY`) to reach the shared library. Capture and direct
308
+ > `replay(...)` never need one — they run over the device transport.
309
+
310
+ In pytest, the `benchpod_waveforms` fixture gives you the library with automatic cleanup of
311
+ anything created during the test, and `@pytest.mark.benchpod_capability("dac_deep_replay")` skips a
312
+ test when the device doesn't advertise a capability.
208
313
 
209
314
  ## Emulated I2C sensor + UART capture (HIL)
210
315
 
@@ -36,23 +36,22 @@ with benchpod.BenchPod("192.168.1.213") as bp: # or "/dev/ttyACM0", or "serial
36
36
  pip install embeddedci
37
37
  # for the cloud (embeddedci:<device>) destination, add the cloud extra:
38
38
  pip install "embeddedci[cloud]"
39
+ # optional: numpy-backed FFT helpers on captures (Capture.fft / dominant_frequency)
40
+ pip install "embeddedci[analysis]"
39
41
  ```
40
42
 
41
43
  The `[cloud]` extra pulls in a WebSocket client used only by the `embeddedci:` destination;
42
- local wifi/serial use needs nothing extra.
44
+ local wifi/serial use needs nothing extra. The `[analysis]` extra adds numpy for the FFT helpers
45
+ — the mean/rms/peak-to-peak reductions are pure-Python and always available.
43
46
 
44
47
  ### OpenOCD (required for flashing)
45
48
 
46
- Flashing shells out to **OpenOCD**, which must be on your `PATH`. It drives the pod's SWD probe
47
- through OpenOCD's `remote_bitbang` adapter in **SWD** mode — and **SWD support for `remote_bitbang`
48
- only exists in OpenOCD *master* (post‑0.12.0)**. The stock packages (`apt install openocd`,
49
- `brew install open-ocd`) are **0.12.0**, whose `remote_bitbang` is `jtag_only`; flashing with them
50
- fails immediately:
51
-
52
- ```
53
- Info : only one transport option; autoselect 'jtag'
54
- Error: Can't change session's transport after the initial selection was made
55
- ```
49
+ Flashing shells out to **OpenOCD**, which must be on your `PATH`. The pod runs a **CMSIS-DAP**
50
+ processor locally; the library drives it through OpenOCD's `cmsis-dap` adapter using its **TCP
51
+ backend** (`cmsis_dap_tcp`), shipping whole DAP transfers rather than per-bit toggles. That backend
52
+ **only exists in OpenOCD *master* (post‑0.12.0)**. The stock packages (`apt install openocd`,
53
+ `brew install open-ocd`) are **0.12.0** and lack it; flashing with them fails up front with a clear
54
+ message.
56
55
 
57
56
  Install a master snapshot instead — the easiest is **xPack OpenOCD**:
58
57
 
@@ -62,11 +61,11 @@ npm install -g @xpack-dev-tools/openocd
62
61
  # or: https://github.com/xpack-dev-tools/openocd-xpack/releases (extract, add bin/ to PATH)
63
62
  ```
64
63
 
65
- Verify your OpenOCD can do SWD over `remote_bitbang`:
64
+ Verify your OpenOCD has the CMSIS-DAP TCP backend:
66
65
 
67
66
  ```bash
68
- openocd -c "adapter driver remote_bitbang" -c "transport list" -c "exit"
69
- # must list: jtag swd (if only 'jtag', it's too old)
67
+ openocd -c "adapter driver cmsis-dap" -c "cmsis-dap backend tcp" -c "exit"
68
+ # must NOT error on the 'backend tcp' line (if it errors, the build is too old)
70
69
  ```
71
70
 
72
71
  ## Named constants (no magic numbers)
@@ -170,11 +169,113 @@ the **token request itself failed**.
170
169
  | Connect (wifi + serial) | ✅ |
171
170
  | Connect (cloud via GitHub OIDC) | ✅ server + SDK; device firmware tunnel pending on-hardware bring-up |
172
171
  | Power on/off (+ scheduled delay) | ✅ |
173
- | Flash + assert ok/not ok | ✅ (pure-Python OpenOCD `remote_bitbang` bridge) |
172
+ | Flash + assert ok/not ok | ✅ (pure-Python OpenOCD `cmsis-dap` TCP bridge) |
174
173
  | Emulated I2C sensor (BMP280) | ✅ wifi + serial (serial via `json` console mode) |
175
174
  | I2C bus decode (`benchpod.i2c`) | ✅ START/STOP, R/W, ACK, register reads |
175
+ | Protocol decode I2C / UART / SPI (`bp.decode`) | ✅ off-device, parity-checked vs the server |
176
176
  | UART capture (`capture_uart`) | ✅ wifi + serial |
177
- | Signal helpers (`capture`, `gpio_set`) | ✅ minimal, TCP transport only |
177
+ | ADC scope capture → calibrated volts (`scope_capture`) | ✅ LAN + cloud tunnel |
178
+ | Raw 12-ch LA capture (`capture_la`) | ✅ LAN + cloud tunnel |
179
+ | Correlated ADC + LA capture (`capture_analog`) | ✅ one hardware trigger, aligned |
180
+ | DAC generate / DC / replay (`generate`, `dac_set`, `replay`) | ✅ looping, concurrent-with-capture (gw v18) |
181
+ | Cloud waveform library + replay (`bp.waveforms`, `replay_waveform`) | ✅ cloud (OIDC) or an API key on LAN (see below) |
182
+ | DAC↔capture co-trigger + auto-stop (`replay(..., on_capture=True)`, `capture_*(stop_dac_after_us=…)`) | ✅ phase-locked to capture t0 (gw v27 / v21) |
183
+ | Closed-loop DAC control — panel/MPPT emulator (`control_loop`, `loop_probe`) | ✅ needs the loop gateware image (`fpga_image`) |
184
+ | Runtime gateware image swap (`fpga_image`) | ✅ loop ↔ deep-replay, no reflash |
185
+ | Signal helpers (`la_step`) | ✅ minimal, TCP transport only |
186
+
187
+ ## Scope, logic analyzer, and DAC replay
188
+
189
+ Every capture returns data with the scaling already applied — an ADC `scope_capture` gives you
190
+ **calibrated volts** (the same affine front-end model the web UI uses), so you assert on real
191
+ voltages, not raw counts. It all works over any transport: a LAN/serial pod **or** a cloud device
192
+ over the byte tunnel.
193
+
194
+ ```python
195
+ from embeddedci import benchpod
196
+
197
+ with benchpod.BenchPod("embeddedci:my-bench") as bp:
198
+ # ADC scope — calibrated volts + summary helpers
199
+ cap = bp.scope_capture(4096, sample_rate_mhz=1)
200
+ assert 3.2 < cap.mean() < 3.4 # a 3.3 V rail
201
+ print(cap.rms(), cap.peak_to_peak(), cap.dominant_frequency()) # fft needs the [analysis] extra
202
+
203
+ # Raw logic analyzer + off-device decode (i2c / uart / spi)
204
+ la = bp.capture_la(8192, sample_rate_mhz=1)
205
+ txns = la.decode("i2c", sda=2, scl=1)
206
+ frames = bp.decode(la, "uart", rx=5, baud=115200)
207
+
208
+ # Correlated ADC + LA from one trigger (aligned timebases)
209
+ both = bp.capture_analog(adc_samples=2048, adc_rate_mhz=0.4, la_samples=2048, la_rate_mhz=1)
210
+
211
+ # DAC replay — loops until stopped, and (gateware v18) can run *while* you capture
212
+ with bp.replay(cap, dac_path="5v"): # replay the captured waveform back out
213
+ alongside = bp.capture_la(8192, sample_rate_mhz=1) # DAC + LA at the same time
214
+ ```
215
+
216
+ `bp.replay(...)` accepts a `Capture` (its volts are replayed), a list of volts, or raw DAC codes
217
+ (`are_codes=True`); `mapping="faithful"` reproduces the voltage (clipping outside the path range),
218
+ `"fit"` auto-scales. Inject a fault with `fault=benchpod.Fault("flatline", start=…, width=…)`.
219
+
220
+ ### DAC ↔ capture co-trigger and auto-stop
221
+
222
+ For a *deterministic* stimulus→response run, phase-lock the DAC to the capture instead of racing
223
+ them from the host. `on_capture=True` arms the DAC to fire on the next capture's hardware t0, and
224
+ `stop_dac_after_us=` cuts it at a sample-precise offset from that same t0:
225
+
226
+ ```python
227
+ # armed, not yet driving — the following capture starts it at t0 and cuts it at 2 ms
228
+ with bp.replay(cap, dac_path="5v", on_capture=True) as r:
229
+ assert r.cotrig # device armed the co-trigger (gw v27)
230
+ a = bp.capture_analog(adc_samples=4096, adc_rate_mhz=0.4,
231
+ la_samples=0, stop_dac_after_us=2000) # DAC fires at t0, off at 2 ms
232
+ ```
233
+
234
+ ### Closed-loop DAC control (solar-panel / MPPT emulator)
235
+
236
+ On the **loop gateware image**, the iCE40 runs a control loop in fabric: each tick it reads the ADC
237
+ (a load "current"), looks it up in a panel I-V curve, damps and clamps, then drives the DAC — no
238
+ host in the loop. Switch to that image with `fpga_image(0)` (deep-replay is `fpga_image(1)`):
239
+
240
+ ```python
241
+ if not bp.capabilities.dac_control_loop:
242
+ bp.fpga_image(0) # swap to the loop image (~10 ms, no reflash)
243
+
244
+ curve = benchpod.build_panel_curve(voc_code=52000, sharpness=6) # a solar panel I-V table
245
+ with bp.control_loop(curve=curve, vmax=52000) as loop: # or voc_code=… to synthesise
246
+ pt = loop.probe() # IVPoint(i=<ADC current>, v=<DAC voltage>)
247
+ print(pt.i, pt.v)
248
+ ```
249
+
250
+ ## Cloud waveform library (load + replay stored recordings)
251
+
252
+ Save a captured waveform to the cloud library and replay it later — on this pod or another:
253
+
254
+ ```python
255
+ with benchpod.BenchPod("embeddedci:my-bench", api_key="eci_…") as bp:
256
+ cap = bp.scope_capture(8192, sample_rate_mhz=0.4)
257
+ wf = bp.save_capture_as_recording(cap, "golden-startup") # stored raw in S3
258
+
259
+ for w in bp.waveforms.list():
260
+ print(w.id, w.name, w.kind)
261
+
262
+ handle = bp.replay_waveform(wf.id, dac_path="5v", mapping="faithful")
263
+ ...
264
+ handle.stop()
265
+ ```
266
+
267
+ > **Auth note.** The cloud waveform library and server-side replay carry the `benchpod:control`
268
+ > capability. Over the cloud destination (`embeddedci:<device>`) the SDK reuses the connection's
269
+ > session token — including the **GitHub Actions OIDC** token minted in CI — so no API key is
270
+ > needed: a workflow that already drives the device can also load/save library waveforms and run
271
+ > server-side replay, scoped to the devices/org the OIDC token is allowed to drive. On a
272
+ > **LAN/serial** connection there is no session token, so pass an API key (`api_key=` /
273
+ > `--benchpod-api-key` / `BENCHPOD_API_KEY`) to reach the shared library. Capture and direct
274
+ > `replay(...)` never need one — they run over the device transport.
275
+
276
+ In pytest, the `benchpod_waveforms` fixture gives you the library with automatic cleanup of
277
+ anything created during the test, and `@pytest.mark.benchpod_capability("dac_deep_replay")` skips a
278
+ test when the device doesn't advertise a capability.
178
279
 
179
280
  ## Emulated I2C sensor + UART capture (HIL)
180
281
 
@@ -135,7 +135,7 @@ backward-compatible.
135
135
  `command.request`/`command.response`) instead of dialing a second byte tunnel.
136
136
  The firmware services the command channel (`CH_CLOUD_CONN`) and the byte tunnel
137
137
  (`CH_CLOUD_TUNNEL_CONN`) as independent connections and announces
138
- `"command":true` in its capabilities, so `power_on`/`power_off`/`gpio_set`/etc.
138
+ `"command":true` in its capabilities, so `power_on`/`power_off`/`la`/etc.
139
139
  run *while* `uart_proxy_start` holds the tunnel. Streaming modes
140
140
  (`dap_start`/`uart_proxy_start`) still use the tunnel via `_dial`. This both
141
141
  removes the two-concurrent-tunnels requirement and makes every command faster
@@ -4,17 +4,17 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "embeddedci"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "BenchPod pytest client for EmbeddedCI hardware-in-the-loop testing"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
- license = { text = "Apache-2.0" }
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
12
13
  authors = [{ name = "EmbeddedCI" }]
13
14
  keywords = ["embedded", "hardware-in-the-loop", "pytest", "benchpod", "swd", "openocd"]
14
15
  classifiers = [
15
16
  "Development Status :: 3 - Alpha",
16
17
  "Framework :: Pytest",
17
- "License :: OSI Approved :: Apache Software License",
18
18
  "Operating System :: OS Independent",
19
19
  "Programming Language :: Python :: 3",
20
20
  "Programming Language :: Python :: 3.9",
@@ -33,6 +33,12 @@ dev = ["pytest>=7.0", "websocket-client>=1.6"]
33
33
  # Cloud destination (embeddedci:<device>): a synchronous WebSocket client for the byte tunnel.
34
34
  # OIDC mint + token exchange use the stdlib (urllib), so no extra HTTP dependency is needed.
35
35
  cloud = ["websocket-client>=1.6"]
36
+ # LAN auto-discovery (connection="discover" / --benchpod-discover): browse mDNS for pods.
37
+ # Kept optional so headless CI (cloud/explicit path, multicast often blocked) stays lean.
38
+ discovery = ["zeroconf>=0.131"]
39
+ # Signal analysis helpers on capture results (Capture.fft / dominant_frequency). The core
40
+ # reductions (mean/rms/peak-to-peak) are pure-Python and need no extra; only the FFT uses numpy.
41
+ analysis = ["numpy>=1.21"]
36
42
 
37
43
  [project.entry-points.pytest11]
38
44
  benchpod = "embeddedci.benchpod.pytest_plugin"