Merge bench/rf-cmd into main
tth-docs / site (push) Successful in 20s
pub-release / release (push) Failing after 13m45s

This commit is contained in:
tth committed 2026-12-04 19:18:14 +01:00
commit 171d350c16
4 files changed
+85

No files matched your search

+3
View File
@@ -312,6 +312,8 @@ console shows its state.
| `set pwr.bootlock <mV>` | SenseCAP Solar repeater (`PWRMGT_RUNTIME`) | do not start below this voltage, 3000..4200 or `off`; saved on the node, see [power.md](power.md) |
| `set pwr.cutoff <mV>` | same | switch a running node off below this voltage, 3000..4200 or `off`. Must stay under the bootlock; neither may be above the battery right now |
| `bench batt [mV\|off\|poll]` | own build (`BENCH_BATT_OVERRIDE`), local only | override battery voltage for adaptive power-save testing (simulates battery without USB; `poll` triggers one sample immediately) |
| `bench preamble <symbols>\|0` | own build (`BENCH_RF_CMD`), repeater, local only | transmit with this preamble length instead of the SF's default (0 = back), to stand in for senders on older firmware in RX-loss tests |
| `bench tx <count> <len> <gap ms> [jitter ms]` / `bench tx` / `bench tx stop` | own build (`BENCH_RF_CMD`), repeater, local only | a train of zero-hop RAW_CUSTOM packets (4 B sequence + random), for RX-loss tests against another board's `recv`; plain `bench tx` shows progress |
| `clkreboot` | all | reset the clock to the build epoch and reboot -- the only way to move a clock backwards (`time` and `clock sync` refuse to) |
RX duty cycle: `max` saved ~2.3 mA on the bench, but a mast on the live mesh
@@ -350,6 +352,7 @@ The ones that change what a node does; set in `platformio.ini` /
| `PWRMGT_BOOTLOCK_DEFAULT`, `PWRMGT_CUTOFF_DEFAULT` | `PWRMGT_VOLTAGE_BOOTLOCK` (SenseCAP 3300), `0` (mV) | thresholds for a node without `/pwr_guard` |
| `NRF52_TICKLESS_MAX_MS` | `50` (ms) | nRF52 with `powersaving on`: the longest the main loop blocks between wake-ups (the DIO1 interrupt wakes it at once); `0` = the old `sd_app_evt_wait()` loop that wakes with every 1024 Hz tick. See [power.md](power.md) |
| `BENCH_BATT_OVERRIDE` | unset | bench only: `bench batt <mV|off|poll>` overrides the battery reading of the adaptive power saving (`pwr.rxgain` / `pwr.rxps`; not `pwr.cutoff`) |
| `BENCH_RF_CMD` | unset | bench only: `bench preamble` and `bench tx` on the repeater console (rxps RX-loss bench of 4. 12. 2026, #46) |
| `PWR_DUTY_INSTRUMENT` | unset | bench only, nRF52: every ~10 s a `PWRDUTY` line on the USB console with the time the MCU was awake and asleep, its wakes, and the CPU time spent on received packets. See [power.md](power.md#cpu-time-per-received-packet-pwr_duty_instrument) |
Prefs saved on the node override the build defaults: a reflash keeps what a
+68
View File
@@ -1568,6 +1568,11 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
set_radio_at = revert_radio_at = 0;
_logging = false;
region_load_active = false;
#ifdef BENCH_RF_CMD
bench_tx_left = bench_tx_seq = bench_tx_gap = bench_tx_jitter = 0;
bench_tx_next = 0;
bench_tx_len = 0;
#endif
recv_pkt_region = NULL;
#if MAX_NEIGHBOURS
@@ -2026,6 +2031,49 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
__builtin_trap(); // UDF -> UsageFault, escalates to HardFault
}
#endif
#ifdef BENCH_RF_CMD
// Bench only (-D BENCH_RF_CMD), local console only: RX-loss tests of rxps (#46).
// bench preamble <symbols>|0 transmit with this preamble (0 = the SF's default)
// bench tx <count> <len> <gap ms> [jitter ms] zero-hop RAW_CUSTOM train
// bench tx progress; bench tx stop
if (sender_timestamp == 0 && strncmp(command, "bench ", 6) == 0) {
const char* a = command + 6;
if (strncmp(a, "preamble ", 9) == 0) {
int n = atoi(a + 9);
if (n < 0 || n > 1024) { strcpy(reply, "Error: bench preamble <0-1024>"); return; }
int16_t st = radio_driver.benchSetPreamble((uint16_t) n);
sprintf(reply, "%s - bench preamble %d (radiolib %d)", st == 0 ? "OK" : "Err", n, (int) st);
return;
}
if (strcmp(a, "tx") == 0) {
sprintf(reply, "> bench tx left %lu, sent seq %lu, len %u, gap %lu+%lu ms",
(unsigned long) bench_tx_left, (unsigned long) bench_tx_seq, (unsigned) bench_tx_len,
(unsigned long) bench_tx_gap, (unsigned long) bench_tx_jitter);
return;
}
if (strcmp(a, "tx stop") == 0) {
bench_tx_left = 0;
strcpy(reply, "OK - bench tx stopped");
return;
}
if (strncmp(a, "tx ", 3) == 0) {
unsigned long cnt = 0, len = 0, gap = 0, jit = 0;
int got = sscanf(a + 3, "%lu %lu %lu %lu", &cnt, &len, &gap, &jit);
if (got < 3 || len < 8 || len > MAX_PACKET_PAYLOAD || gap < 100) {
strcpy(reply, "Error: bench tx <count> <len 8-184> <gap ms>=100> [jitter ms]");
return;
}
bench_tx_left = cnt;
bench_tx_seq = 0;
bench_tx_len = (uint8_t) len;
bench_tx_gap = gap;
bench_tx_jitter = got >= 4 ? jit : 0;
bench_tx_next = millis();
sprintf(reply, "OK - bench tx %lu x %lu B every %lu+%lu ms", cnt, len, gap, (unsigned long) bench_tx_jitter);
return;
}
}
#endif
const char* cmd = command;
cli_args::stripPrefix(cmd, reply, &reply_max);
@@ -2150,12 +2198,32 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
}
}
#ifdef BENCH_RF_CMD
void MyMesh::benchTxLoop() {
if (bench_tx_left == 0 || !millisHasNowPassed(bench_tx_next)) return;
uint8_t data[MAX_PACKET_PAYLOAD];
memcpy(data, &bench_tx_seq, 4); // receivers can count gaps from the sequence
getRNG()->random(&data[4], bench_tx_len - 4); // unique packet hash every time
mesh::Packet* pkt = createRawData(data, bench_tx_len);
if (pkt) {
sendZeroHop(pkt);
bench_tx_seq++;
bench_tx_left--;
}
uint32_t jit = bench_tx_jitter ? getRNG()->nextInt(0, bench_tx_jitter + 1) : 0;
bench_tx_next = futureMillis(bench_tx_gap + jit);
}
#endif
void MyMesh::loop() {
#ifdef WITH_BRIDGE
bridge.loop();
#endif
mesh::Mesh::loop();
#ifdef BENCH_RF_CMD
benchTxLoop();
#endif
// Fairness limiter refilling. The `else if` chain keeps the three timers from
// aligning on one loop pass; each adds ONE token per bucket per interval.
+7
View File
@@ -219,6 +219,13 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
uint32_t pending_discover_tag;
unsigned long pending_discover_until;
bool region_load_active;
#ifdef BENCH_RF_CMD
// `bench tx`: a train of zero-hop RAW_CUSTOM packets for RX-loss tests (rxps, #46)
uint32_t bench_tx_left, bench_tx_seq, bench_tx_gap, bench_tx_jitter;
unsigned long bench_tx_next;
uint8_t bench_tx_len;
void benchTxLoop();
#endif
unsigned long dirty_contacts_expiry;
#if MAX_NEIGHBOURS
NeighbourInfo neighbours[MAX_NEIGHBOURS];
+7
View File
@@ -143,6 +143,13 @@ public:
virtual uint8_t getSpreadingFactor() const { return LORA_SF; }
static uint16_t preambleLengthForSF(uint8_t sf) { return sf <= 8 ? 32 : 16; }
void updatePreamble(uint8_t sf) { _preamble_sf = sf; _radio->setPreambleLength(preambleLengthForSF(sf)); }
#ifdef BENCH_RF_CMD
// Bench only: transmit with another preamble than this SF's default (0 = back to the
// default), to stand in for senders on older firmware. A radio settings change resets it.
int16_t benchSetPreamble(uint16_t symbols) {
return _radio->setPreambleLength(symbols ? symbols : preambleLengthForSF(_preamble_sf));
}
#endif
PacketMillis calcMaxPacketMillis(uint8_t sf, float bw, uint8_t cr, uint8_t preambleSymbols);
virtual int16_t performChannelScan();