-
Notifications
You must be signed in to change notification settings - Fork 0
Commander Class
Commander is the lowest-level layer of the Python API: a direct, 1:1 mirror of the Simplicity Commander CLI. Each CLI command suite is exposed as a sub-object, and each method returns the command output as a dict — equivalent to running the CLI with --json.
from pathlib import Path
from pycommander import Commander
commander = Commander(serial_number="440055955")
print(commander.device.info(target_device="EFR32MG24"))
print(commander.util.appinfo(filename="firmware.hex"))
print(commander.flash.flash(filenames=["firmware.hex"], address=0x08000000))Commander(
serial_number: str | None = None,
ip_address: str | None = None,
serial_port: str | None = None,
target_device: str | None = None,
debug_speed: int | None = None,
debug_tif: str | None = None,
debug_irpre: int | None = None,
debug_drpre: int | None = None,
log_file_path: Path | None = None,
executable_path: Path | None = None,
)These parameters are shared across the API and described in Python-API-Overview. Highlights:
- Provide at most one of
serial_number/ip_address/serial_port(more than one raisesValueError). -
target_deviceapplies--deviceto commands that take it. -
debug_*map to Commander's debug options. -
log_file_pathenables per-invocation Logging. -
executable_pathoverrides the bundled Commander executable (must exist, orFileNotFoundErroris raised).
The flavor packages set the CLI/GUI selection for you. If you instantiate
pycommander_core.commander_base.CommanderBasedirectly, you must passcli=True/cli=False(or anexecutable_path).
A Commander exposes the following command suites as attributes. Each links to its full reference.
| Attribute | Class | Reference |
|---|---|---|
commander.adapter |
AdapterCommand |
Reference-Adapter-AEM-VCOM |
commander.aem |
AemCommand |
Reference-Adapter-AEM-VCOM |
commander.vcom |
VcomCommand |
Reference-Adapter-AEM-VCOM |
commander.ctune |
CtuneCommand |
Reference-Adapter-AEM-VCOM |
commander.device |
DeviceCommand |
Reference-Device-Flash-Memory |
commander.flash |
FlashCommand |
Reference-Device-Flash-Memory |
commander.verify |
VerifyCommand |
Reference-Device-Flash-Memory |
commander.readmem |
ReadmemCommand |
Reference-Device-Flash-Memory |
commander.extflash |
ExtflashCommand |
Reference-Device-Flash-Memory |
commander.security |
SecurityCommand |
Reference-Security |
commander.tokens |
TokensCommand |
Reference-Tokens-NVM3-LittleFS |
commander.nvm3 |
Nvm3Command |
Reference-Tokens-NVM3-LittleFS |
commander.littlefs |
LittlefsCommand |
Reference-Tokens-NVM3-LittleFS |
commander.convert |
ConvertCommand |
Reference-Image-Files |
commander.ebl |
EblCommand |
Reference-Image-Files |
commander.gbl3 |
Gbl3Command |
Reference-Image-Files |
commander.gbl4 |
Gbl4Command |
Reference-Image-Files |
commander.ota |
OtaCommand |
Reference-Image-Files |
commander.rps |
RpsCommand |
Reference-Image-Files |
commander.postbuild |
PostbuildCommand |
Reference-Image-Files |
commander.util |
UtilCommand |
Reference-Utilities |
commander.serial |
SerialCommand |
Reference-Utilities |
commander.mfg917 |
Mfg917Command |
Reference-Utilities |
In addition to the command suites, Commander exposes a few convenience methods.
Returns the embedded Simplicity Commander, J-Link, EMDLL, mbed TLS and Qt component versions as a CommanderVersionInfo dataclass, or None if it could not be retrieved.
print(commander.getVersion())listAvailableAdapters(list_usb_adapters=False, list_network_adapters=False) -> list[BasicAdapterInfo] | None
Performs an unintrusive scan for available adapters over USB or the network. Returns a list of BasicAdapterInfo objects (each carrying jlink_serial_number, ip_address, nickname — any of which may be None), or None on failure.
Exactly one of list_usb_adapters / list_network_adapters must be True (otherwise ValueError).
# USB adapters
for a in commander.listAvailableAdapters(list_usb_adapters=True):
print(a.jlink_serial_number, a.nickname)
# Network adapters
for a in commander.listAvailableAdapters(list_network_adapters=True):
print(a.ip_address, a.nickname)Escape hatch for commands the typed API doesn't expose. Arguments are forwarded straight to the Commander CLI.
- With
json_formatted_output=True(default), returns the parsed JSONdict. - With
json_formatted_output=False, returns aCommanderResultnamedtuple(returncode, output)with the raw text output.
result = commander.runCommand("rtt", "--help", json_formatted_output=False)
print(result.output)**kwargs accepts the same per-call override keys as command methods (serial_number, target_device, force, devicexml, the debug_* keys, …).
Not every CLI command is available on Commander. Commands designed for interactive CLI sessions are intentionally omitted — for example vcom, vuart, rtt and swo interactive flows. (A non-interactive vcom config is exposed; see Reference-Adapter-AEM-VCOM.)
Some methods are also stricter than their CLI counterparts because there is no interactive session to fall back on. For instance, aem dump requires outfile and duration to be provided. For flexible, open-ended AEM capture, use the [[AEM-and-Energy-Measurement|AemStream]] class instead.
For anything not surfaced by the typed API, fall back to runCommand(...).
Command methods return the parsed JSON dict. Most Commander commands include a top-level success boolean and a result object; the higher-level Adapter-Class and Target-Class helpers exist precisely to parse these into typed dataclasses for you. If a command produces non-JSON output, _run still returns a dict shaped like {"success": True, "output": "..."} (or {"success": False, "error": "..."} on failure).
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