-
Notifications
You must be signed in to change notification settings - Fork 0
Adapter Class
Adapter is a high-level interface for interacting with a Silicon Labs adapter (a kit or debugger such as the WSTK, WPK, or Simplicity Link Debugger). Its convenience methods rely on features that exist only on Silicon Labs adapters and are not available with a generic J-Link adapter.
from pycommander import Adapter
from pycommander_core.types import VcomHandshake
adapter = Adapter(serial_number="440055955", target_device="EFR32MG24")
print(adapter.info())
adapter.setVoltage(1.8)
adapter.setVcomConfig(115200, VcomHandshake.RTSCTS, store=True)Adapter takes the shared connection/debug parameters (see Python-API-Overview) plus two composition parameters:
- When you construct a flavor
Adapter(from pycommander import Adapter), aCommanderis created for you and exposed asadapter._commander. If you passtarget_device, a [[Target-Class|Target]] is also created and attached asadapter.target. - The underlying
AdapterBaseadditionally accepts an existingcommander=and/ortarget=for advanced composition (e.g. to share a logging-enabledCommander):
from pathlib import Path
from pycommander import Adapter, Commander
commander = Commander(serial_number="440055955", log_file_path=Path("pc.log"))
adapter = Adapter(commander=commander, target_device="EFR32MG24")Multiple Adapter instances represent multiple kits and operate independently.
Return rich information about the adapter as an AdapterInfo — connected boards, firmware info, J-Link serial, VCOM port and capabilities, IP/MAC, nickname, kit name/part number, AEM support, debug mode. Returns None if it could not be retrieved.
Reset the adapter. Returns True on success.
Upgrade the adapter firmware.
- If
filenameis omitted, Commander's bundled firmware is used and the upgrade is only performed if the bundled version is newer than the installed one. - If
filenameis given, that firmware package (*.emz) is flashed.
Returns an AdapterFwUpgradeResult (package_was_installed, currently_installed_version), or None on failure.
Read the target supply voltage configuration. Returns an AdapterVoltageInfo containing per-rail AdapterRailInfo entries (configured vs. measured voltage, powered state), or None.
Set the target supply voltage. With calibrate=True (default), the adapter recalibrates automatically if the voltage changed. Returns True on success.
Configure the adapter's VCOM. handshake must be a VcomHandshake enum value (NONE, RTSCTS, AUX) — anything else raises ValueError. With store=True the configuration is persisted on the adapter. Returns True on success.
from pycommander_core.types import VcomHandshake
adapter.setVcomConfig(baudrate=115200, handshake=VcomHandshake.RTSCTS, store=True)analyzeEnergyUsage(duration_s, get_distribution=False, cluster_states=False, detect_period=False) -> AemAnalysisResult | None
Capture and analyze the target's energy usage over duration_s seconds using the Advanced Energy Monitor. At least one of the three analyses must be enabled (otherwise ValueError):
-
get_distribution— current/time distribution histogram. -
cluster_states— Bayesian-blocks clustering into distinct power states. -
detect_period— periodicity detection (needs at least ~5 periods captured).
Returns an AemAnalysisResult with distribution, clustering, period_detection and signal_characteristics, or None on failure.
result = adapter.analyzeEnergyUsage(duration_s=10, cluster_states=True, detect_period=True)
print(result.clustering.unique_states)
print(result.signal_characteristics.min_current_ma, result.signal_characteristics.max_current_ma)For continuous, open-ended capture rather than a fixed-window analysis, use [[AEM-and-Energy-Measurement|AemStream]].
-
adapter.target— the attached [[Target-Class|Target]] (present whentarget_devicewas provided). Use it for flashing, CTUNE, security, etc. - The underlying
Commanderis available for anything the helpers don't cover; see Commander-Class.
adapter.target.flashApplication(filenames=[Path("firmware.hex")])
ctune = adapter.target.getCTUNE()
adapter.target.setCTUNE(ctune.board)The Adapter class focuses on tasks that involve the adapter hardware itself (Silicon Labs only):
- Reading adapter and kit information
- Resetting the adapter
- Upgrading the adapter's firmware
- Configuring the target device's supply voltage
- Setting the adapter's VCOM configuration
- Analyzing the target device's energy usage
Tasks involving the device (flashing, erasing, security, …) live on [[Target-Class|Target]], which works with any supported debug adapter.
PyCommander · GitHub · Simplicity Commander docs · Licensed under the Silicon Labs MSLA
Getting started
Using PyCommander
Topics
Command reference
- Overview
- adapter · aem · vcom · ctune
- device · flash · verify · readmem · extflash
- security
- tokens · nvm3 · littlefs
- convert · ebl · gbl3 · gbl4 · ota · rps · postbuild
- util · serial · mfg917
Contributing