Repository navigation
Fix immediate command polling when the device sends timeout 0 - #33
Merged
Merged
Conversation
The next CMD_QUERY is armed with now + (command.timeout or 100). 0 is truthy in Lua, so a device that sends timeout 0 is polled on every tick. The answer to CLICK re-arms the poll at now + 0, overriding the response timeout execCommand set, and the POLL can reach the device before its CONFIRMATION_NEEDED is back. The device answers READY and the confirm dialog never shows (#16). Treat 0 like a missing timeout and poll once per second. Co-authored-by: Itay Sharoni <[email protected]>
|
This also looks good now (well, the finishing text isn't shown, but that is fixed in #36). |
CapnBry
approved these changes
Oct 1, 2026
CapnBry
left a comment
Member
There was a problem hiding this comment.
Great!
I will say that pushing a single-use constant into the module's locals means that the function then needs an upval object and pointer to access it which is like 30 bytes of RAM in addition to the value itself. It's good programming style to have named "constants" for things but in limited environments, not necessarily worth the cost of keeping it all in RAM all the time.
Not requesting a change but in general this should be avoided.
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 #16. Supersedes #20 (rebased on the current
unified-lua-lsp; diagnosis by @Itay-Sharoni).The next CMD_QUERY is armed with
now + (command.timeout or 100). In Lua 0 is truthy, so a device that sendstimeout = 0is polled on every tick.execCommandnow waits_responseTimeout()before the first poll, but the answer to CLICK re-arms the poll in_onEntryatnow + 0, so the POLL can still reach the device before its CONFIRMATION_NEEDED is back. The device answers READY and the confirm dialog never shows.Treat 0 like a missing timeout and poll once per second. Devices sending a real timeout (ELRS sends 200) are unaffected.
Checked in the simulator (GX12) with the CRSFSimulator Bind command set to
timeout = 0:No device with timeout 0 here — @wimalopaan, can you verify on yours?