device

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package device finds connected boards and talks to them over serial.

Index

Constants

This section is empty.

Variables

View Source
var ErrLost = errors.New("connection lost")

ErrLost reports that the port went away while monitoring (board unplugged or reset into a different USB identity).

Functions

func Monitor

func Monitor(ctx context.Context, port string, baud int, opened func(), line func(string)) error

Monitor reads lines from port until ctx is cancelled or the port goes away, calling opened once the port is open and line for each line. DTR and RTS stay de-asserted: asserting them holds many ESP32 boards in reset through the auto-reset circuit.

func ProbeESP

func ProbeESP(port string) string

ProbeESP asks the chip behind port for its ID without resetting it, to tell a live ESP from a bare USB-serial bridge: "verified" when it answers within 2 s, else "silent" (dead, unwired, or running firmware).

func Wait

func Wait(board Port, timeout time.Duration) string

Wait polls for board to be connected again (after a flash resets it), returning its current port, or "" after timeout.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder turns the code addresses in ESP-IDF panic output (backtraces, "abort() was called at PC", the register dump's PC) into functions and source lines with addr2line against the app's ELF. (The register dump's PC is not decoded: it repeats the backtrace's first frame.) Generated C carries #line directives, so Volt code decodes to main.volt lines.

func NewDecoder

func NewDecoder(elf, addr2line string) *Decoder

NewDecoder returns nil when the ELF or addr2line is missing.

func (*Decoder) Line

func (d *Decoder) Line(s string) (frames []Frame, warning string)

Line inspects one monitor line. ESP-IDF's panic handler prints the running app's ELF hash after the backtrace, so decoded frames are held until that line: they are returned if the hash matches the ELF, dropped with a warning if not (the frames would name the wrong code). A reboot or halt line without a hash releases them unverified.

type Frame

type Frame struct {
	PC       string `json:"pc"`
	Func     string `json:"func"`
	File     string `json:"file,omitempty"`
	Line     int    `json:"line,omitempty"`
	Inlined  bool   `json:"inlined,omitempty"` // inlined into the frame above
	Resolved bool   `json:"resolved"`
}

Frame is one decoded code address.

type Port

type Port struct {
	Port      string `json:"port"` // serial device, or mount path when bootsel
	Chip      string `json:"chip"` // ESP32, ESP32-S3, RP2040, RP2350, STM32, Unknown
	Desc      string `json:"desc"`
	VendorID  string `json:"vendorId"`
	ProductID string `json:"productId"`
	Serial    string `json:"serialNumber,omitempty"`
	State     string `json:"state"`           // running (serial) or bootsel (mass storage)
	Probe     string `json:"probe,omitempty"` // ESP only, with --probe: verified or silent
}

Port is one connected board. The JSON shape matches the IDE's scan_devices entries.

func List

func List() ([]Port, error)

List returns connected boards: USB serial ports, then Picos in BOOTSEL.

func (Port) Matches

func (p Port) Matches(chip string) bool

Matches reports whether the port's detected chip is chip (volt.toml name).

func (Port) SameBoard

func (p Port) SameBoard(q Port) bool

SameBoard reports whether q is the same physical board as p, e.g. after it re-enumerated under another name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL