2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "sigrok-internal.h"
28 unsigned int num_enabled_probes;
32 static int init(struct sr_output *o)
35 struct sr_probe *probe;
47 if (!(ctx = g_try_malloc0(sizeof(struct context))))
52 /* Get the number of probes and their names. */
53 ctx->probelist = g_ptr_array_new();
54 for (l = o->dev->probes; l; l = l->next) {
56 if (!probe || !probe->enabled)
58 g_ptr_array_add(ctx->probelist, probe->name);
59 ctx->num_enabled_probes++;
65 static int event(struct sr_output *o, int event_type, uint8_t **data_out,
73 if (!(ctx = o->internal))
80 case SR_DF_FRAME_BEGIN:
81 *data_out = (uint8_t *)g_strdup("FRAME-BEGIN\n");
85 *data_out = (uint8_t *)g_strdup("FRAME-END\n");
91 g_ptr_array_free(ctx->probelist, TRUE);
96 /* Ignore everything else. */
105 static int data(struct sr_output *o, const uint8_t *data_in,
106 uint64_t length_in, uint8_t **data_out, uint64_t *length_out)
117 if (!(ctx = o->internal))
120 if (!data_in || !data_out)
123 outstr = g_string_sized_new(512);
125 fdata = (float *)data_in;
126 max = length_in / sizeof(float);
127 for (i = 0; i < max;) {
128 for (j = 0; j < ctx->num_enabled_probes; j++) {
129 g_string_append_printf(outstr, "%s: %f\n",
130 (char *)g_ptr_array_index(ctx->probelist, j),
135 *data_out = (uint8_t *)outstr->str;
136 *length_out = outstr->len;
137 g_string_free(outstr, FALSE);
142 SR_PRIV struct sr_output_format output_float = {
144 .description = "Floating point",
145 .df_type = SR_DF_ANALOG,