Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ had changed in them - which is the gap this file exists to close.

### Added

- **A build says whether it takes MeshCore's console commands.** A firmware
that is not MeshCore is no longer sent provisioning it refuses line by line,
and an experiment arm that would pin a setting onto one is refused before
the run rather than producing cells that differ by nothing. `dialect` on
`firmware.import`, `firmware.update` and `firmware.details`, and a switch
in the build's window.
- **Renode boards can run in lockstep with the engine.** With
`MESHBENCH_RENODE_LOCKSTEP=1`, an nRF52 board's CPU and chip advance one
millisecond of virtual time per millisecond the engine asks for, with the
Expand Down
20 changes: 20 additions & 0 deletions docs/firmware-build-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ the card with nothing saying why.
**Verbs:** `node.card {node, fitted, file, wipe}`, and `firmware.wipe` for all
of them at once.

## Takes MeshCore's console commands

On by default. Provisioning, and every setting an experiment arm pins, is
MeshCore's command line typed at the node's console: `set name`, `set lat`,
`region put`, and so on. A firmware that is not MeshCore refuses each line, and
the only trace was a line in its console:

```
set name Deck Error: unknown config: name Deck
```

Off, a node running this build is sent none of it. The Provisioning panel says
so in place of the script, and `experiment.start` refuses an arm that would pin
a setting onto such a node, because a setting that did not apply makes two
cells that differ by nothing.

The verbs call it `dialect`: `meshcore`, `none`, or another firmware's name.
`firmware.import` takes it too, so a third-party image is never provisioned on
its first run.

## Notes

`notes`
Expand Down
6 changes: 3 additions & 3 deletions docs/scripting-verbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ Two verbs are **not** in this table:
| `firmware.build_failed` | — | — | *none* — the build worker telling the store it failed |
| `firmware.built` | — | `built` | *none* — the build worker telling the store it finished |
| `firmware.delete` | *a bare string*, `path` string | `deleted` | `wb.firmware.delete(build)` |
| `firmware.details` | *a bare string*, `version` string, `role` string, `board` string | `role`, `version`, `board`, `native`, `on_disk`, `path`, `settings_path`, `bytes`, `modified`, `in_use`, `kind`, `bootable`, `flash_mb`, `coproc_at_reset`, `card_required`, `notes` | `wb.firmware.details(build)` |
| `firmware.details` | *a bare string*, `version` string, `role` string, `board` string | `role`, `version`, `board`, `native`, `on_disk`, `path`, `settings_path`, `bytes`, `modified`, `in_use`, `kind`, `bootable`, `flash_mb`, `coproc_at_reset`, `card_required`, `dialect`, `notes` | `wb.firmware.details(build)` |
| `firmware.download` | *a bare string*, `role` string, `version` string, `board` string | `downloading`, `role`, `version`, `board`, `job` | `wb.firmware.download(role, version, board=None)` |
| `firmware.failed` | *a bare string*, `reason` string | — | *none* — the firmware starter reporting a failure |
| `firmware.import` | *a bare string*, `path` string, `role` string, `board` string, `label` string, `version` string | `version`, `role`, `board`, `path`, `bytes` | `wb.firmware.import_(path, role, board=None, label="")` |
| `firmware.import` | *a bare string*, `path` string, `role` string, `board` string, `label` string, `version` string, `dialect` string | `version`, `role`, `board`, `path`, `bytes` | `wb.firmware.import_(path, role, board=None, label="")` |
| `firmware.installed` | — | `cache`, `installed` | `wb.firmware.installed` |
| `firmware.library` | — | `builds`, `count` | `wb.firmware.library` |
| `firmware.needed` | — | `roles` | `wb.firmware.needed()` |
Expand All @@ -221,7 +221,7 @@ Two verbs are **not** in this table:
| `firmware.start` | — | `starting` | `wb.firmware.start()` |
| `firmware.started` | — | `running`, `playing` | *none* — the firmware starter reporting back |
| `firmware.state` | — | `running`, `nodes`, `total`, `starting` | `wb.firmware.state() / wb.firmware.wait_started()` |
| `firmware.update` | *a bare string*, `version` string, `role` string, `board` string, `label` string, `new_role` string, `new_board` string, `card_required` bool, `coproc_at_reset` bool, `notes` string | `role`, `version`, `board`, `path`, `renamed`, `repinned`, `settings` | `wb.firmware.update(build, label=\|new_role=\|coproc_at_reset=\|notes=)` |
| `firmware.update` | *a bare string*, `version` string, `role` string, `board` string, `label` string, `new_role` string, `new_board` string, `card_required` bool, `coproc_at_reset` bool, `dialect` string, `notes` string | `role`, `version`, `board`, `path`, `renamed`, `repinned`, `settings` | `wb.firmware.update(build, label=\|new_role=\|coproc_at_reset=\|notes=)` |
| `firmware.window` 🪟 | *a bare string*, `version` string, `role` string, `board` string | `role`, `version`, `board` | `wb.firmware.window(build)` |
| `firmware.wipe` | — | `wiped`, `root`, `cards` | `wb.firmware.wipe()` |

