Skip to content

netsrv.c: /system endpoint hardcodes power=0, breaks frontend monitoring #561

Description

@rmurray484

Description

The /system JSON endpoint in webfrontend/netsrv.c hardcodes "power": 0
on line 313 (and "reset": 0 on line 312), regardless of the simulator's
actual run state.

httpdPrintf(conn, "\"reset\": %d, ", 0 /*reset*/);
httpdPrintf(conn, "\"power\": %d ", 0 /*power*/);

The /*power*/ and /*reset*/ inline comments suggest these were
placeholder values during early development — likely pending wiring to the
actual simulator state variables.

Impact

Any frontend that polls /system and reads state.power will always see
the simulator as "powered off" — even when the CPU is actively running CP/M
or any other ROM/program. This breaks status indicators and any auto-recovery
logic that gates on state.power == 1.

Reproduction

  1. Build any frontpanel-enabled machine (e.g. imsaisim)
  2. Start with -n flag (web frontend enabled)
  3. Boot CP/M in the terminal — emulator is clearly running
  4. curl http://localhost:8080/system | jq .state
  5. Observed: {"last_error": 0, "cpu_error": 0, "reset": 0, "power": 0}
  6. Expected: power: 1 while simulator is running

Context

Discovered while deploying imsaisim in a headless Linux container
(Debian 13 trixie) for a public-facing web demo. Frontend showed
"System offline. Reload?" loop because it interpreted state.power == 0
as the simulator being down, despite CP/M booting fine and accepting
keyboard input via the /tty WebSocket.

We don't propose a specific fix path here — wiring state.power and
state.reset to actual simulator state may interact with the CPA
(Control Panel Adapter, see #38) work and the FRONTPANEL conditional
compilation paths, which warrant maintainer judgment.

Environment

  • z80pack: master HEAD 91fd28eb (release 1.38)
  • Build: make FRONTPANEL=NO INFOPANEL=NO build for headless container deployment
  • OS: Debian 13 trixie (libc 2.41), x86_64

Reported by Richard Murray, in collaboration with Claude (Anthropic) — colossus-ia.org

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions