interface
UseVemuResult
Everything useVemu returns: emulator status, board selection, program/run controls, video + UART wiring callbacks, and the peripheral inspector surface.
interface UseVemuResultFields
| Name | Type | Description |
|---|---|---|
status | VemuStatus | Current emulator lifecycle state. |
boards | BoardInfo[] | Boards compiled into the loaded runtime. |
selectedBoard | string | Id of the currently selected board (empty string until boards are listed). |
setSelectedBoard | Dispatch<SetStateAction<string>> | Select a board by id; instantiates a fresh (non-running) machine for it. |
selectedHasDisplay | boolean | Static display capability of the selected board (false when unknown). |
hasVideo | boolean | True once the running machine has produced at least one video frame. |
ips | string | Human-readable simulated clock speed (e.g. "4.2 MHz"); empty while not running. |
loadProgram | (data: Uint8Array, kind: ProgramKind, boardOverride?: string) => void | Load a program (ROM/ELF/binary) and start running, optionally switching board first. |
loadLinux | (kernel: Uint8Array, initrd: Uint8Array, boardOverride?: string) => void | Boot a Linux kernel + initramfs (arm64) and start running, optionally switching board first. Uses the wasm `newLinux` factory: the board builder generates the DTB and bootargs, so only the raw kernel `Image` and `initrd` bytes are passed. UART wiring is identical to loadProgram. |
loadRiscvLinux | ( firmware: Uint8Array, image: Uint8Array, initrd: Uint8Array, boardOverride?: string, ) => void | Build + start a RISC-V Linux machine from OpenSBI firmware + kernel Image + initramfs (the `vemu_riscv64_virt` board), optionally switching board. |
loadUicr | (data: Uint8Array) => boolean | Load a raw UICR image (uicr.bin) into the running machine's UICR region. Returns false when no machine is built or the board has no UICR. Not persisted - re-apply after loading a new program image. |
loadWithFiles | ( files: Array<{ id: string; bytes: Uint8Array; addr?: number; kind?: ProgramKind }>, boardOverride?: string, cmdline?:... | Build + start a machine from a board-declared set of file slots (the generic path behind every board's loader UI). Each entry pairs a slot id with its bytes plus an optional load-address override and program `kind`. Supersedes loadProgram/loadLinux/loadRiscvLinux for the slot-based UI. |
stop | () => void | Pause the run loop (status returns to "ready"). |
reset | () => void | Reset the machine and restart with the last loaded program. |
eraseAll | () => void | Discard the current machine and rebuild the selected board with empty flash. |
setDraw | (cb: (f: VemuFrame) => void) => void | Register the callback that renders video frames (wired up by `VemuCanvas`). |
setUartSink | (cb: (b: Uint8Array) => void) => void | Register the sink for UART output bytes (wired up by `VemuTerminal`). |
setTerminalClear | (cb: () => void) => void | Register a callback that clears the terminal UI (wired up by `VemuTerminal`); invoked on `reset()` / `eraseAll()` so a reboot starts from a clean screen. |
sendUart | (bytes: Uint8Array) => void | Send UART input bytes to the running machine. |
peripheralList | string[] | Names of inspectable peripherals exposed by the current machine. |
peripheralEvents | PeripheralEvent[] | Rolling buffer (last 100) of peripheral events emitted by the machine. |
peripheralError | string | null | Build/exposure error to surface in the peripheral panel, or null. |
snapshotVersion | number | Monotonic counter that bumps when inspector snapshots should be re-pulled. |
getPeripheralSnapshot | (name: string) => PeripheralSnapshot | null | Pull the current snapshot for a peripheral by name (null if unavailable). |
sendPeripheralCommand | (name: string, cmd: { name: string; params: Record<string, string> }) => void | Send a command to a peripheral's inspector. |
sendUartRx | (target: string, bytes: number[], timing?: TimingSpec) => void | Deliver UART RX bytes to a named UART, optionally at a precise virtual time (deterministic timed delivery). Absent `timing` is immediate. |
clockHz | number | Guest clock in Hz (cycles/sec), or 0 when unknown. |