Expand Down
6 changes: 4 additions & 2 deletions docs/verb-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ Report everything known about one build: where it is, what it is, and what has b
| `role` | string | optional | which role, when one label carries more than one |
| `board` | string | optional | which board; absent means a build for this machine |

**Answers** `role`, `version`, `board`, `native`, `on_disk`, `path`, `settings_path`, `bytes`, `modified`, `in_use`, `kind`, `bootable`, `flash_mb`, `coproc_at_reset`, `card_required`, `notes`. Answered from the library, so a published build nobody has fetched is described too: `on_disk` is then false and `path` and `bytes` are empty. `in_use` counts the nodes pinned to it, `kind`, `bootable` and `flash_mb` are read from a board image and say nothing about a native build, `settings_path` is where its settings would be written whether any exist or not, and `modified` is absent for a build not on this machine. A label naming more than one build is refused rather than guessed at.
**Answers** `role`, `version`, `board`, `native`, `on_disk`, `path`, `settings_path`, `bytes`, `modified`, `in_use`, `kind`, `bootable`, `flash_mb`, `coproc_at_reset`, `card_required`, `dialect`, `notes`. Answered from the library, so a published build nobody has fetched is described too: `on_disk` is then false and `path` and `bytes` are empty. `in_use` counts the nodes pinned to it, `kind`, `bootable` and `flash_mb` are read from a board image and say nothing about a native build, `settings_path` is where its settings would be written whether any exist or not, and `modified` is absent for a build not on this machine. A label naming more than one build is refused rather than guessed at.

**Example** - find out where a build lives and what is running it

Expand Down Expand Up @@ -1853,6 +1853,7 @@ Put somebody's own build into the library, which is how a change is tested again
| `board` | string | optional | the board it is for; absent means a build for this machine |
| `label` | string | optional | what the library will know it by and what a node pins; absent, it is stamped with a timestamp so a second import does not replace the first in place |
| `version` | string | optional | an older name for `label`, read only when `label` is absent, because scripts written against it are already out in the world |
| `dialect` | string | optional | the console vocabulary the image speaks: meshcore, absent included, for MeshCore's own; none for a firmware with no console; or the name of another. A node running a build that is not MeshCore's is not sent provisioning, which it would refuse line by line |

**Answers** `version`, `role`, `board`, `path`, `bytes`. `version` is the label the build was stored under, which is the timestamp when none was given and is what `firmware.set` then has to be handed.

Expand Down Expand Up @@ -2031,6 +2032,7 @@ Rename a build, move it to another board or role, or change how it is run.
| `new_board` | string | optional | move it to this board instead; unchanged when absent |
| `card_required` | bool | optional | this firmware will not get far without storage in the board's slot, so every node running it is given a card whatever it would otherwise have had |
| `coproc_at_reset` | bool | optional | start this build's coprocessors enabled, which the part does not do - for a firmware that traps inside its own exception vector and cannot be seen past |
| `dialect` | string | optional | the console vocabulary the build speaks: meshcore for MeshCore's own, none for no console, or another name; absent leaves it alone. Anything but meshcore means nodes running this build are not provisioned, and an experiment arm that pins settings onto one is refused |
| `notes` | string | optional | what the next person should know about this build |

**Answers** `role`, `version`, `board`, `path`, `renamed`, `repinned`, `settings`. The build's identity after the change comes back, with `renamed` saying whether the file actually moved and `repinned` how many nodes were pointed at the new name, which happens on their behalf so none is left naming a build nothing answers to. `settings` holds `coproc_at_reset`, `card_required` and `notes` as they now stand. Refused for a build not on this machine, and refused while a node is running it.
Expand Down Expand Up @@ -3782,7 +3784,7 @@ Put every arm through every seed on a worker, each cell in its own engine with n

