value = g_hash_table_lookup(hash, key);
hwopt->value = g_strdup(value);
opts = g_slist_append(opts, hwopt);
- break;
}
g_list_free(keys);
static void print_dev_line(const struct sr_dev_inst *sdi)
{
+ struct sr_probe *probe;
+ GSList *l;
if (sdi->vendor && sdi->vendor[0])
printf("%s ", sdi->vendor);
printf("%s ", sdi->model);
if (sdi->version && sdi->version[0])
printf("%s ", sdi->version);
- if (sdi->probes)
- printf("with %d probes", g_slist_length(sdi->probes));
+ if (sdi->probes) {
+ if (g_slist_length(sdi->probes) == 1) {
+ probe = sdi->probes->data;
+ printf("with 1 probe: %s", probe->name);
+ } else {
+ printf("with %d probes:", g_slist_length(sdi->probes));
+ for (l = sdi->probes; l; l = l->next) {
+ probe = l->data;
+ printf(" %s", probe->name);
+ }
+ }
+ }
printf("\n");
}
int num_enabled_probes, sample_size, ret, i;
uint64_t output_len, filter_out_len;
uint8_t *output_buf, *filter_out;
+ GString *out;
/* If the first packet to come in isn't a header, don't even try. */
if (packet->type != SR_DF_HEADER && o == NULL)
received_samples);
if (outfile && outfile != stdout)
fclose(outfile);
+
+ if (o->format->cleanup)
+ o->format->cleanup(o);
g_free(o);
o = NULL;
break;
g_message("received unknown packet type %d", packet->type);
}
+ if (o && o->format->recv) {
+ out = o->format->recv(o, sdi, packet);
+ if (out && out->len) {
+ fwrite(out->str, 1, out->len, outfile);
+ fflush(outfile);
+ }
+ }
+
}
/* Register the given PDs for this session.
static int select_probes(struct sr_dev_inst *sdi)
{
- char **probelist;
- int max_probes, i;
+ struct sr_probe *probe;
+ GSList *selected_probes, *l;
if (!opt_probes)
return SR_OK;
- /*
- * This only works because a device by default initializes
- * and enables all its probes.
- */
- max_probes = g_slist_length(sdi->probes);
- probelist = parse_probestring(max_probes, opt_probes);
- if (!probelist) {
+ if (!(selected_probes = parse_probestring(sdi, opt_probes)))
return SR_ERR;
- }
- for (i = 0; i < max_probes; i++) {
- if (probelist[i]) {
- sr_dev_probe_name_set(sdi, i, probelist[i]);
- g_free(probelist[i]);
- } else {
- sr_dev_probe_enable(sdi, i, FALSE);
- }
+ for (l = sdi->probes; l; l = l->next) {
+ probe = l->data;
+ if (g_slist_find(selected_probes, probe))
+ probe->enabled = TRUE;
+ else
+ probe->enabled = FALSE;
}
- g_free(probelist);
+ g_slist_free(selected_probes);
return SR_OK;
}