Skip to content

Background telemetry decoder

Rotorflight sends its own telemetry values in a custom frame that EdgeTX does not decode by itself, so something on the radio has to unpack it and hand the values to the sensors. The dashboard does that on its own, in the widget, and it works — but a widget call is stopped at a fixed instruction count, so when frames arrive faster than the widget can decode them the older part of the backlog is dropped. One value is kept even then: for three seconds after an in-flight tuning step, the flight controller's answer to that step is looked for in the dropped frames, so the new value and its announcement do not wait for the flight controller to send it again. In rare cases it still does. An adjustment made with a switch of the pilot's own, without in-flight tuning, is not looked for.

The suite can move that work into a small script the radio runs outside the widgets: SCRIPTS/FUNCTIONS/rfsbg.lua. A call there is paused and continued on the next turn instead of being cut off, so it decodes every frame it takes. The same script also makes the adjustment announcements, at the level set under Settings → Audio → Volume, while Adjustment events is on (System → Settings → Audio → Events). It takes them from the frames it decodes, and with the setting off it does not load the part that speaks them at all; switched on in the tool, it picks the change up with its next reading of the settings.

Where to find it

Model → Special Functions, as an entry named rfsbg on the always-on switch.

The suite adds that entry itself, once, the first time a model connects to a flight controller. It takes effect the next time the model is loaded, because the radio reads a model's special functions when it loads it. Nothing is asked of you and there is nothing to confirm.

Turning it off

Untick the entry on the Special Functions page. The suite leaves an entry it can see alone, ticked or not, so it stays off.

Deleting the entry instead frees the script slot, and the suite adds it again on the next connect — deleting is not how to switch it off.

Without the script, the dashboard decodes for itself exactly as it did before. Nothing is lost and nothing needs to be configured. While the dashboard's connect sequence is still reading the flight controller's configuration -- and before it, while the suite waits for the armed state before sending anything -- it decodes only the armed state (the arming flags, or the System Status word), so it can see an armed model and send it nothing; the other values follow once the sequence is through. That is also what happens on the first connect of a model, before the radio has loaded the entry the suite has just added.

Notes

  • The radio has only a handful of script slots — seven or nine, shared by every mixer and special-function script on it. This takes one of them.
  • A model that already runs another background decoder does not get this one. Rotorflight's earlier Lua scripts install rf2bg, which reads the same frames. Every special-function script on a radio shares one telemetry queue, so whichever runs first takes the frames and a second decoder receives nothing at all. Where the suite sees such an entry on the model it installs nothing and writes the reason to the log; the dashboard then decodes for itself.
  • Opening a tool pauses it, together with every other permanent script, for as long as the tool is open. Whoever is running then decodes for itself: the dashboard notices within a second and takes the decoding back, and the tool decodes from its own first pass -- including while it is still reading the flight controller's configuration, which is when it has to be able to see the model arm.
  • A setting changed in the tool reaches it within about 30 seconds of the tool being closed (the tool pauses it, above), for example switching the adjustment announcements on or off. Every 30 seconds it looks at the settings file and at the reload.req beside it, and reads the settings again only when one of them has moved since its last read, so a radio whose settings stay as they are does not pay for the read.
  • An error inside it does not stop it. The radio ends a script whose error reaches it, shows the Lua error and does not run it again until the scripts are reloaded. So the decoding, the adjustment announcements and the rest of its work each catch their own error and are tried again on the next cycle, and a start that failed, or a decoder that did not load, is tried again at most once a second. While the decoding fails, the dashboard takes it over within a second, as it does when the script is not there. With the log level at WARN or above the log carries one line when a part starts failing, and from INFO up one more when it works again -- except for a start that failed before the log was open, which leaves no line.
  • It cannot be seen from the suite if it is configured as a global function rather than on the model. The radio offers no way for a script to read the global special functions, so a background decoder installed there is invisible to the check above.
  • It watches the dashboard widget and records the moment it stops. A widget that uses more than its share of a cycle is not called again by the radio, so it cannot write down that this happened to it; this script runs outside the widgets and can. With the log level at DEBUG or above its log then carries a line naming how long the dashboard has been silent and what its last drawn cycle cost. A dashboard on another screen page or behind one of the radio's menu pages is still called by the radio and still does its work, so it is not reported. A model without this script has nothing that can report that.
  • While it runs, the dashboard reads the radio's sensors. Without it, the dashboard decodes for itself and reads its values straight from its own decoder, as the flight controller sends them; see sensor selection. A correction made on the radio's sensor page therefore reaches a value the dashboard reads from its decoder only while this script runs.
  • Its decoding can be followed in the log. From DEBUG up, the decoder's lines (tag rfsuite.decoder) start with bg when this script decodes and with dash or tool when the dashboard or the tool does, so a log shows when the dashboard stood aside for it and when it took over; at TRACE each decoded frame is listed with the values that changed. Its state line, like the dashboard's and the tool's, says whether that part decoded since its last one and with how many frames and gaps, or that it stood aside for another part (decoder elsewhere). See collecting logs.
  • It writes a log of its own when Log Session To Card is on and the log level is DEBUG or above, the function files of each power-up, beside the tool's and the dashboard's. Unlike theirs, it needs both switches to start: Log Session To Card alone writes no function file. Once it has started, lowering the level again does not stop it for the rest of that session, although its step file is then no longer rewritten. Because this script is paused and resumed rather than cut off, it keeps writing where a widget that overran its instruction budget cannot, and its one-line step file says when it last ran. See collecting logs.