X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Finput%2Fcsv.c;h=1c4a5d7f16c8f7e18e063554a23ebccdb564c8f6;hb=11addc897a86a039f72cefbebb5058611ad79102;hp=19bed0b8f1ce493294164e2dce1710bdfb27613f;hpb=51e60cde097d0c770824585cdfe47735c6b5c248;p=libsigrok.git diff --git a/src/input/csv.c b/src/input/csv.c index 19bed0b8..1c4a5d7f 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -136,9 +136,6 @@ /* * TODO * - * - Unbreak analog data when submitted in the 'double' data type. This - * was observed with sigrok-cli screen output. Is analog.encoding->unitsize - * not handled appropriately? Is it a sigrok-cli or libsigrok issue? * - Add a test suite for input modules in general, and CSV in specific? * Becomes more important with the multitude of options and their * interaction. Could cover edge cases (BOM presence, line termination @@ -146,7 +143,7 @@ * samplerates, etc). */ -typedef float csv_analog_t; /* 'double' currently is flawed. */ +typedef double csv_analog_t; /* Single column formats. */ enum single_col_format { @@ -277,21 +274,13 @@ struct context { static int flush_samplerate(const struct sr_input *in) { struct context *inc; - struct sr_datafeed_packet packet; - struct sr_datafeed_meta meta; - struct sr_config *src; inc = in->priv; if (!inc->calc_samplerate && inc->samplerate) inc->calc_samplerate = inc->samplerate; if (inc->calc_samplerate && !inc->samplerate_sent) { - packet.type = SR_DF_META; - packet.payload = &meta; - src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(inc->calc_samplerate)); - meta.config = g_slist_append(NULL, src); - sr_session_send(in->sdi, &packet); - g_slist_free(meta.config); - sr_config_free(src); + (void)sr_session_send_meta(in->sdi, SR_CONF_SAMPLERATE, + g_variant_new_uint64(inc->calc_samplerate)); inc->samplerate_sent = TRUE; } @@ -350,6 +339,7 @@ static int flush_logic_samples(const struct sr_input *in) return rc; inc->datafeed_buf_fill = 0; + return SR_OK; } @@ -368,6 +358,7 @@ static int queue_logic_samples(const struct sr_input *in) if (rc != SR_OK) return rc; } + return SR_OK; } @@ -443,6 +434,7 @@ static int flush_analog_samples(const struct sr_input *in) } inc->analog_datafeed_buf_fill = 0; + return SR_OK; } @@ -461,6 +453,7 @@ static int queue_analog_samples(const struct sr_input *in) if (rc != SR_OK) return rc; } + return SR_OK; } @@ -728,6 +721,7 @@ static const struct column_details *lookup_column_details(struct context *inc, s return NULL; if (!nr || nr > inc->column_want_count) return NULL; + return &inc->column_details[nr - 1]; } @@ -1025,6 +1019,7 @@ static int parse_ignore(const char *column, struct context *inc, (void)column; (void)inc; (void)details; + return SR_OK; } @@ -1156,6 +1151,7 @@ static int format_match(GHashTable *metadata, unsigned int *confidence) if (!status) return SR_ERR; + return SR_OK; } @@ -1788,7 +1784,7 @@ static struct sr_option options[] = { }, [OPT_HEADER] = { "header", "Get channel names from first line.", - "Use the first processed line's column captions (when available) as channel names. Off by default", + "Use the first processed line's column captions (when available) as channel names. Enabled by default.", NULL, NULL, }, [OPT_SAMPLERATE] = { @@ -1825,7 +1821,7 @@ static const struct sr_option *get_options(void) l = g_slist_append(l, g_variant_ref_sink(g_variant_new_string("oct"))); options[OPT_SINGLE_FMT].values = l; options[OPT_START_LINE].def = g_variant_ref_sink(g_variant_new_uint32(1)); - options[OPT_HEADER].def = g_variant_ref_sink(g_variant_new_boolean(FALSE)); + options[OPT_HEADER].def = g_variant_ref_sink(g_variant_new_boolean(TRUE)); options[OPT_SAMPLERATE].def = g_variant_ref_sink(g_variant_new_uint64(0)); options[OPT_COL_SEP].def = g_variant_ref_sink(g_variant_new_string(",")); options[OPT_COMMENT].def = g_variant_ref_sink(g_variant_new_string(";"));