**Takes** nothing.

**Answers** `running`, `runs`, `reproducible`, `not_reproducible_why`. `runs` is how many cells were queued. Poll experiment.state until `running` goes false. It refuses where a sweep is already running, where no network is loaded, where no sender has been named, and where the last sweep's cell in flight has not yet let go of the results table. `reproducible` is false where the network carries a node running in an emulator, whose firmware is stepped by the emulator's clock rather than by the run's: the cells then differ for reasons the matrix does not record, so the arms measure nothing against each other, and `not_reproducible_why` says which node, empty when there is none. The sweep still runs - a single arm on emulated firmware is a legitimate thing to watch - but a script comparing arms should stop here.
**Answers** `running`, `runs`, `reproducible`, `not_reproducible_why`. `runs` is how many cells were queued. Poll experiment.state until `running` goes false. It refuses where a sweep is already running, where no network is loaded, where no sender has been named, and where the last sweep's cell in flight has not yet let go of the results table. `reproducible` is false where the network carries a node running in an emulator, whose firmware is stepped by the emulator's clock rather than by the run's: the cells then differ for reasons the matrix does not record, so the arms measure nothing against each other, and `not_reproducible_why` says which node, empty when there is none. The sweep still runs - a single arm on emulated firmware is a legitimate thing to watch - but a script comparing arms should stop here. Refused before anything runs when an arm pins a setting onto a node whose firmware does not take MeshCore's console commands (`firmware.update` `dialect`), naming the arm and the nodes: the setting would not apply, and the cells would differ by nothing.

**Example** - start the matrix that is defined

