fix(radio): lua telemetry handling - #7773
Open
3djc wants to merge 2 commits into
Open
Conversation
(cherry picked from commit c6df336ca7ecf4bd9ff2928f02e4e53577e6e301)
Collaborator
|
Are the same fixes needed for ghostTelemetryPush? |
Collaborator
Author
Technicaly no, because Ghost caps payload at 10 bytes, so bellow LUA_MINSTACK (set at 20) But yes, it would look nicer and more consistent to have it there too, incoming |
Mirror the crossfireTelemetryPush fixes
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.
Reports of radios rebooting into EMERGENCY MODE while using the Rotorflight Lua scripts, and attemps to address it, at least partially.
Telemetry RX runs in the FreeRTOS timer task (prio 2, via xTimerPendFunctionCallFromISR); Lua runs in the menus task (prio 1). So RX preempts Lua at any instruction, and:
Colorlcd only. It fires on script/widget open and close with telemetry streaming.
Fixed with a mutex over the list, held across the whole push loop, and unregister+free collapsed into a single destroyTelemetryQueue() under that lock.
lua_gettop(L) > TELEMETRY_OUTPUT_BUFFER_SIZE compares the argument count (always 2), not the payload length, leaving the payload unbounded. pushByte() drops silently past 64 bytes, but the frame's length byte and crc8(data + 2, ...) still use the full length and read past the buffer. Now checks the real frame size, keeping the length as lua_Integer until validated so a >255 table can't wrap through uint8_t.
The payload loop also lua_rawgeti'd each element without popping it, growing the Lua stack one slot per byte — past LUA_MINSTACK that writes beyond the reserved C-call slots. Added the missing lua_pop().
Untested (as in I wasn't able to reproduce the EM without that fix, so could not confirm this fixes it)