Enhance KissModem frame processing and timeout handling#2490
Open
tuzzmaniandevil wants to merge 1 commit intomeshcore-dev:devfrom
Open
Enhance KissModem frame processing and timeout handling#2490tuzzmaniandevil wants to merge 1 commit intomeshcore-dev:devfrom
tuzzmaniandevil wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes several bugs in the KISS modem TX state machine that could cause the modem to permanently stop sending packets over serial.
Problem
The KISS modem TX state machine had multiple paths that could lock up permanently, requiring a device reboot:
TX_SENDINGstuck forever — IfisSendComplete()never returns true (missed radio interrupt, SPI glitch), the state machine stays inTX_SENDINGindefinitely. No more packets can be sent or queued.startSendRaw()return value ignored — If the radio fails to start transmitting, the modem entersTX_SENDINGwaiting for a completion that never started.TX_WAIT_CLEARstuck forever — If the radio gets stuck detecting a phantom carrier,isReceiving()returns true indefinitely and the state machine never progresses.Changes
TX_SENDINGusinggetEstAirtimeFor() * 1.5, matching the approach used by the Dispatcher in companion/repeater firmware. Adapts automatically to radio configuration instead of using a fixed 10s constant.startSendRaw()error handling — Check return value; on failure, drop the packet and return toTX_IDLEinstead of entering a dead state.TX_WAIT_CLEARtimeout — If the channel stays busy longer than the worst-case max packet airtime × 1.5, force-proceed toTX_DELAY.TX_SLOT_WAITtimer reset — Reset_tx_timerwhen cycling back toTX_WAIT_CLEARso the channel-busy timeout measures time in that state, not cumulative time since the TX was queued.HW_RESP_TX_DONE(result=0x00) so the host knows the packet was rejected.HW_RESP_TX_DONE(result=0x00) instead of silently dropping.Testing
These are all state machine edge cases triggered by radio hardware faults (missed interrupts, stuck carrier detect). Verified by code review against the Dispatcher's equivalent timeout handling in
src/Dispatcher.cpp.