JSON events

Every event espx prints with --json, its fields, and the JSON documents the data commands print.

--json puts machine-readable output on stdout and nothing else. Progress and warnings stay on stderr, and child processes have their stdout sent to stderr, so stdout parses line by line. Every type here is defined in espx's core and published as one JSON Schema, schema/espx.json in the espx repository, generated from the Rust types.

Event streams

build, flash, run, monitor, replay and devices --watch print one JSON object per line. Each has an event field naming what happened and a ts field, host milliseconds since the Unix epoch:

{ "ts": 1789180727730, "event": "line", "text": "Hello world!" }

A recording made with monitor --record holds the same objects, plus bytes events. Fields marked optional are left out when they have no value.

Monitor events

line

One line of serial output.

FieldTypeMeaning
textstringThe line, without the trailing newline. Plain-text logs keep their ANSI colour codes
levelstring, optionalFor a decoded defmt line: trace, debug, info, warn or error
modulestring, optionalFor a decoded defmt line: the module path
locationstring, optionalFor a decoded defmt line: file:line, relative to the project when the file is in it

reset

espx reset the board through the serial lines, on opening the port or after a flash. No fields.

boot

The ROM's reset banner (rst:0x..), sent right before the line that holds it.

FieldTypeMeaning
reasonstringpower_on, software, watchdog, brownout, panic, deep_sleep, external, usb or unknown
codeinteger, optionalThe ROM's reset code
rawstringThe banner line

panic means a software reset right after a panic or exception in the same session. The reasons are explained in Monitor and replay.

panic

An esp-backtrace panic, collected from its banner, message and addresses.

FieldTypeMeaning
messagestringThe panic message
framesarray of framesOne per address, and one per inlined function at that address

exception

A CPU exception, such as a load from an invalid address or an illegal instruction.

FieldTypeMeaning
kindstringThe exception as the chip names it
addressinteger, optionalThe faulting address, for access faults, misaligned accesses and the load, store, fetch, TLB and PIF causes
framesarray of framesThe faulting instruction first, then the backtrace

warning

Something the user should know that did not stop the monitor, such as a missing release binary to decode against, or events dropped because a reader fell behind.

FieldTypeMeaning
messagestringWhat happened

detached

The board dropped off USB (deep sleep, a replug).

FieldTypeMeaning
pathstringThe port it was on

reconnected

The board is back, possibly on another port path. espx follows a board by its USB serial number.

FieldTypeMeaning
pathstringThe port it is on now

bytes

Raw serial bytes. Only in recordings, never on stdout.

FieldTypeMeaning
hexstringThe bytes, two lowercase hex digits each

Watch events

These come from --until, --expect, --reject and --timeout. A stream ends with matched, rejected, timeout or done.

EventFieldsMeaning
expectedpattern (string), index (integer, from 0)An --expect pattern (or --until) matched a line
matchedpattern (string)The last expectation matched; the command exits 0
rejectedpattern (string)A --reject pattern matched; the command exits 1
timeoutafter_ms (integer)The timeout ran out; the command exits 124
donenoneThe stream ended, or build or flash finished

Build events

diagnostic

One compiler message from cargo.

FieldTypeMeaning
levelstringAs cargo spells it: error, warning, note, failure-note, ...
codestring or nullThe error code, such as E0308
messagestringThe message
filestring or nullThe primary span's file
lineinteger or nullIts line
columninteger or nullIts column
renderedstring or nullcargo's rendered text, exactly what cargo would print

size

The built image, after a successful build.

FieldTypeMeaning
flashintegerBytes of the image that go to flash
ramintegerBytes of static RAM, not counting the stack
app_partitioninteger or nullBytes in the app partition the image must fit

Flash events

EventFieldsMeaning
flashingpercent (integer 0 to 100), offset (integer, optional)Flash progress. With offset, the progress of the region written at that address. Without it, the start (0) and end (100) of the whole flash
flashedbytes (integer), ms (integer)The flash finished: the image size (0 when espflash did not report it) and how long the write took

run and flash --monitor emit flashing, flashed, then reconnected once the board is back, then reset and the boot log. Plain flash --json emits the per-region flashing events and ends with done.

Device events

devices --watch --json prints these:

EventFieldsMeaning
attachedport (a port)A board was plugged in
detachedpath (string)A board was unplugged

Shared types

frames

FieldTypeMeaning
addressintegerThe code address
functionstring or nullThe function, when the release binary resolves it
filestring or nullThe source file; relative when inside the project
lineinteger or nullThe source line

port

FieldTypeMeaning
pathstringThe serial port, such as /dev/cu.usbmodem101
usbobject or nullvid and pid (integers), and serial_number, manufacturer and product when the device reports them
descriptionstringManufacturer and product, or the port type
board_idstring, optionalThe board model id from espx boards, only when the USB ids identify exactly one model
warningobject, optionalA likely driver problem: problem (system_driver), message, and driver (the URL of the driver to install)

A board's id, which espx.toml, names and agent policies use, is usb.serial_number when present, else path.

Data documents

These commands print one pretty-printed JSON document with --json:

CommandDocument
devicesArray of ports
devices --probeArray of devices: port, board (the info document or null), error (string or null), lease (board and holder while another process holds it, or null)
infochip, and revision, crystal, flash_size, features, mac as strings or null
chipsArray of chips: id, name, arch (xtensa or riscv), rust_target, stable (boolean)
boardsArray of board models: id, name, chip, usb (array of vid and pid), led (GPIO or null), led_kind, button, uart_tx, uart_rx, link
boardOne board model, as in boards
depsArray of name, version, source (string or null)
doctorArray of checks: name, status (ok, missing or outdated), detail (the version for ok, installed and latest for outdated), optional, fix (the command that fixes it)
contextproject, chip, board, bound, locked, crates, hal_features, binary, examples, attached
agentboards (array of board ids), flash, erase
logArray of audit entries; see Agent policy

In context, project holds dir, name, channel, target, chip and defmt; bound is the [board] id from espx.toml; locked says whether the versions in crates come from Cargo.lock (true) or from Cargo.toml's requirements; examples is the esp-hal examples URL or null.

Errors

A failing command prints one error: line on stderr, as text, even with --json. The error codes in the schema's ErrorCode type appear in MCP tool results and the audit log; see Exit codes.