]> sigrok.org Git - libsigrok.git/blobdiff - src/session.c
session: Add helper sr_session_send_meta() to send SR_DF_META packages.
[libsigrok.git] / src / session.c
index b3fdfb54a2451b0ac506b0f82b452fda30ad6807..bfc0a35a9782aeb4a399f49d07234a1e4e73e2fc 100644 (file)
@@ -1071,6 +1071,44 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet)
        }
 }
 
+/**
+ * Helper to send a meta datafeed package (SR_DF_META) to the session bus.
+ *
+ * @param sdi The device instance to send the package from. Must not be NULL.
+ * @param key The config key to send to the session bus.
+ * @param var The value to send to the session bus.
+ *
+ * @retval SR_OK Success.
+ * @retval SR_ERR_ARG Invalid argument.
+ *
+ * @private
+ */
+SR_PRIV int sr_session_send_meta(const struct sr_dev_inst *sdi,
+               uint32_t key, GVariant *var)
+{
+       struct sr_config *cfg;
+       struct sr_datafeed_packet packet;
+       struct sr_datafeed_meta meta;
+       int ret;
+
+       cfg = sr_config_new(key, var);
+       if (!cfg)
+               return SR_ERR;
+
+       memset(&meta, 0, sizeof(meta));
+
+       packet.type = SR_DF_META;
+       packet.payload = &meta;
+
+       meta.config = g_slist_append(NULL, cfg);
+
+       ret = sr_session_send(sdi, &packet);
+       g_slist_free(meta.config);
+       sr_config_free(cfg);
+
+       return ret;
+}
+
 /**
  * Send a packet to whatever is listening on the datafeed bus.
  *