Serial console for an ESP-IDF target.

The page supplies an already granted port and a terminal. Chip text is written to the terminal. Ctrl+T menu commands, panic and core-dump capture, and address decoration stay inside this object and are reported with IDFMonitor.on.

Constructors

Properties

baudRate: number
coldFailures: number = 0
colorizer: Colorizer
connectedOnce: boolean = false
coredump: CoredumpDetector = ...
customHardReset?: string
customReset?: string
decodeAddresses: boolean
decodeCoredumps: boolean
decodePanic: boolean
decoder: null | SymbolAddressDecoder = null
digests: string[] = []
elfFiles: ElfFile[]
encrypted: boolean
eol: "\r\n" | "\n" | "\r"
exitEmitted: boolean = false
gdb: GdbStubDetector = ...
keySubscription: null | {
    dispose(): void;
} = null

Type declaration

lines: LineBuffer
logCapture: null | string[] = null
lookback: string[] = []
loopPromise: Promise<void> = ...
matcher: LineMatcher
noReset: boolean
openPortAttempts: number
outputEnabled: boolean = true
panic: PanicDecoder = ...
parser: ConsoleParser
pauseGate: Promise<void> = ...
paused: boolean = false
progName: undefined | string
reader: undefined | ReadableStreamDefaultReader<Uint8Array>
ready: Promise<void>
readySettled: boolean = false
reconnectDelayMs: number
rejectReady: ((error) => void)

Type declaration

    • (error): void
    • Parameters

      • error: Error

      Returns void

resolvePause: (() => void) = ...

Type declaration

    • (): void
    • Returns void

resolveReady: (() => void)

Type declaration

    • (): void
    • Returns void

romElf?: ArrayBuffer | Uint8Array
stamper: Timestamper
state: "stopped" | "idle" | "running" = "idle"
stopRequested: boolean = false
target: string
terminal: MonitorTerminal
timestampsEnabled: boolean
wait: ((ms) => Promise<void>)

Type declaration

    • (ms): Promise<void>
    • Parameters

      • ms: number

      Returns Promise<void>

waiter: null | ExpectWaiter = null
writeQueue: Promise<void> = ...

