Skip to main content

OEP Python client

Open Embedded Probe の host 側。v1(oep-spec の docs/oep-core.ja.md と docs/oep-if-*.ja.md、固める候補の形)を話す。番号は oep-spec の generated/oep-v1/oep_v1_registry.py をそのまま写した oep_client.v1.registry から取る。破壊的変更を前提とする 実験段階で、互換 API は約束しない。OEP を初めて読む人は oep-spec の docs/review-guide.ja.md(どこに何が書いてあるか)から。

target の知識は host にある、という OEP の分担に従う。probe は線と DMI / DP・AP の転送しか知らず、CH32 の flash コントローラ、RAM ローダー、RP2350 の boot ROM、Cortex-M の debug レジスタなどはここに置く。

pip install oep-client-python     # PyPI (import oep_client); a checkout: pip install -e <checkout>
uv run pytest                                                            # in a checkout

import oep_client.v1 だけで使える(sys.path に src/ を足す使い方は不要になった)。番号の表は tools/sync_registry.sh で oep-spec から写す。PyPI の oep-client は別のプロジェクトなので、配布名は oep-client-python。

リリースは GitHub Actions の Release(workflow_dispatch、version = X.Y.Z か X.Y.ZbN): tools/prepare_release.py が pyproject.toml と oep_client.__version__ を書き換え、CHANGELOG.md の Unreleased をその版にし、試験と build の後に commit と tag、 GitHub Release、PyPI(Trusted Publishing)へ出す。変更は CHANGELOG.md の Unreleased に (EN) / (JA) で書き足しておく。

モジュール(oep_client.v1)

モジュール 中身
host 要求と結果、session_id とロック、call()(失敗なら例外)、pipeline、エラーの階層(OepError / Rejected / Failed)
link transport: シリアルの口(常に COBS + CRC、0x00 <COBS> 0x00、フレームの外は雑音として捨てる、排他で開く)、USB vendor bulk / HID と TCP(長さつきフレーム、§5.1 の立て直し)、corr による照合と送り直し、open_host(target)
core インターフェースを名前で探す(キャッシュつき)、confirm、probe の describe(ラベル、transport の一覧)、ロックの取り方(take)、ピンの割り当て(plan)、Interface の土台
riscv oep.wire.rvswd / oep.wire.swio、oep.target.riscv-dm、リセット線の探索、GPIO 経由の attach
console oep.target.console(位置つきのストリーム)と、バイト列として読む ConsoleIO
fixture oep.fixture.gpio / uart(revision 1)
capture oep.fixture.capture(revision 1、oep-spec の oep-if-capture)。読んだ区画は Host.on_capture の callback に CaptureRecord で渡る(記録の受け口。wireskein には依存しない)
esp32_targets 独自インターフェース io.github.ch32-riscv-ug.esp32.i2c-target / spi-target(oep-probe-arduino の ESP32 の I2C / SPI の target)
decode キャプチャのチャネルの復号(I2C)
registry oep-spec の番号の表から生成したモジュール(編集しない。oep-spec から写し直す)
arm oep.wire.swd、oep.target.arm-adi、MEM-AP、Cortex-M の停止と関数呼び出し
ch32_flash CH32 の書き込み(RAM ローダー、ページ単位の書き直し)
rp2350 RP2350 の boot ROM 経由の flash と reboot
uiapduino UIAPduino のブートローダへの出入り
catalog / names / interfaces / dump 能力の一覧と describe の形、表示
fake / endpoint / fake_serial / fake_serve 偽の probe(下の「偽の probe」)
target 上の主なものを 1 か所から import する入口(最初の版に合わせて書いた呼び出し側のため)

使い方の例

from oep_client.v1 import core, link, riscv, ch32_flash

hst = link.open_host("/run/board-identify/by-id/esp32-series-30eda0e31108")   # pipelining つき
# a serial port (always COBS), "tcp://127.0.0.1:PORT" (a broker), "usb" / "usb:303a:0002[:SERIAL]" (vendor, then HID)
core.take(hst, 30000, owner="flash script")   # the only way in: force; else wait out the lease, name the holder
wire = riscv.Wire(hst, "oep.wire.rvswd")
conn, _ = wire.attach(halt=True)
dm = riscv.RiscvDm(hst, conn)
dm.reset_halt()
result = ch32_flash.program(hst, dm, open("sketch.bin", "rb").read(), ch32_flash.PROFILES["x035"])
dm.reset(confirm=True)
wire.detach(conn)
hst.end()

能力の一覧は uv run python -m oep_client.v1 dump --port <probe>(--fake p4-x035 でハードウェアなし)。 実機での一通りの確認は ArduinoCore-CH32 の tests/manual/oep_smoke/(oep_smoke.py、oep_probe_checks.py)。

偽の probe(動く spec)

endpoint.Endpoint は oep-spec の規範どおりに答える偽の probe で、ch32rv・この client・probe の firmware を突き合わせる 「動く spec」として使う(spec が変わったら、probe の firmware より先にここを合わせる)。fake は宣言の例(profile: p4-x035、esp32-v003、p4-bench = スロット 3 か所と席 2 つの架空の治具)、fake_serial はシリアルの口のバイトの側(COBS の 候補、生のバイトと bind、セッション中の停止と再開)。

外のプログラムの試験には fake_serve を子プロセスで使う:

uv run python -m oep_client.v1.fake_serve --pty --profile p4-bench --slot x035 --bind last-reset \
    --console 'uptime %d\r\n' --every 100
# 最初の行: PTY /dev/pts/N(--tcp 0 なら PORT n)。stdin を閉じると終わる

pty がシリアルの口(host が TIOCEXCL を掛けて開く)、--tcp PORT は --framing cobs(シリアルの口)か --framing length (vendor bulk / TCP の形)。故障の注入は --drop N(N 番目の答えを 1 回出さない。要求は実行済みなので送り直しは覚えた答えを 受ける)、--noise TEXT(答えの前に雑音)、--corrupt N(N 番目の答えの CRC を 1 回壊す)。ほかは --help。

v0 の client(oep_client.v0)は 2026-09-26 に消した(git の履歴に残る)。v0 を話す probe はもう無い。

Metadata

Release files for oep-client-python 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oep-client-python 0.0.1
File Size Uploaded
oep_client_python-0.0.1.tar.gz 125.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oep-client-python 0.0.1
File Interpreter ABI Platform
oep_client_python-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 237.5 kB

Release files / oep_client_python-0.0.1.tar.gz

Download URL oep_client_python-0.0.1.tar.gz
Size 125.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3339cd3f76a021e8d8515ba649d2bf1e44601735d2b4b8a1c44c29c8ef4091d1
BLAKE2b-256 checksum
How to use checksums
44f403a0f7dffbc4113457f4a13a70e3a88c415d11ba2e905b0a13be96771de6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release files / oep_client_python-0.0.1-py3-none-any.whl

Download URL oep_client_python-0.0.1-py3-none-any.whl
Size 112.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a42101383ae4894373b35b6292a238b8f47b268776eee936f939be256fdbd9e6
BLAKE2b-256 checksum
How to use checksums
be6ee079ff993d53667fb75d06c402ed0bef33b56919669f2bd7a0a5d0c959ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page