if (ctx->samplerate) {
packet.type = SR_DF_META;
packet.payload = &meta;
- src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&ctx->samplerate);
+ src = sr_config_new(SR_CONF_SAMPLERATE,
+ g_variant_new_uint64(ctx->samplerate));
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
+ sr_config_free(src);
}
/* Chop up the input file into chunks & send it to the session bus. */
/* Send metadata about the SR_DF_LOGIC packets to come. */
packet.type = SR_DF_META;
packet.payload = &meta;
- src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&samplerate);
+ src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
+ sr_config_free(src);
/* TODO: Handle trigger point. */
packet.type = SR_DF_META;
packet.payload = &meta;
samplerate = ctx->samplerate / ctx->downsample;
- src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&samplerate);
+ src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
+ sr_config_free(src);
/* Parse the contents of the VCD file */
parse_contents(file, in->sdi, ctx);
packet.type = SR_DF_META;
packet.payload = &meta;
- src = sr_config_new(SR_CONF_SAMPLERATE, (const void *)&ctx->samplerate);
+ src = sr_config_new(SR_CONF_SAMPLERATE,
+ g_variant_new_uint64(ctx->samplerate));
meta.config = g_slist_append(NULL, src);
sr_session_send(in->sdi, &packet);
+ sr_config_free(src);
if ((fd = open(filename, O_RDONLY)) == -1)
return SR_ERR;
struct context *ctx;
struct sr_probe *probe;
GSList *l;
- uint64_t *samplerate;
+ GVariant *gvar;
if (!o) {
sr_warn("%s: o was NULL", __func__);
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8;
if (sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
- o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- ctx->samplerate = *samplerate;
+ o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+ ctx->samplerate = g_variant_get_uint64(gvar);
+ g_variant_unref(gvar);
} else
ctx->samplerate = 0;
struct context *ctx;
struct sr_probe *probe;
GSList *l;
+ GVariant *gvar;
int num_probes;
- uint64_t *samplerate;
time_t t;
unsigned int i;
num_probes = g_slist_length(o->sdi->probes);
if (sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
- o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- ctx->samplerate = *samplerate;
+ o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+ ctx->samplerate = g_variant_get_uint64(gvar);
+ g_variant_unref(gvar);
} else
ctx->samplerate = 0;
struct context *ctx;
struct sr_probe *probe;
GSList *l;
- uint64_t *samplerate;
+ GVariant *gvar;
+ uint64_t samplerate;
unsigned int i;
int b, num_probes;
char *c, *frequency_s;
o->internal = ctx;
ctx->num_enabled_probes = 0;
for (l = o->sdi->probes; l; l = l->next) {
- probe = l->data; /* TODO: Error checks. */
+ probe = l->data;
if (!probe->enabled)
continue;
ctx->probelist[ctx->num_enabled_probes++] = probe->name;
num_probes = g_slist_length(o->sdi->probes);
comment[0] = '\0';
+ samplerate = 0;
if (sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
- o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- if (!(frequency_s = sr_samplerate_string(*samplerate))) {
+ o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+ samplerate = g_variant_get_uint64(gvar);
+ if (!(frequency_s = sr_samplerate_string(samplerate))) {
sr_err("%s: sr_samplerate_string failed", __func__);
g_free(ctx->header);
g_free(ctx);
+ g_variant_unref(gvar);
return SR_ERR;
}
snprintf(comment, 127, gnuplot_header_comment,
ctx->num_enabled_probes, num_probes, frequency_s);
g_free(frequency_s);
+ g_variant_unref(gvar);
}
/* Columns / channels */
sprintf(c, "# %d\t\t%s\n", i + 1, ctx->probelist[i]);
}
- if (!(frequency_s = sr_period_string(*samplerate))) {
+ if (!(frequency_s = sr_period_string(samplerate))) {
sr_err("%s: sr_period_string failed", __func__);
g_free(ctx->header);
g_free(ctx);
struct context *ctx;
struct sr_probe *probe;
GSList *l;
- uint64_t *samplerate, tmp;
+ GVariant *gvar;
+ uint64_t samplerate;
int num_enabled_probes;
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
}
ctx->unitsize = (num_enabled_probes + 7) / 8;
- if (o->sdi->driver && sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE))
- o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- else {
- tmp = 0;
- samplerate = &tmp;
+ if (o->sdi->driver && sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
+ o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+ samplerate = g_variant_get_uint64(gvar);
+ g_variant_unref(gvar);
+ } else {
+ samplerate = 0;
}
ctx->header = g_string_sized_new(512);
- g_string_append_printf(ctx->header, ";Rate: %"PRIu64"\n", *samplerate);
+ g_string_append_printf(ctx->header, ";Rate: %"PRIu64"\n", samplerate);
g_string_append_printf(ctx->header, ";Channels: %d\n", num_enabled_probes);
g_string_append_printf(ctx->header, ";EnabledChannels: -1\n");
g_string_append_printf(ctx->header, ";Compressed: true\n");
struct context *ctx;
struct sr_probe *probe;
GSList *l;
- uint64_t *samplerate;
+ GVariant *gvar;
+ uint64_t samplerate;
int num_probes, ret;
char *samplerate_s;
snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
num_probes = g_slist_length(o->sdi->probes);
if (o->sdi->driver || sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
- ret = o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- if (ret != SR_OK)
+ if ((ret = o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar,
+ o->sdi)) != SR_OK)
goto err;
- if (!(samplerate_s = sr_samplerate_string(*samplerate))) {
+ samplerate = g_variant_get_uint64(gvar);
+ if (!(samplerate_s = sr_samplerate_string(samplerate))) {
ret = SR_ERR;
+ g_variant_unref(gvar);
goto err;
}
snprintf(ctx->header + strlen(ctx->header),
"Acquisition with %d/%d probes at %s\n",
ctx->num_enabled_probes, num_probes, samplerate_s);
g_free(samplerate_s);
+ g_variant_unref(gvar);
}
ctx->linebuf_len = ctx->samples_per_line * 2 + 4;
struct context *ctx;
struct sr_probe *probe;
GSList *l;
- uint64_t *samplerate;
+ GVariant *gvar;
int num_probes, i;
char *samplerate_s, *frequency_s, *timestamp;
time_t t;
PACKAGE, PACKAGE_VERSION);
if (o->sdi->driver && sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
- o->sdi->driver->config_get(SR_CONF_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- ctx->samplerate = *samplerate;
+ o->sdi->driver->config_get(SR_CONF_SAMPLERATE, &gvar, o->sdi);
+ ctx->samplerate = g_variant_get_uint64(gvar);
if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) {
g_string_free(ctx->header, TRUE);
g_free(ctx);
+ g_variant_unref(gvar);
return SR_ERR;
}
g_string_append_printf(ctx->header, vcd_header_comment,
ctx->num_enabled_probes, num_probes, samplerate_s);
g_free(samplerate_s);
+ g_variant_unref(gvar);
}
/* timescale */