docs/reference/gds-plugins/data-handler.md
Data Handler Plugins allow users to register custom consumers for decoded F Prime data types, such as telemetry, events, or channels. These plugins are useful for logging, transforming, forwarding, or visualizing data as it flows through the system.
Each handler is dynamically registered to specific data descriptors (e.g., telemetry, events) and all custom data handlers run in a single custom data handler process. This allows these plugins to process decoded data without interfering with the core GDS runtime.
An example OpenMCTPush plugin shows how to use a DataHandler to push data to another service (in this case via ZeroMQ).
Data Handler plugins are FEATURE plugins. All will run unless individually disabled by the user.
To use a Data Handler plugin, implement the data_callback() method, which is invoked whenever a matching decoded data item is received. You can register for specific descriptor types by returning them in the get_handled_descriptors() method.
Typical use cases include:
CustomDataHandler process.data object passed to data_callback() is specific to the descriptor type.To create a Data Handler plugin, subclass the DataHandlerPlugin base class and implement the following:
get_handled_descriptors() -> list[str]:| Descriptor String | Data |
|---|---|
| "FW_PACKET_TELEM" | F Prime channels |
| "FW_PACKET_LOG" | F Prime events |
| "FW_PACKET_FILE" | F Prime file packets |
| "FW_PACKET_PACKETIZED_TLM" | F Prime packets |
data_callback(data, source):data type depends on the descriptor. The source argument is unused GDS plugins.from fprime_gds.common.handlers import DataHandlerPlugin
from fprime_gds.plugin.definitions import gds_plugin
@gds_plugin(DataHandlerPlugin)
class EventLogger(DataHandlerPlugin):
"""Logs all event data to a file."""
def get_handled_descriptors(self):
return ["FW_PACKET_LOG"]
def data_callback(self, data, source):
value_object = data.get_val_obj()
with open("event_log.txt", "a") as f:
f.write(f"{value_object.val}\n")
This plugin will be called for every decoded event received by the system.
[!NOTE] The decoded data passed to data_callback() is an instance of the decoded object — for example, a ChannelTelemetry, Event, or CustomType depending on the descriptor.
The data handler plugin also supports some helper functionality.
self.publisher.publish_channel(name: str, value: Any, time: TimeType)
This call allows users to publish telemetry values by name. It is used in ground-processed channels.