| 104 | } |
| 105 | |
| 106 | static GString *gen_header(const struct sr_output *o) |
| 107 | { |
| 108 | struct context *ctx; |
| 109 | struct sr_channel *ch; |
| 110 | GVariant *gvar; |
| 111 | GString *header; |
| 112 | time_t t; |
| 113 | unsigned int num_channels, i; |
| 114 | char *samplerate_s; |
| 115 | |
| 116 | ctx = o->priv; |
| 117 | if (ctx->samplerate == 0) { |
| 118 | if (sr_config_get(o->sdi->driver, o->sdi, NULL, NULL, SR_CONF_SAMPLERATE, |
| 119 | &gvar) == SR_OK) { |
| 120 | if (gvar != NULL) { |
| 121 | ctx->samplerate = g_variant_get_uint64(gvar); |
| 122 | g_variant_unref(gvar); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | t = time(NULL); |
| 128 | header = g_string_sized_new(512); |
| 129 | g_string_printf(header, "%s", gnuplot_header); |
| 130 | g_string_append_printf(header, "# Generated by %s on %s", |
| 131 | PACKAGE_STRING, ctime(&t)); |
| 132 | |
| 133 | num_channels = g_slist_length(o->sdi->channels); |
| 134 | g_string_append_printf(header, "# Acquisition with %d/%d channels", |
| 135 | ctx->num_enabled_channels, num_channels); |
| 136 | if (ctx->samplerate != 0) { |
| 137 | samplerate_s = sr_samplerate_string(ctx->samplerate); |
| 138 | g_string_append_printf(header, " at %s", samplerate_s); |
| 139 | g_free(samplerate_s); |
| 140 | } |
| 141 | g_string_append_printf(header, "\n"); |
| 142 | |
| 143 | g_string_append_printf(header, "%s", gnuplot_header2); |
| 144 | |
| 145 | /* Columns / channels */ |
| 146 | for (i = 0; i < ctx->num_enabled_channels; i++) { |
| 147 | ch = g_slist_nth_data(o->sdi->channels, ctx->channel_index[i]); |
| 148 | g_string_append_printf(header, "# %d\t\t%s\n", i + 1, ch->name); |
| 149 | } |
| 150 | |
| 151 | return header; |
| 152 | } |
| 153 | |
| 154 | static int receive(const struct sr_output *o, const struct sr_datafeed_packet *packet, |
| 155 | GString **out) |
no test coverage detected