X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=output%2Foutput_vcd.c;h=509aad0754b7b0075aab2796ee6a0759fb693d70;hb=c548332c21acc2588114214b38eaa3237fc3f8b3;hp=6833eec26123da43f44c7d86044bb68d5208566b;hpb=f50f3f40d9238b0c50be67e52bc132aadfcf2050;p=libsigrok.git diff --git a/output/output_vcd.c b/output/output_vcd.c index 6833eec2..509aad07 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "config.h" struct context { @@ -36,23 +37,13 @@ struct context { uint64_t samplerate; }; -const char *vcd_header = "\ -$date %s $end\n\ -$version %s $end\n%s\ -$timescale %s $end\n\ -$scope module %s $end\n\ -%s\ -$upscope $end\n\ -$enddefinitions $end\n\ -$dumpvars\n"; - -const char *vcd_header_comment = "\ +static const char *vcd_header_comment = "\ $comment\n Acquisition with %d/%d probes at %s\n$end\n"; 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; @@ -71,7 +62,7 @@ static int init(struct sr_output *o) ctx->probelist[ctx->num_enabled_probes++] = probe->name; } if (ctx->num_enabled_probes > 94) { - g_warning("VCD only supports 94 probes."); + sr_warn("VCD only supports 94 probes."); return SR_ERR; } @@ -91,10 +82,10 @@ static int init(struct sr_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 SR_ERR; @@ -106,13 +97,13 @@ static int init(struct sr_output *o) /* timescale */ /* VCD can only handle 1/10/100 (s - fs), so scale up first */ - if (ctx->samplerate > MHZ(1)) - ctx->period = GHZ(1); - else if (ctx->samplerate > KHZ(1)) - ctx->period = MHZ(1); + if (ctx->samplerate > SR_MHZ(1)) + ctx->period = SR_GHZ(1); + else if (ctx->samplerate > SR_KHZ(1)) + ctx->period = SR_MHZ(1); else - ctx->period = KHZ(1); - if (!(frequency_s = sigrok_period_string(ctx->period))) { + ctx->period = SR_KHZ(1); + if (!(frequency_s = sr_period_string(ctx->period))) { g_string_free(ctx->header, TRUE); free(ctx); return SR_ERR; @@ -149,7 +140,7 @@ static int event(struct sr_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); @@ -165,7 +156,7 @@ static int event(struct sr_output *o, int event_type, char **data_out, return SR_OK; } -static int data(struct sr_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; @@ -223,10 +214,10 @@ static int data(struct sr_output *o, char *data_in, uint64_t length_in, } struct sr_output_format output_vcd = { - "vcd", - "Value Change Dump (VCD)", - DF_LOGIC, - init, - data, - event, + .id = "vcd", + .description = "Value Change Dump (VCD)", + .df_type = SR_DF_LOGIC, + .init = init, + .data = data, + .event = event, };