]> sigrok.org Git - libsigrok.git/blobdiff - src/input/csv.c
Use driver name as the log prefix in standard functions
[libsigrok.git] / src / input / csv.c
index cc451bacdab05382b5a38f9074e56f77c8d4ef00..1eb20bff72691bbf97ccf9bc8b0a637d47a76cd0 100644 (file)
@@ -612,7 +612,7 @@ static int process_buffer(struct sr_input *in)
 
        inc = in->priv;
        if (!inc->started) {
-               std_session_send_df_header(in->sdi, LOG_PREFIX);
+               std_session_send_df_header(in->sdi);
 
                if (inc->samplerate) {
                        packet.type = SR_DF_META;
@@ -621,6 +621,7 @@ static int process_buffer(struct sr_input *in)
                        src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
                        meta.config = g_slist_append(NULL, src);
                        sr_session_send(in->sdi, &packet);
+                       g_slist_free(meta.config);
                        sr_config_free(src);
                }
 
@@ -737,7 +738,6 @@ static int receive(struct sr_input *in, GString *buf)
 static int end(struct sr_input *in)
 {
        struct context *inc;
-       struct sr_datafeed_packet packet;
        int ret;
 
        if (in->sdi_ready)
@@ -746,11 +746,8 @@ static int end(struct sr_input *in)
                ret = SR_OK;
 
        inc = in->priv;
-       if (inc->started) {
-               /* End of stream. */
-               packet.type = SR_DF_END;
-               sr_session_send(in->sdi, &packet);
-       }
+       if (inc->started)
+               std_session_send_df_end(in->sdi);
 
        return ret;
 }
@@ -771,6 +768,17 @@ static void cleanup(struct sr_input *in)
        g_free(inc->sample_buffer);
 }
 
+static int reset(struct sr_input *in)
+{
+       struct context *inc = in->priv;
+
+       cleanup(in);
+       inc->started = FALSE;
+       g_string_truncate(in->buf, 0);
+
+       return SR_OK;
+}
+
 static struct sr_option options[] = {
        { "single-column", "Single column", "Enable/specify single column", NULL, NULL },
        { "numchannels", "Max channels", "Number of channels", NULL, NULL },
@@ -784,7 +792,7 @@ static struct sr_option options[] = {
        ALL_ZERO
 };
 
-static struct sr_option *get_options(void)
+static const struct sr_option *get_options(void)
 {
        if (!options[0].def) {
                options[0].def = g_variant_ref_sink(g_variant_new_int32(0));
@@ -811,4 +819,5 @@ SR_PRIV struct sr_input_module input_csv = {
        .receive = receive,
        .end = end,
        .cleanup = cleanup,
+       .reset = reset,
 };