X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=output%2Foutput_vcd.c;h=17505e6a2a1af10f2df1309db12430a38d255912;hb=54ac5277c5e462f1778300b9bc3fdd4709ecb2dc;hp=b21bfb92d83d17b87816011ba84b0c9165b812fb;hpb=32c0551ba66452acc24c9dc163ade3a637b1c7f2;p=libsigrok.git diff --git a/output/output_vcd.c b/output/output_vcd.c index b21bfb92..17505e6a 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -49,17 +49,17 @@ $dumpvars\n"; const char *vcd_header_comment = "\ $comment\n Acquisition with %d/%d probes at %s\n$end\n"; -static int init(struct output *o) +static int init(struct sr_output *o) { struct context *ctx; - struct probe *probe; + struct sr_probe *probe; GSList *l; int num_probes, i; char *samplerate_s, *frequency_s, *timestamp; time_t t; if (!(ctx = calloc(1, sizeof(struct context)))) - return SIGROK_ERR_MALLOC; + return SR_ERR_MALLOC; o->internal = ctx; ctx->num_enabled_probes = 0; @@ -72,7 +72,7 @@ static int init(struct output *o) } if (ctx->num_enabled_probes > 94) { g_warning("VCD only supports 94 probes."); - return SIGROK_ERR; + return SR_ERR; } ctx->probelist[ctx->num_enabled_probes] = 0; @@ -91,13 +91,13 @@ static int init(struct output *o) g_string_append_printf(ctx->header, "$version %s %s $end\n", PACKAGE, PACKAGE_VERSION); - if (o->device->plugin) { + if (o->device->plugin && sr_device_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) { ctx->samplerate = *((uint64_t *) o->device->plugin->get_device_info( - o->device->plugin_index, DI_CUR_SAMPLERATE)); - if (!((samplerate_s = sigrok_samplerate_string(ctx->samplerate)))) { + o->device->plugin_index, SR_DI_CUR_SAMPLERATE)); + if (!((samplerate_s = sr_samplerate_string(ctx->samplerate)))) { g_string_free(ctx->header, TRUE); free(ctx); - return SIGROK_ERR; + return SR_ERR; } g_string_append_printf(ctx->header, vcd_header_comment, ctx->num_enabled_probes, num_probes, samplerate_s); @@ -112,10 +112,10 @@ static int init(struct output *o) ctx->period = MHZ(1); else ctx->period = KHZ(1); - if (!(frequency_s = sigrok_period_string(ctx->period))) { + if (!(frequency_s = sr_period_string(ctx->period))) { g_string_free(ctx->header, TRUE); free(ctx); - return SIGROK_ERR; + return SR_ERR; } g_string_append_printf(ctx->header, "$timescale %s $end\n", frequency_s); free(frequency_s); @@ -135,13 +135,13 @@ static int init(struct output *o) if (!(ctx->prevbits = calloc(sizeof(int), num_probes))) { g_string_free(ctx->header, TRUE); free(ctx); - return SIGROK_ERR_MALLOC; + return SR_ERR_MALLOC; } - return SIGROK_OK; + return SR_OK; } -static int event(struct output *o, int event_type, char **data_out, +static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -149,7 +149,7 @@ static int event(struct output *o, int event_type, char **data_out, ctx = o->internal; switch (event_type) { - case DF_END: + case SR_DF_END: outbuf = strdup("$dumpoff\n$end\n"); *data_out = outbuf; *length_out = strlen(outbuf); @@ -162,10 +162,10 @@ static int event(struct output *o, int event_type, char **data_out, break; } - return SIGROK_OK; + return SR_OK; } -static int data(struct output *o, char *data_in, uint64_t length_in, +static int data(struct sr_output *o, const char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out) { struct context *ctx; @@ -219,13 +219,13 @@ static int data(struct output *o, char *data_in, uint64_t length_in, *length_out = out->len; g_string_free(out, FALSE); - return SIGROK_OK; + return SR_OK; } -struct output_format output_vcd = { +struct sr_output_format output_vcd = { "vcd", "Value Change Dump (VCD)", - DF_LOGIC, + SR_DF_LOGIC, init, data, event,