diff --git a/bin/test-config-check.sh b/bin/test-config-check.sh index 6ebbe54453..4c97480823 100755 --- a/bin/test-config-check.sh +++ b/bin/test-config-check.sh @@ -402,12 +402,12 @@ assert "config.d overrides are reported" 0 configd-conflict/config.yaml check \ "files define a 'Lora:' section" \ "The file loaded last wins" \ "Result: 0 errors," -# Switch tables are the one place "last wins" is false: the loader only ever writes -# HIGH, so the effective table is the OR of every file. Proven with --output-yaml. -assert "switch tables across files do not override" 1 rfswitch-sticky/config.yaml check \ - "These do NOT override each other" \ - "a HIGH from an earlier file survives a later file that sets LOW" \ - "Enable exactly one" +# rfswitch_table follows "last file wins" like every other Lora: key: no special-cased +# error, just the standard cross-file-overlap info. +assert "rfswitch tables across files: last one wins" 0 rfswitch-last-wins/config.yaml check \ + "'Lora.rfswitch_table' is set in 2 files" \ + "The file loaded last wins" \ + "Result: 0 errors," echo echo "--check takes precedence over --output-yaml:" diff --git a/src/platform/portduino/ConfigCheck.cpp b/src/platform/portduino/ConfigCheck.cpp index 1616604b77..5688927d04 100644 --- a/src/platform/portduino/ConfigCheck.cpp +++ b/src/platform/portduino/ConfigCheck.cpp @@ -915,18 +915,6 @@ void checkCrossFileOverlap(const PathIndex &paths, const std::map" leaves the slot unused. + // not spelled exactly "DIO" (trailing junk included) leaves the slot unused. for (int i = 0; i < 5; i++) { const std::string name = table["pins"][i].as(""); int dioNum = 0; - if (sscanf(name.c_str(), "DIO%d", &dioNum) == 1 && dioNum >= 0 && dioNum <= INT8_MAX) + if (sscanf(name.c_str(), "DIO%d", &dioNum) == 1 && dioNum >= 0 && dioNum <= INT8_MAX && + name == "DIO" + std::to_string(dioNum)) portduino_config.rfswitch_dio_num[i] = (int8_t)dioNum; } diff --git a/test/fixtures/portduino-config/README.md b/test/fixtures/portduino-config/README.md index 9c78eb4051..ad99371703 100644 --- a/test/fixtures/portduino-config/README.md +++ b/test/fixtures/portduino-config/README.md @@ -182,13 +182,11 @@ the last-loaded file is reset to its default - here `config.yaml` sets The load order within `config.d/` comes from the filesystem, so the report warns rather than assuming alphabetical order. -`rfswitch-sticky/` covers the one place where "the file loaded last wins" is false, -and it documents a firmware bug rather than a configuration mistake. Its `config.d/` -holds two switch tables; the last one loaded sets `MODE_RX` LOW on both pins, but the -loader only ever writes HIGH and never writes LOW back, so the HIGH from the earlier -file survives and the effective table is the OR of both. Verified with -`meshtasticd --output-yaml`. Until the loader is fixed, `--check` reports this as an -error and tells you to enable exactly one. +`rfswitch-last-wins/` covers `Lora.rfswitch_table` across two `config.d/` files. It +follows the same "last file loaded wins" rule as every other `Lora:` key - the loader +resets a table's pins and mode rows before applying a replacement, so an earlier +file's `MODE_RX` setting cannot leak through a later file that omits it. `--check` +reports this as the standard cross-file-overlap info, not a special-cased error. ## Running these as a normal boot diff --git a/test/fixtures/portduino-config/rfswitch-sticky/config.d/a-first.yaml b/test/fixtures/portduino-config/rfswitch-last-wins/config.d/a-first.yaml similarity index 100% rename from test/fixtures/portduino-config/rfswitch-sticky/config.d/a-first.yaml rename to test/fixtures/portduino-config/rfswitch-last-wins/config.d/a-first.yaml diff --git a/test/fixtures/portduino-config/rfswitch-last-wins/config.d/b-second.yaml b/test/fixtures/portduino-config/rfswitch-last-wins/config.d/b-second.yaml new file mode 100644 index 0000000000..59597b33a2 --- /dev/null +++ b/test/fixtures/portduino-config/rfswitch-last-wins/config.d/b-second.yaml @@ -0,0 +1,7 @@ +# Sets MODE_RX LOW on both pins. Whichever of this file and a-first.yaml the filesystem +# returns last should fully replace the other's table, per "last file wins". +Lora: + Module: lr1121 + rfswitch_table: + pins: [DIO5, DIO6] + MODE_RX: [LOW, LOW] diff --git a/test/fixtures/portduino-config/rfswitch-last-wins/config.yaml b/test/fixtures/portduino-config/rfswitch-last-wins/config.yaml new file mode 100644 index 0000000000..1781b359ff --- /dev/null +++ b/test/fixtures/portduino-config/rfswitch-last-wins/config.yaml @@ -0,0 +1,4 @@ +# Primary config for the rfswitch_table last-wins case. The two files in config.d/ +# each define a Lora.rfswitch_table; the one loaded last should fully replace it. +General: + ConfigDirectory: config.d/ diff --git a/test/fixtures/portduino-config/rfswitch-sticky/config.d/b-second.yaml b/test/fixtures/portduino-config/rfswitch-sticky/config.d/b-second.yaml deleted file mode 100644 index 1832c76256..0000000000 --- a/test/fixtures/portduino-config/rfswitch-sticky/config.d/b-second.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# FAULT, and it is a firmware bug rather than a typo. This file is loaded LAST and says -# MODE_RX is LOW on both pins, but the loader only ever writes HIGH and never writes -# LOW back, so the HIGH from a-first.yaml survives. The effective table is the OR of -# both files -- a switch state that neither file asked for. Verified with --output-yaml. -Lora: - Module: lr1121 - rfswitch_table: - pins: [DIO5, DIO6] - MODE_RX: [LOW, LOW] diff --git a/test/fixtures/portduino-config/rfswitch-sticky/config.yaml b/test/fixtures/portduino-config/rfswitch-sticky/config.yaml deleted file mode 100644 index ccc3ab9883..0000000000 --- a/test/fixtures/portduino-config/rfswitch-sticky/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Primary config for the sticky-switch-table case. The two files in config.d/ each -# define a Lora.rfswitch_table. -General: - ConfigDirectory: config.d/