embeddedci 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 (39) hide show
  1. embeddedci-0.1.0/.github/workflows/ci.yml +37 -0
  2. embeddedci-0.1.0/.github/workflows/publish.yml +48 -0
  3. embeddedci-0.1.0/.gitignore +13 -0
  4. embeddedci-0.1.0/LICENSE +202 -0
  5. embeddedci-0.1.0/PKG-INFO +242 -0
  6. embeddedci-0.1.0/README.md +214 -0
  7. embeddedci-0.1.0/examples/README.md +51 -0
  8. embeddedci-0.1.0/examples/test_bmp280.py +81 -0
  9. embeddedci-0.1.0/pyproject.toml +49 -0
  10. embeddedci-0.1.0/src/embeddedci/__init__.py +20 -0
  11. embeddedci-0.1.0/src/embeddedci/benchpod/__init__.py +95 -0
  12. embeddedci-0.1.0/src/embeddedci/benchpod/client.py +314 -0
  13. embeddedci-0.1.0/src/embeddedci/benchpod/connection.py +84 -0
  14. embeddedci-0.1.0/src/embeddedci/benchpod/constants.py +95 -0
  15. embeddedci-0.1.0/src/embeddedci/benchpod/errors.py +40 -0
  16. embeddedci-0.1.0/src/embeddedci/benchpod/flash.py +430 -0
  17. embeddedci-0.1.0/src/embeddedci/benchpod/i2c.py +252 -0
  18. embeddedci-0.1.0/src/embeddedci/benchpod/protocol.py +61 -0
  19. embeddedci-0.1.0/src/embeddedci/benchpod/pytest_plugin.py +170 -0
  20. embeddedci-0.1.0/src/embeddedci/benchpod/sensor.py +89 -0
  21. embeddedci-0.1.0/src/embeddedci/benchpod/transport/__init__.py +46 -0
  22. embeddedci-0.1.0/src/embeddedci/benchpod/transport/base.py +73 -0
  23. embeddedci-0.1.0/src/embeddedci/benchpod/transport/serial.py +344 -0
  24. embeddedci-0.1.0/src/embeddedci/benchpod/transport/tcp.py +212 -0
  25. embeddedci-0.1.0/src/embeddedci/benchpod/uart.py +90 -0
  26. embeddedci-0.1.0/src/embeddedci/py.typed +0 -0
  27. embeddedci-0.1.0/tests/conftest.py +9 -0
  28. embeddedci-0.1.0/tests/examples/test_bmp280_hil.py +154 -0
  29. embeddedci-0.1.0/tests/examples/test_smoke.py +49 -0
  30. embeddedci-0.1.0/tests/test_connection.py +54 -0
  31. embeddedci-0.1.0/tests/test_flash_bridge.py +134 -0
  32. embeddedci-0.1.0/tests/test_i2c_decode.py +73 -0
  33. embeddedci-0.1.0/tests/test_integration.py +134 -0
  34. embeddedci-0.1.0/tests/test_protocol.py +47 -0
  35. embeddedci-0.1.0/tests/test_sensor.py +117 -0
  36. embeddedci-0.1.0/tests/test_serial_json.py +141 -0
  37. embeddedci-0.1.0/tests/test_tcp_transport.py +116 -0
  38. embeddedci-0.1.0/tests/test_timed_power.py +76 -0
  39. embeddedci-0.1.0/tests/test_uart_capture.py +101 -0
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["**"]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ python-version: ["3.9", "3.11", "3.13"]
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: ${{ matrix.python-version }}
19
+ - name: Install package + test deps
20
+ run: python -m pip install -e ".[dev]"
21
+ - name: Run tests
22
+ # Hardware fixtures skip automatically without a BENCHPOD_CONNECTION,
23
+ # so the suite stays green on runners without a pod attached.
24
+ run: pytest -q
25
+
26
+ build:
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.11"
33
+ - name: Build and check distribution
34
+ run: |
35
+ python -m pip install --upgrade build twine
36
+ python -m build
37
+ twine check dist/*
@@ -0,0 +1,48 @@
1
+ name: Publish to PyPI
2
+
3
+ # Publishes a release to PyPI when a version tag is pushed, e.g. `v0.1.0`.
4
+ # Uses PyPI Trusted Publishing (OIDC) — no API token / secret required.
5
+ # One-time setup on PyPI: project settings → Publishing → add a GitHub
6
+ # trusted publisher with:
7
+ # owner: embeddedci-com repo: embeddedci-python
8
+ # workflow: publish.yml environment: pypi
9
+
10
+ on:
11
+ push:
12
+ tags: ["v*"]
13
+
14
+ jobs:
15
+ build:
16
+ name: Build distribution
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.11"
23
+ - name: Build sdist and wheel
24
+ run: |
25
+ python -m pip install --upgrade build
26
+ python -m build
27
+ - name: Check artifacts render
28
+ run: |
29
+ python -m pip install --upgrade twine
30
+ twine check dist/*
31
+ - uses: actions/upload-artifact@v4
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+
36
+ publish:
37
+ name: Publish to PyPI
38
+ needs: build
39
+ runs-on: ubuntu-latest
40
+ environment: pypi
41
+ permissions:
42
+ id-token: write # required for trusted publishing
43
+ steps:
44
+ - uses: actions/download-artifact@v4
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
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/
@@ -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.
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: embeddedci
3
+ Version: 0.1.0
4
+ Summary: BenchPod pytest client for EmbeddedCI hardware-in-the-loop testing
5
+ Project-URL: Homepage, https://embeddedci.com
6
+ Project-URL: Repository, https://github.com/embeddedci-com/embeddedci-python
7
+ Project-URL: Issues, https://github.com/embeddedci-com/embeddedci-python/issues
8
+ Author: EmbeddedCI
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: benchpod,embedded,hardware-in-the-loop,openocd,pytest,swd
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Framework :: Pytest
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: pyserial>=3.5
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # embeddedci (BenchPod pytest library)
30
+
31
+ A pytest-friendly Python client for an [EmbeddedCI](https://embeddedci.com)
32
+ **BenchPod** — the same device operations you do today with `benchpod-cli`,
33
+ available straight from your tests:
34
+
35
+ * connect to a BenchPod over **wifi/network or serial**
36
+ * power the target on/off
37
+ * **flash** firmware to the target and **assert ok / not ok**
38
+ * emulate an I2C sensor (BMP280) and decode the bus traffic
39
+
40
+ ```python
41
+ from embeddedci import benchpod
42
+
43
+ with benchpod.BenchPod("192.168.1.213") as bp: # or "/dev/ttyACM0", or "serial"
44
+ bp.ping()
45
+ bp.power_on(benchpod.INTERNAL)
46
+ result = bp.flash(
47
+ file="firmware.elf", target="target/stm32f1x.cfg",
48
+ swclk=benchpod.PIN1, swdio=benchpod.PIN2, nreset=benchpod.PIN3,
49
+ target_power=benchpod.INTERNAL,
50
+ )
51
+ assert result.ok
52
+ bp.power_off(benchpod.INTERNAL)
53
+ ```
54
+
55
+ ## Install
56
+
57
+ ```bash
58
+ pip install embeddedci
59
+ ```
60
+
61
+ Flashing shells out to **OpenOCD**, which must be on your `PATH`
62
+ (`brew install open-ocd` / `apt install openocd`).
63
+
64
+ ## Named constants (no magic numbers)
65
+
66
+ | Concept | Constants | Wire value |
67
+ |---|---|---|
68
+ | Target-power eFuse | `benchpod.INTERNAL`, `benchpod.EXTERNAL` | 1, 2 |
69
+ | LA pins (SWCLK/SWDIO/NRESET) | `benchpod.PIN1` … `benchpod.PIN12` | 1 … 12 |
70
+
71
+ Plain ints still work (`efuse=1`, `swclk=1`); they're validated and coerced.
72
+
73
+ ## Using it in pytest
74
+
75
+ Installing the package registers a pytest plugin. Point it at a pod and use the
76
+ fixtures:
77
+
78
+ ```bash
79
+ pytest --benchpod-connection=192.168.1.213
80
+ # or: export BENCHPOD_CONNECTION=serial
81
+ ```
82
+
83
+ ```python
84
+ def test_firmware_flashes(benchpod):
85
+ benchpod.power_on(benchpod.INTERNAL)
86
+ assert benchpod.flash(
87
+ file="firmware.elf", target="target/stm32f1x.cfg",
88
+ swclk=benchpod.PIN1, swdio=benchpod.PIN2,
89
+ ).ok
90
+
91
+ # benchpod_target powers the target on for the test and off at teardown:
92
+ def test_with_powered_target(benchpod_target):
93
+ ...
94
+ ```
95
+
96
+ Without a connection configured the fixtures **skip** rather than fail, so the
97
+ suite stays green in CI runners without hardware.
98
+
99
+ ## Connection strings
100
+
101
+ | Form | Transport |
102
+ |---|---|
103
+ | `192.168.1.213` or `host:8080` | wifi/network (JSON over TCP, port 8080 default) |
104
+ | `/dev/ttyACM0`, `COM3` | serial (USB CDC-ACM console) |
105
+ | `serial` / `usb` | serial, auto-detected by USB VID `0x2E8A` |
106
+
107
+ Resolution order: explicit argument / `--benchpod-connection` →
108
+ `benchpod_connection` ini option → `BENCHPOD_CONNECTION` env var.
109
+
110
+ ## Status of features
111
+
112
+ | Feature | State |
113
+ |---|---|
114
+ | Connect (wifi + serial) | ✅ |
115
+ | Power on/off (+ scheduled delay) | ✅ |
116
+ | Flash + assert ok/not ok | ✅ (pure-Python OpenOCD `remote_bitbang` bridge) |
117
+ | Emulated I2C sensor (BMP280) | ✅ wifi + serial (serial via `json` console mode) |
118
+ | I2C bus decode (`benchpod.i2c`) | ✅ START/STOP, R/W, ACK, register reads |
119
+ | UART capture (`capture_uart`) | ✅ wifi + serial |
120
+ | Signal helpers (`capture`, `gpio_set`) | ✅ minimal, TCP transport only |
121
+
122
+ ## Emulated I2C sensor + UART capture (HIL)
123
+
124
+ The pod can **pretend to be an I2C sensor** (a BMP280) on two LA channels while
125
+ you capture the DUT's UART — so you can flash an app, power-cycle it, and assert
126
+ on its boot output with and without the sensor present:
127
+
128
+ ```python
129
+ from embeddedci import benchpod
130
+
131
+ with benchpod.BenchPod("192.168.1.213") as bp:
132
+ bp.flash(file="app.elf", target="target/stm32f4x.cfg",
133
+ swclk=benchpod.PIN13, swdio=benchpod.PIN14, target_power=benchpod.INTERNAL)
134
+
135
+ # I2C is open-drain — enable the pod's pull-ups on SDA/SCL (LA1-8 only),
136
+ # then have the pod become a BMP280 on those lines.
137
+ bp.enable_pullup(benchpod.PIN1, benchpod.PIN2)
138
+ bp.enable_i2c_sensor(benchpod.Sensor.BMP280, sda=benchpod.PIN1, scl=benchpod.PIN2,
139
+ temperature_c=22.5, pressure_pa=101000)
140
+
141
+ # Power-cycle while capturing UART so the boot banner lands in the window.
142
+ cap = bp.power_cycle_and_capture(rx=benchpod.PIN5, tx=benchpod.PIN6,
143
+ delay=1.5, duration=6.0, until=r"APP_OK")
144
+ assert cap.match("APP_OK")
145
+ assert cap.match(r"chip id match=0x58|bmp280_detected=yes")
146
+ ```
147
+
148
+ How the power-cycle works: `power_cycle_and_capture` powers the eFuse off, then
149
+ schedules a power-on `delay` seconds out (a **pod-side timer** via
150
+ `target_power`'s `delay_ms`), then enters UART capture — so the scheduled
151
+ power-on, and the DUT's boot output, land *inside* the capture window. This
152
+ sidesteps the firmware's one-connection-at-a-time limit (you can't send a
153
+ power-on while the UART proxy owns the link).
154
+
155
+ `rx` is the LA channel the pod **samples** (wire the DUT's TX here); `tx` is the
156
+ channel the pod **drives** (DUT's RX).
157
+
158
+ > **Serial gets the full JSON API too.** The pod's TCP API is JSON; the serial
159
+ > console is normally text-only. The firmware exposes a `json` console command
160
+ > that switches the console into the same JSON dispatcher (exit with
161
+ > `{"cmd":"json_exit"}`). The serial transport enters/leaves this mode
162
+ > automatically, so `enable_i2c_sensor(...)`, `i2c_sensor_la_decoded(...)`, etc.
163
+ > work over serial as well as wifi — no code change in your test.
164
+
165
+ ### Decode the I2C bus
166
+
167
+ While the pod serves the emulated sensor it also samples the SDA/SCL lines. The
168
+ `benchpod.i2c` module turns that raw capture into decoded transactions, so you
169
+ can assert what the DUT *actually did* on the wire — not just that it booted:
170
+
171
+ ```python
172
+ from embeddedci import benchpod
173
+ from embeddedci.benchpod import i2c
174
+
175
+ with benchpod.BenchPod("192.168.1.213") as bp:
176
+ bp.enable_i2c_sensor(benchpod.Sensor.BMP280, sda=benchpod.PIN7, scl=benchpod.PIN8)
177
+ bp.power_off(benchpod.INTERNAL); bp.power_on(benchpod.INTERNAL) # DUT boots & probes
178
+
179
+ txns = bp.i2c_sensor_la_decoded(samples=4096, sample_rate_mhz=0.5)
180
+ print(i2c.format_transactions(txns))
181
+ # -> S 0x76W+ 0xD0+ Sr 0x76R+ 0x58- P (write reg 0xD0, read chip id 0x58)
182
+ assert i2c.read_register(txns, 0x76, 0xD0) == [0x58]
183
+ ```
184
+
185
+ The decoder handles START/repeated-START/STOP, the R/W bit, per-byte ACK/NACK,
186
+ and the common "write register pointer, then read" pattern (`read_register`). It
187
+ works on a `(scl, sda)` stream too (`i2c.decode_samples`) and ships a waveform
188
+ synthesizer (`i2c.synthesize`) so you can build and decode traces with no
189
+ hardware — see [`tests/test_i2c_decode.py`](tests/test_i2c_decode.py).
190
+
191
+ ### Getting started: one clean HIL test
192
+
193
+ The "hello world" of EmbeddedCI HIL — flash → emulate a BMP280 → power-cycle →
194
+ assert on UART — is in [`examples/test_bmp280.py`](examples/test_bmp280.py), with
195
+ a wiring table and run command at the top:
196
+
197
+ ```bash
198
+ pytest examples/test_bmp280.py \
199
+ --benchpod-connection=/dev/tty.usbserial-0001 \ # or an IP for wifi
200
+ --benchpod-firmware=path/to/your_app.elf
201
+ ```
202
+
203
+ It uses the plugin's `benchpod`, `pins` and `firmware` fixtures and the
204
+ `@pytest.mark.hardware` marker, and **skips automatically** without a connection.
205
+ The pin map comes from `--benchpod-swclk/-swdio/-nreset/-uart-rx/-uart-tx/-i2c-sda/-i2c-scl/-efuse`
206
+ options (sensible defaults) so tests aren't hardcoded to your wiring. See
207
+ [`examples/README.md`](examples/README.md) for the full wiring table.
208
+
209
+ A more thorough multi-case version (present/absent + I2C-bus decode) lives in
210
+ [`tests/examples/test_bmp280_hil.py`](tests/examples/test_bmp280_hil.py).
211
+
212
+ ## Releasing (maintainers)
213
+
214
+ Releases publish to [PyPI](https://pypi.org/project/embeddedci/) automatically
215
+ via [`.github/workflows/publish.yml`](.github/workflows/publish.yml) using PyPI
216
+ **Trusted Publishing** (OIDC) — no API token or secret is stored in GitHub.
217
+
218
+ **One-time setup** on PyPI (or first via [TestPyPI](https://test.pypi.org)):
219
+ project → *Settings → Publishing → Add a pending publisher* with
220
+ owner `embeddedci-com`, repo `embeddedci-python`, workflow `publish.yml`,
221
+ environment `pypi`.
222
+
223
+ To cut a release:
224
+
225
+ ```bash
226
+ # 1. bump the version in pyproject.toml (e.g. 0.1.0 -> 0.1.1), commit it
227
+ # 2. tag and push — the tag must match the version
228
+ git tag v0.1.1
229
+ git push origin v0.1.1
230
+ ```
231
+
232
+ The tag push builds the sdist + wheel, runs `twine check`, and publishes. The
233
+ git tag is the source of truth for what shipped; keep it equal to the
234
+ `version` in `pyproject.toml`.
235
+
236
+ Build and verify locally before tagging:
237
+
238
+ ```bash
239
+ python -m pip install build twine
240
+ python -m build # -> dist/embeddedci-*.tar.gz and *.whl
241
+ twine check dist/*
242
+ ```