From ff7233cb9284670fc13105847e251e8bf9ae0724 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 10 Oct 2026 15:53:00 +0000 Subject: [PATCH] LoRa: ask for the frame bound before reading back the CR it timed test_preambleHold_isSizedForTheWorstCaseFrame read phy.lastCodingRate straight after the first preamble sighting, where nothing has yet asked the chip to time anything: preambleHoldActive() short-circuits on the unset stamp, so the sighting that starts a hold never reaches calculateTimeOnAir() and the fake still reports a coding rate of 0. Ask maxRxFrameMsec() for the bound first, then assert the CR and CRC it was asked for. The case pins the same thing it always meant to - that the hold is timed at CR 4/8 with CRC rather than at our own CR. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01CStem6K6MQRBNR8YCFgtCE --- test/test_radio/test_main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_radio/test_main.cpp b/test/test_radio/test_main.cpp index a82f0937b5..d57073d1ba 100644 --- a/test/test_radio/test_main.cpp +++ b/test/test_radio/test_main.cpp @@ -789,9 +789,11 @@ static void test_preambleHold_isSizedForTheWorstCaseFrame() Time::setTestMillis(1000); TEST_ASSERT_TRUE(radioIf->receiveDetectedPublic(TestableRadioLibInterface::kFakePreambleDetected)); + // The first sighting short-circuits on the unset stamp, so the bound has to be asked for before the chip has been + // asked anything at all. + TEST_ASSERT_EQUAL_UINT32_MESSAGE(159, radioIf->maxRxFrameMsecPublic(), "part milliseconds round up"); TEST_ASSERT_EQUAL_UINT8_MESSAGE(8, phy.lastCodingRate, "the hold must be timed at the worst case CR, not ours"); TEST_ASSERT_TRUE_MESSAGE(phy.lastCrcEnabled, "a received frame may carry a CRC, which lengthens it"); - TEST_ASSERT_EQUAL_UINT32_MESSAGE(159, radioIf->maxRxFrameMsecPublic(), "part milliseconds round up"); Time::setTestMillis(1100); // the old sizing released here, with the frame still arriving TEST_ASSERT_TRUE(radioIf->preambleHoldActivePublic());