Methods

  • Reset the chip into the download bootloader.

    Returns Promise<void>

    Resolves when the sequence has finished.

  • Drop a waiting expect without resolving it. Used when the monitor stops.

    Returns void

  • Continue a chip that stopped in the gdb stub, then read the port again. Writes +$c#63. No local debugger is started.

    Returns Promise<void>

    Resolves when reading has resumed.

  • Write a resolved address under the chip line and emit it.

    Parameters

    Returns void

  • Emit exit once per session.

    Parameters

    • code: number

      Status code.

    Returns void

  • Wait until a chip line matches. Recent lines are checked before new ones. The pattern is tested against the line with its newline removed, so $ matches the end.

    Parameters

    • pattern: string | RegExp

      Regular expression. A string is compiled with new RegExp.

    • Optional timeoutSeconds: number

      When set, the promise rejects with ExpectTimeoutError.

    Returns Promise<string>

    The matching line without its newline.

  • Reject start because the port never opened.

    Parameters

    • error: Error

      Open failure.

    Returns void

  • Cancel the reader after paused is already set, then let continueStub proceed. Called without awaiting so the read loop can leave handleFragment and notice paused.

    Returns Promise<void>

    Resolves when the read loop has stopped.

  • Decode one chip fragment. Detectors run before the print filter.

    Parameters

    • fragment: string

      Text, including a trailing newline when it has one.

    • newline: boolean

      True when the fragment ends a line.

    Returns void

  • Load every ELF before the first open so a bad image fails start.

    Returns Promise<void>

    Resolves when the images are indexed.

  • Write a monitor status block. Each line is prefixed with --- .

    Parameters

    • text: string

      Status text. Newlines are preserved as separate status lines.

    Returns void

  • Remove a subscription created with on.

    Type Parameters

    Parameters

    • event: K

      Event id.

    • handler: ((payload) => void)

      The same function that was registered.

    Returns this

    This monitor.

  • Subscribe to a monitor event.

    Type Parameters

    Parameters

    • event: K

      Event id.

    • handler: ((payload) => void)

      Called with the payload.

    Returns this

    This monitor, so subscriptions can be chained.

  • Handle one terminal character at a time, matching the Python console parser.

    Parameters

    • data: string

      Text from terminal.onData.

    Returns void

  • Subscribe to the next occurrence of an event.

    Type Parameters

    Parameters

    • event: K

      Event id.

    • handler: ((payload) => void)

      Called once.

    Returns this

    This monitor.

  • Open the port and run the startup line sequence. A reconnect passes false and does not reset the chip.

    Parameters

    • first: boolean

      True only for the first open of this session.

    Returns Promise<void>

    Resolves when the port is open.

  • Enter the bootloader with the classic, USB-JTAG, or custom sequence.

    Returns Promise<void>

    Resolves when the sequence has finished.

  • Pulse EN, or run the custom hard-reset sequence.

    Returns Promise<void>

    Resolves when the lines have been restored.

  • Filter, color, timestamp, and decorate one fragment.

    Parameters

    • fragment: string

      Original fragment, including its newline.

    • newline: boolean

      Whether the fragment ends a line.

    • stripped: string

      Fragment without CR or LF.

    • forceHide: boolean

      True while a panic stack dump is being captured.

    Returns void

  • Read until stop, gdb pause, or a cold-open failure.

    Parameters

    • greet: boolean

      True for the initial open, which may reset the chip.

    Returns Promise<void>

    Resolves when this loop stops reading.

  • Release a reader lock if this loop still holds it.

    Parameters

    • reader: undefined | ReadableStreamDefaultReader<Uint8Array>

      Reader to release.

    Returns void

  • Remember a line for expect, and complete a waiting expect when it matches.

    Parameters

    • line: string

      Line without its newline.

    Returns void

  • Tell the page that the operator asked to flash. This package does not run esptool.

    Parameters

    • action: "flash" | "app-flash" | "flash-all"

      Which flash command was chosen.

    Returns void

  • Hard-reset the chip through RTS.

    Returns Promise<void>

    Resolves when the pulse has finished.

  • Install a fresh ready promise for the next open.

    Returns void

  • Run a menu command.

    Parameters

    • action: MenuAction

      Command selected by the parser.

    • Optional key: string

      Original character, for forwarded and unknown keys.

    Returns Promise<void>

    Resolves when the command has been issued.

  • USB identity, or an empty object when the port cannot report it.

    Returns SerialPortInfo

    Vendor and product ids.

  • Write text to the device, followed by the configured end-of-line.

    Parameters

    • text: string

      Characters to send. The end-of-line is added.

    Returns Promise<void>

    Resolves when the bytes are written.

  • Pause the caller. Command-stream scripts use this between send and expect.

    Parameters

    • seconds: number

      How long to wait.

    Returns Promise<void>

    Resolves when the wait is over.

  • Open the port if it is closed, optionally hard-reset the chip, and start reading. Resolves when the first open succeeds.

    Returns Promise<void>

    Resolves when chip bytes can be received.

  • Stop reading, unsubscribe the terminal, and close the port.

    Returns Promise<void>

    Resolves when the port is closed.

  • Start or stop an in-memory copy of terminal output. The captured text is on the log-toggle event when capture stops.

    Returns boolean

    True when capture is running.

  • Show or hide chip text. Status lines are still written.

    Returns boolean

    True when chip text is visible.

  • Turn line timestamps on or off.

    Returns boolean

    True when timestamps are written.

  • Queue a device write so keystrokes cannot interleave.

    Parameters

    • data: Uint8Array

      Bytes to send.

    Returns Promise<void>

    Resolves when this write finishes.

  • Write to the terminal and, when capture is on, keep a copy.

    Parameters

    • data: string

      Text, including ANSI sequences.

    Returns void