GVariant *gvar;
uint64_t time_msec;
uint64_t samplerate;
+ struct sr_dev_driver *driver;
+
+ driver = sr_dev_inst_driver_get(sdi);
if (!(time_msec = sr_parse_timestring(opt_time))) {
g_critical("Invalid time '%s'", opt_time);
}
} else if (sr_dev_has_option(sdi, SR_CONF_SAMPLERATE)) {
/* Convert to samples based on the samplerate. */
- sr_config_get(sdi->driver, sdi, NULL, SR_CONF_SAMPLERATE, &gvar);
+ sr_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE, &gvar);
samplerate = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
limit_samples = (samplerate) * time_msec / (uint64_t)1000;
static uint64_t samplerate = 0;
static int triggered = 0;
static FILE *outfile = NULL;
- GSList *l;
+ GSList *l, *channels_sdi;
GString *out;
GVariant *gvar;
uint64_t end_sample;
uint64_t input_len;
int i;
char **channels;
+ struct sr_dev_driver *driver;
+
+ driver = sr_dev_inst_driver_get(sdi);
+ channels_sdi = sr_dev_inst_channels_get(sdi);
/* If the first packet to come in isn't a header, don't even try. */
if (packet->type != SR_DF_HEADER && o == NULL)
}
rcvd_samples_logic = rcvd_samples_analog = 0;
- if (sr_config_get(sdi->driver, sdi, NULL, SR_CONF_SAMPLERATE,
+ if (sr_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE,
&gvar) == SR_OK) {
samplerate = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
/* Saving to a session file. */
if (rcvd_samples_logic == 0) {
/* First packet with logic data, init session file. */
- channels = g_malloc(sizeof(char *) * g_slist_length(sdi->channels));
- for (i = 0, l = sdi->channels; l; l = l->next) {
+ channels = g_malloc(sizeof(char *) * g_slist_length(channels_sdi));
+ for (i = 0, l = channels_sdi; l; l = l->next) {
ch = l->data;
if (ch->type == SR_CHANNEL_LOGIC)
channels[i++] = ch->name;
gsize n_elements, i;
const uint32_t *dev_opts;
int is_demo_dev;
+ struct sr_dev_driver *driver;
devices = device_scan();
if (!devices) {
for (sd = devices; sd; sd = sd->next) {
sdi = sd->data;
- if (sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS, &gvar) != SR_OK) {
+ driver = sr_dev_inst_driver_get(sdi);
+
+ if (sr_config_list(driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS, &gvar) != SR_OK) {
g_critical("Failed to query sr_config_list(SR_CONF_DEVICE_OPTIONS).");
return;
}
sr_session_destroy(session);
return;
}
- if (sr_config_list(sdi->driver, sdi, NULL,
+ if (sr_config_list(driver, sdi, NULL,
SR_CONF_LIMIT_SAMPLES, &gvar) == SR_OK) {
/* The device has no compression, or compression is turned
* off, and publishes its sample memory size. */
static void print_dev_line(const struct sr_dev_inst *sdi)
{
struct sr_channel *ch;
- GSList *sl, *l;
+ GSList *sl, *l, *channels;
GString *s;
GVariant *gvar;
+ struct sr_dev_driver *driver;
+ const char *vendor, *model, *version;
+
+ driver = sr_dev_inst_driver_get(sdi);
+ vendor = sr_dev_inst_vendor_get(sdi);
+ model = sr_dev_inst_model_get(sdi);
+ version = sr_dev_inst_version_get(sdi);
+ channels = sr_dev_inst_channels_get(sdi);
s = g_string_sized_new(128);
- g_string_assign(s, sdi->driver->name);
- if (sr_config_get(sdi->driver, sdi, NULL, SR_CONF_CONN, &gvar) == SR_OK) {
+ g_string_assign(s, driver->name);
+ if (sr_config_get(driver, sdi, NULL, SR_CONF_CONN, &gvar) == SR_OK) {
g_string_append(s, ":conn=");
g_string_append(s, g_variant_get_string(gvar, NULL));
g_variant_unref(gvar);
}
g_string_append(s, " - ");
- if (sdi->vendor && sdi->vendor[0])
- g_string_append_printf(s, "%s ", sdi->vendor);
- if (sdi->model && sdi->model[0])
- g_string_append_printf(s, "%s ", sdi->model);
- if (sdi->version && sdi->version[0])
- g_string_append_printf(s, "%s ", sdi->version);
- if (sdi->channels) {
- if (g_slist_length(sdi->channels) == 1) {
- ch = sdi->channels->data;
+ if (vendor && vendor[0])
+ g_string_append_printf(s, "%s ", vendor);
+ if (model && model[0])
+ g_string_append_printf(s, "%s ", model);
+ if (version && version[0])
+ g_string_append_printf(s, "%s ", version);
+ if (channels) {
+ if (g_slist_length(channels) == 1) {
+ ch = channels->data;
g_string_append_printf(s, "with 1 channel: %s", ch->name);
} else {
- sl = g_slist_sort(g_slist_copy(sdi->channels), sort_channels);
+ sl = g_slist_sort(g_slist_copy(channels), sort_channels);
g_string_append_printf(s, "with %d channels:", g_slist_length(sl));
for (l = sl; l; l = l->next) {
ch = l->data;
void show_dev_detail(void)
{
- struct sr_dev_driver *driver;
+ struct sr_dev_driver *driver_from_opt, *driver;
struct sr_dev_inst *sdi;
const struct sr_config_info *srci;
struct sr_channel *ch;
struct sr_channel_group *channel_group, *cg;
- GSList *devices, *cgl, *chl;
+ GSList *devices, *cgl, *chl, *channel_groups;
GVariant *gvar_opts, *gvar_dict, *gvar_list, *gvar;
gsize num_opts, num_elements;
double dlow, dhigh, dcur_low, dcur_high;
char *tmp_str, *s, c;
const char **stropts;
- if (parse_driver(opt_drv, &driver, NULL)) {
+ if (parse_driver(opt_drv, &driver_from_opt, NULL)) {
/* A driver was specified, report driver-wide options now. */
- show_drv_detail(driver);
+ show_drv_detail(driver_from_opt);
}
if (!(devices = device_scan())) {
g_slist_free(devices);
print_dev_line(sdi);
+ driver = sr_dev_inst_driver_get(sdi);
+ channel_groups = sr_dev_inst_channel_groups_get(sdi);
+
if (sr_dev_open(sdi) != SR_OK) {
g_critical("Failed to open device.");
return;
select_channels(sdi);
channel_group = select_channel_group(sdi);
- if ((sr_config_list(sdi->driver, sdi, channel_group, SR_CONF_DEVICE_OPTIONS,
+ if ((sr_config_list(driver, sdi, channel_group, SR_CONF_DEVICE_OPTIONS,
&gvar_opts)) != SR_OK)
/* Driver supports no device instance options. */
return;
- if (sdi->channel_groups) {
+ if (channel_groups) {
printf("Channel groups:\n");
- for (cgl = sdi->channel_groups; cgl; cgl = cgl->next) {
+ for (cgl = channel_groups; cgl; cgl = cgl->next) {
cg = cgl->data;
printf(" %s: channel%s", cg->name,
g_slist_length(cg->channels) > 1 ? "s" : "");
}
printf("Supported configuration options");
- if (sdi->channel_groups) {
+ if (channel_groups) {
if (!channel_group)
printf(" across all channel groups");
else
continue;
if (key == SR_CONF_TRIGGER_MATCH) {
- if (sr_config_list(sdi->driver, sdi, channel_group, key,
+ if (sr_config_list(driver, sdi, channel_group, key,
&gvar_list) != SR_OK) {
printf("\n");
continue;
* only to those that don't support compression, or
* have it turned off by default. The values returned
* are the low/high limits. */
- if (sr_config_list(sdi->driver, sdi, channel_group, key,
+ if (sr_config_list(driver, sdi, channel_group, key,
&gvar) != SR_OK) {
continue;
}
} else if (key == SR_CONF_SAMPLERATE) {
/* Supported samplerates */
printf(" %s", srci->id);
- if (sr_config_list(sdi->driver, sdi, channel_group, SR_CONF_SAMPLERATE,
+ if (sr_config_list(driver, sdi, channel_group, SR_CONF_SAMPLERATE,
&gvar_dict) != SR_OK) {
printf("\n");
continue;
} else if (srci->datatype == SR_T_UINT64) {
printf(" %s", srci->id);
gvar = NULL;
- if (sr_config_get(sdi->driver, sdi, channel_group, key,
+ if (sr_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
tmp_uint64 = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
} else
tmp_uint64 = 0;
- if (sr_config_list(sdi->driver, sdi, channel_group,
+ if (sr_config_list(driver, sdi, channel_group,
SR_CONF_BUFFERSIZE, &gvar_list) != SR_OK) {
if (gvar) {
/* Can't list it, but we have a value to show. */
} else if (srci->datatype == SR_T_STRING) {
printf(" %s: ", srci->id);
- if (sr_config_get(sdi->driver, sdi, channel_group, key,
+ if (sr_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
tmp_str = g_strdup(g_variant_get_string(gvar, NULL));
g_variant_unref(gvar);
} else
tmp_str = NULL;
- if (sr_config_list(sdi->driver, sdi, channel_group, key,
+ if (sr_config_list(driver, sdi, channel_group, key,
&gvar) != SR_OK) {
if (tmp_str) {
/* Can't list it, but we have a value to show. */
} else if (srci->datatype == SR_T_UINT64_RANGE) {
printf(" %s: ", srci->id);
- if (sr_config_list(sdi->driver, sdi, channel_group, key,
+ if (sr_config_list(driver, sdi, channel_group, key,
&gvar_list) != SR_OK) {
printf("\n");
continue;
}
- if (sr_config_get(sdi->driver, sdi, channel_group, key, &gvar) == SR_OK) {
+ if (sr_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) {
g_variant_get(gvar, "(tt)", &cur_low, &cur_high);
g_variant_unref(gvar);
} else {
} else if (srci->datatype == SR_T_BOOL) {
printf(" %s: ", srci->id);
- if (sr_config_get(sdi->driver, sdi, channel_group, key,
+ if (sr_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
if (g_variant_get_boolean(gvar))
printf("on (current), off\n");
} else if (srci->datatype == SR_T_DOUBLE_RANGE) {
printf(" %s: ", srci->id);
- if (sr_config_list(sdi->driver, sdi, channel_group, key,
+ if (sr_config_list(driver, sdi, channel_group, key,
&gvar_list) != SR_OK) {
printf("\n");
continue;
}
- if (sr_config_get(sdi->driver, sdi, channel_group, key, &gvar) == SR_OK) {
+ if (sr_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) {
g_variant_get(gvar, "(dd)", &dcur_low, &dcur_high);
g_variant_unref(gvar);
} else {
} else if (srci->datatype == SR_T_FLOAT) {
printf(" %s: ", srci->id);
- if (sr_config_get(sdi->driver, sdi, channel_group, key,
+ if (sr_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
printf("%f\n", g_variant_get_double(gvar));
g_variant_unref(gvar);
} else if (srci->datatype == SR_T_RATIONAL_PERIOD
|| srci->datatype == SR_T_RATIONAL_VOLT) {
printf(" %s", srci->id);
- if (sr_config_get(sdi->driver, sdi, channel_group, key,
+ if (sr_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
g_variant_get(gvar, "(tt)", &cur_p, &cur_q);
g_variant_unref(gvar);
} else
cur_p = cur_q = 0;
- if (sr_config_list(sdi->driver, sdi, channel_group,
+ if (sr_config_list(driver, sdi, channel_group,
key, &gvar_list) != SR_OK) {
printf("\n");
continue;