Troubleshooting
waiteventalways times out: make sure you actually started the background run ($sim command bg_run) and capture an event-count baseline before starting it. Use-sinceso early callbacks are included. Tcl event processing is required for live data updates, but not for the callback counters.Circuit is not loaded: ensure your circuit issues
.enddirective.Complex data: if you expected real data but get
{re im}pairs, your vector is complex per ngspice. Handle both cases in your Tcl code if needed.Multiple runs: clear old event data between runs if you want pristine event counters and messages buffer:
$sim messages -clearand$sim eventcounts -clear. Data buffer and saved vectors resetted after run of the new simulation to prevent data mixing.Waiting for fast simulations: capture the bg_running counter before starting a background run and pass it to
waitevent -since. Otherwise callbacks received before the wait do not count. The run helper does this automatically. Do not clear event counters while a saved baseline is in use.Live storage across runs: new plots replace live list data as well as resetting live RBC vectors. Synchronous
command runand background execution therefore retain the current plot’s samples, not all previous runs. Call$sim flushafter synchronouscommand runto apply the new plot and its data. The explicitvectors -clearremains useful for consuming samples in batches within a plot or releasing them early; it discards queued samples as well as published samples in both output modes.Halt and resume:
bg_haltpreserves live samples.bg_resumeappends when continuing the same plot, even though ngspice may resend initialization metadata. A subsequent new plot still resets live storage. Wait for the background-start event before halting, and for the stop event before resuming. Capture a fresheventcountsbaseline before each command and usewaitevent bg_running -since $baseline(one event per start or halt). Call$sim flushor process Tcl events to publish queued samples; event counts alone do not publish data.Slider callback reentry: the
runhelper publishes data throughflushand does not callupdate. Pending slider, timer and idle callbacks remain queued until the application returns to the Tcl event loop. RBC vector notifications may still invoke callbacks during publication; reentrant handle operations are rejected while that publication is in progress.
Copyright (c) George Yashin