-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Telemetry FIFO #3229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telemetry FIFO #3229
Conversation
If the message has the same source/destination
Seems to cause TBS Agent Lite to have literal 'mare
mha1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Telemetry and the LUA script works fine showing "other devices" and loading the RX settings even under heavy telemetry load with some expected limitations:
All Full-res packet rates in all available Switch Modes and all telemetry ratios,
all packet rates in Hybrid Mode and all telemetry ratios,
all packet rates in Wide Mode and telemetry ratios 1:2, 1:4:
- RX settings loading times are comparable to pre-3.5.5 firmware versions
All packet rates in Wide Mode and telemetry ratios 1:8 or slower:
- RX settings loading times are as expected about factor 3 (50Hz about factor 4) slower than compared to pre-3.5.5 firmware version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working flipping great, amazing refactor with support for a longer queue to support bursts. Most of these are minor things, but we do need to address the webui not loading for me on 8285 RXes (2 resources load and then the web server never responds to rest) but we can maybe tackle that in a separate PR. Here's what I see, and I can push most of these changes.
- Bug introduced in lua.cpp pushResponseChunk(), should be
else nextStatusChunk++; - dummy[CRSF_MAX_PACKET_LEN] -> replace messagePayloads.popBytes(dummy, sz); with skip()
- Remove crsf_telemetry_package_t and member
- Remove receivedPackages
- Remove twoslotLastQueueIndex
- Remove currentPayloadIndex
- Comment for ACTION_NEXT suggest "continue searching queue for other messages"
- settingsCount should be member, and probably named prioritizedCount?
- bit(7) should be a define and use e.g. IS_DEL(sz) SET_DEL(sz) SIZE(sz) etc
- FIFO<TELEMETRY_FIFO_SIZE> everywhere, typedef it
- Should comparator_t definition have const as well?
- messagePayloads[] data is accessed without lock
- uint16_t messagePosition = 0 -> rename overwritePosition
- if (whatToDo == ACTION_IGNORE || whatToDo == ACTION_APPEND || whatToDo == ACTION_OVERWRITE) is clearer if it is if (whatToDo != ACTION_NEXT)
- Add comparitor for CRSF_FRAMETYPE_PARAMETER_SETTINGS_ENTRY to check for duplicates (OVERWRITE)
- Should AppendTelemetryPackage also check currentPayload? Considering duplicates of PARAMINFO being requested while that value is currently being transmitted. Would require changing signature to use some sort of accessor helper class
- MicroOptimization: If the first item in the queue is prio, use pop instead of marking deleted. This only triggers at high packet rates so probably doesn't matter?
- Test for two different deviceinfo
- Test function that doesn't require popping and requeing everything
int Telemetry::UpdatedPayloadCount()
{
int retVal = 0;
unsigned pos = 0;
while (pos < messagePayloads.size())
{
uint8_t sz = messagePayloads[pos];
if (!(sz & bit(7)))
{
retVal++;
}
pos += (sz & 0x7F) + 1;
}
return retVal;
}- Add uint8_t payload[0] to crsf_header_t and use payload[0] instead of ((uint8_t*)newMessage)[CRSF_TELEMETRY_TYPE_INDEX + 1]
- Move CRSF_FRAMETYPE_OPENTX_SYNC to be in a new enum, subtype?
- CRSF_FRAMETYPE_RADIO_ID rename to CRSF_FRAMETYPE_HANDSET? (spec lists as Remote Related Frames)
- CRSF_FRAMETYPE_OPENTX_SYNC go to subcommand rename to CRSF_HANDSET_SUBCMD_TIMING
- Can we reuse deleted slots to reduce buffer use? Push can also defragment as it goes, merging an adjacent deleted block into one larger deleted block
- CRSF_AP_CUSTOM_TELEM_STATUS_TEXT is actually a log so both our old and new mechanism isn't great for servicing this message, but that's outside the scope of this PR
Since all the accesses are from the devices framework we don't need to disable the interrupts
This PR is a reimplementation of the slot-based telemetry system using a prioritised FIFO.
It builds on the work done in #3222.
There are a few inherent issues in the slot-based telemetry system.
Issue 1: Only 2 slots for non-sensor based messages
By using a FIFO for the messages we are no longer limited to 2 slots, we can have as many messages in the FIFO as will fit. The current allocation is 2kbytes. Also, the telemetry system can overwrite undelivered entries in the queue for sensor-data messages. i.e. all of the "broadcast" type simple messages.
This should resolve #3196
Issue 2: Prioritise "parameter" messages
The implementation prioritises delivery of the 5 message types used for CRSF configuration:
CRSF_FRAMETYPE_DEVICE_PINGCRSF_FRAMETYPE_DEVICE_INFOCRSF_FRAMETYPE_PARAMETER_SETTINGS_ENTRYCRSF_FRAMETYPE_PARAMETER_READCRSF_FRAMETYPE_PARAMETER_WRITEThis ensures that the Lua scripts load in a timely manner, even at 1:8 telemetry ratio. This also has the benefit of being able to remove the special behaviour added in #3222 which paused (dropped) telemetry message for 10 seconds when seeing a
DEVICE_INFOmessage.resolves #3218