/*
- * This file is part of the sigrok project.
+ * This file is part of the libsigrok project.
*
- * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
+ * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
* Copyright (C) 2011 HÃ¥vard Espeland <gus@ping.uio.no>
*
* This program is free software: you can redistribute it and/or modify
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_hwcap(o->sdi, SR_HWCAP_SAMPLERATE)) {
- ret = o->sdi->driver->info_get(SR_DI_CUR_SAMPLERATE,
- (const void **)&samplerate, o->sdi);
- if (ret != SR_OK)
+ if (o->sdi->driver || sr_dev_has_option(o->sdi, SR_CONF_SAMPLERATE)) {
+ 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;
ret = SR_ERR_MALLOC;
}
+ if (mode == MODE_ASCII &&
+ !(ctx->prevsample = g_try_malloc0(num_probes / 8))) {
+ sr_err("%s: ctx->prevsample malloc failed", __func__);
+ ret = SR_ERR_MALLOC;
+ }
+
err:
if (ret != SR_OK) {
g_free(ctx->header);