Expand Down
13 changes: 12 additions & 1 deletion docs/verbs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@
"reproducible",
"not_reproducible_why"
],
"answers": "`runs` is how many cells were queued. Poll experiment.state until `running` goes false. It refuses where a sweep is already running, where no network is loaded, where no sender has been named, and where the last sweep's cell in flight has not yet let go of the results table. `reproducible` is false where the network carries a node running in an emulator, whose firmware is stepped by the emulator's clock rather than by the run's: the cells then differ for reasons the matrix does not record, so the arms measure nothing against each other, and `not_reproducible_why` says which node, empty when there is none. The sweep still runs - a single arm on emulated firmware is a legitimate thing to watch - but a script comparing arms should stop here.",
"answers": "`runs` is how many cells were queued. Poll experiment.state until `running` goes false. It refuses where a sweep is already running, where no network is loaded, where no sender has been named, and where the last sweep's cell in flight has not yet let go of the results table. `reproducible` is false where the network carries a node running in an emulator, whose firmware is stepped by the emulator's clock rather than by the run's: the cells then differ for reasons the matrix does not record, so the arms measure nothing against each other, and `not_reproducible_why` says which node, empty when there is none. The sweep still runs - a single arm on emulated firmware is a legitimate thing to watch - but a script comparing arms should stop here. Refused before anything runs when an arm pins a setting onto a node whose firmware does not take MeshCore's console commands (`firmware.update` `dialect`), naming the arm and the nodes: the setting would not apply, and the cells would differ by nothing.",
"example": {
"params": {},
"what": "start the matrix that is defined"
Expand Down Expand Up @@ -1926,6 +1926,7 @@
"flash_mb",
"coproc_at_reset",
"card_required",
"dialect",
"notes"
],
"answers": "Answered from the library, so a published build nobody has fetched is described too: `on_disk` is then false and `path` and `bytes` are empty. `in_use` counts the nodes pinned to it, `kind`, `bootable` and `flash_mb` are read from a board image and say nothing about a native build, `settings_path` is where its settings would be written whether any exist or not, and `modified` is absent for a build not on this machine. A label naming more than one build is refused rather than guessed at.",
Expand Down Expand Up @@ -2016,6 +2017,11 @@
"name": "version",
"type": "string",
"what": "an older name for `label`, read only when `label` is absent, because scripts written against it are already out in the world"
},
{
"name": "dialect",
"type": "string",
"what": "the console vocabulary the image speaks: meshcore, absent included, for MeshCore's own; none for a firmware with no console; or the name of another. A node running a build that is not MeshCore's is not sent provisioning, which it would refuse line by line"
}
],
"returns": [
Expand Down Expand Up @@ -2215,6 +2221,11 @@
"type": "bool",
"what": "start this build's coprocessors enabled, which the part does not do - for a firmware that traps inside its own exception vector and cannot be seen past"
},
{
"name": "dialect",
"type": "string",
"what": "the console vocabulary the build speaks: meshcore for MeshCore's own, none for no console, or another name; absent leaves it alone. Anything but meshcore means nodes running this build are not provisioned, and an experiment arm that pins settings onto one is refused"
},
{
"name": "notes",
"type": "string",
Expand Down
105 changes: 105 additions & 0 deletions internal/app/session/dialect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Which firmware takes MeshCore's console commands.
//
// Provisioning, and every setting an experiment arm pins, is a run of MeshCore
// CLI lines typed at a node's console. A firmware that is not MeshCore refuses
// each of them, and the only trace was a line in its console somebody had to
// read - "set name Deck Error: unknown config". So a build can say what it
// speaks, a node running one that does not speak MeshCore's is not sent it,
// and an arm that would pin a setting onto one is refused before the run.
package session

import (
"fmt"
"sort"
"strings"

"github.com/MeshBench/meshbench/internal/app/state"
"github.com/MeshBench/meshbench/internal/firmware"
"github.com/MeshBench/meshbench/internal/world/scenario"
)

// dialectOf is the console vocabulary a node's build speaks, or "" for
// MeshCore's own.
func dialectOf(n scenario.Node, installed []firmware.Installed) string {
if n.Firmware.Version == "" {
return ""
}
for _, in := range installed {
if in.Board == n.Firmware.Board && in.Version == n.Firmware.Version &&
sameRole(in.Role, string(n.Firmware.Role)) {
if set := firmware.LoadBuildSettings(in.Path); !set.SpeaksMeshCore() {
return set.Dialect
}
return ""
}
}
return ""
}

// sameRole matches an installed image to the role a node names, as the engine
// does when it boots one: the role itself, or that role plus the transport a
// published companion carries. Matching on board and version alone took a
// repeater and a companion image of one version for each other, and each has
// its own settings.
func sameRole(installed, node string) bool {
return node == "" || installed == node || strings.HasPrefix(installed, node+"_")
}

// withDialect is a node's provisioning script, or in place of it one line
// saying why there is none.
func withDialect(n scenario.Node, lines []state.ProvisionLine) []state.ProvisionLine {
d := dialectOf(n, firmware.ListInstalled(firmware.DefaultCacheDir()))
if d == "" {
return lines
}
return []state.ProvisionLine{{
Command: fmt.Sprintf("# %s runs %s, which does not take MeshCore's console commands: "+
"nothing is sent", n.Name, describeDialect(d)),
Why: "a build declares the console vocabulary it speaks, and this one is not MeshCore's",
Comment: true,
}}
}

func describeDialect(d string) string {
if d == "none" {
return "a firmware with no console"
}
return d + " firmware"
}

// PinsSettings reports whether this arm sets anything provisioning carries, as
// opposed to only choosing builds or timing.
func (a ExpArm) PinsSettings() bool {
return a.PathHashMode != nil || a.RepPathHash != nil ||
a.LoopDetect != "" || a.CAD != "" || len(a.Set) > 0
}

// RefuseUnprovisionable says which arms would pin settings onto nodes whose
// firmware cannot take them, or "" when none would. Each node is judged on the
// build the arm runs it on.
func (s *Sim) RefuseUnprovisionable(arms []ExpArm, nodes []scenario.Node) string {
installed := firmware.ListInstalled(firmware.DefaultCacheDir())
var bad []string
for _, arm := range arms {
if !arm.PinsSettings() {
continue
}
var names []string
for _, n := range nodes {
n = WithFirmware(n, SweepArm{RepeaterVersion: arm.RepeaterVersion,
CompanionVersion: arm.CompanionVersion})
if d := dialectOf(n, installed); d != "" {
names = append(names, fmt.Sprintf("%s (%s)", n.Name, d))
}
}
if len(names) > 0 {
sort.Strings(names)
bad = append(bad, fmt.Sprintf("arm %q pins settings onto %s", arm.Label, strings.Join(names, ", ")))
}
}
if len(bad) == 0 {
return ""
}
return strings.Join(bad, "; ") + ", whose firmware does not take MeshCore's console commands, " +
"so the settings would not apply and the cells would differ by nothing"
}
Loading