]> sigrok.org Git - libsigrok.git/blobdiff - output/vcd.c
Skip analog probes in logic-only output formats.
[libsigrok.git] / output / vcd.c
index 8e2d1b2191d9e1f77825a58c9cdec33aeeac2e83..44a12dec37a8c2e2265ea499d4410d61443d5ac3 100644 (file)
 #include "libsigrok.h"
 #include "libsigrok-internal.h"
 
-/* Message logging helpers with subsystem-specific prefix string. */
-#define LOG_PREFIX "output/vcd: "
-#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
-#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
-#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
-#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
-#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
-#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
+#define LOG_PREFIX "output/vcd"
 
 struct context {
        int num_enabled_probes;
@@ -69,6 +62,8 @@ static int init(struct sr_output *o)
 
        for (l = o->sdi->probes; l; l = l->next) {
                probe = l->data;
+               if (probe->type != SR_PROBE_LOGIC)
+                       continue;
                if (!probe->enabled)
                        continue;
                ctx->probeindices = g_array_append_val(
@@ -131,6 +126,8 @@ static int init(struct sr_output *o)
        /* Wires / channels */
        for (i = 0, l = o->sdi->probes; l; l = l->next, i++) {
                probe = l->data;
+               if (probe->type != SR_PROBE_LOGIC)
+                       continue;
                if (!probe->enabled)
                        continue;
                g_string_append_printf(ctx->header, "$var wire 1 %c %s $end\n",
@@ -190,7 +187,7 @@ static int receive(struct sr_output *o, const struct sr_dev_inst *sdi,
                for (p = 0; p < ctx->num_enabled_probes; p++) {
                        index = g_array_index(ctx->probeindices, int, p);
                        curbit = (sample[p / 8] & (((uint8_t) 1) << index)) >> index;
-                       prevbit = (ctx->prevsample[p / 8] & (((uint64_t) 1) << index)) >> index;
+                       prevbit = (ctx->prevsample[p / 8] & (((uint8_t) 1) << index)) >> index;
 
                        /* VCD only contains deltas/changes of signals. */
                        if (prevbit == curbit)