]> sigrok.org Git - libsigrok.git/blobdiff - output/text/text.c
sr: fx2lafw: Abort pending transfers when sampling is stopped
[libsigrok.git] / output / text / text.c
index 4267c5b0021ac21aa43f9249ff6483828e4b276f..f0237a9836c5fb643a96da7aef6360129df29e94 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the sigrok project.
  *
- * Copyright (C) 2011 Bert Vermeulen <bert@biot.com>
+ * Copyright (C) 2010-2012 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
@@ -27,7 +27,7 @@
 #include "sigrok-internal.h"
 #include "text.h"
 
-SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf)
+SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
 {
        static int max_probename_len = 0;
        int len, i;
@@ -45,7 +45,8 @@ SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf)
        }
 
        for (i = 0; ctx->probelist[i]; i++) {
-               sprintf(outbuf + strlen(outbuf), "%*s:%s\n", max_probename_len,
+               sprintf((char *)outbuf + strlen((const char *)outbuf),
+                       "%*s:%s\n", max_probename_len,
                        ctx->probelist[i], ctx->linebuf + i * ctx->linebuf_len);
        }
 
@@ -57,8 +58,8 @@ SR_PRIV void flush_linebufs(struct context *ctx, char *outbuf)
                if (ctx->mode == MODE_ASCII)
                        space_offset = 0;
 
-               sprintf(outbuf + strlen(outbuf), "T:%*s^\n",
-                       ctx->mark_trigger + space_offset, "");
+               sprintf((char *)outbuf + strlen((const char *)outbuf),
+                       "T:%*s^\n", ctx->mark_trigger + space_offset, "");
        }
 
        memset(ctx->linebuf, 0, i * ctx->linebuf_len);
@@ -81,7 +82,7 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
        o->internal = ctx;
        ctx->num_enabled_probes = 0;
 
-       for (l = o->device->probes; l; l = l->next) {
+       for (l = o->dev->probes; l; l = l->next) {
                probe = l->data;
                if (!probe->enabled)
                        continue;
@@ -109,10 +110,10 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
        }
 
        snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
-       num_probes = g_slist_length(o->device->probes);
-       if (o->device->plugin || sr_dev_has_hwcap(o->device, SR_HWCAP_SAMPLERATE)) {
-               samplerate = *((uint64_t *) o->device->plugin->get_device_info(
-                               o->device->plugin_index, SR_DI_CUR_SAMPLERATE));
+       num_probes = g_slist_length(o->dev->probes);
+       if (o->dev->driver || sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
+               samplerate = *((uint64_t *) o->dev->driver->dev_info_get(
+                               o->dev->driver_index, SR_DI_CUR_SAMPLERATE));
                if (!(samplerate_s = sr_samplerate_string(samplerate))) {
                        g_free(ctx->header);
                        g_free(ctx);
@@ -142,12 +143,12 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
        return SR_OK;
 }
 
-SR_PRIV int event(struct sr_output *o, int event_type, char **data_out,
+SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
                  uint64_t *length_out)
 {
        struct context *ctx;
        int outsize;
-       char *outbuf;
+       uint8_t *outbuf;
 
        ctx = o->internal;
        switch (event_type) {
@@ -165,7 +166,7 @@ SR_PRIV int event(struct sr_output *o, int event_type, char **data_out,
                }
                flush_linebufs(ctx, outbuf);
                *data_out = outbuf;
-               *length_out = strlen(outbuf);
+               *length_out = strlen((const char *)outbuf);
                g_free(o->internal);
                o->internal = NULL;
                break;