From: Gerhard Sittig Date: Sat, 3 Dec 2022 06:49:47 +0000 (+0100) Subject: input/csv: unbreak assignment of zero values to analog channels X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e7ed37042611;p=libsigrok.git input/csv: unbreak assignment of zero values to analog channels Unconditionally assign the value of 0.0 to the current sample's position of analog data for the session feed. Not assigning that zero value could result in old data from previous chunks to transpire through, yielding invalid output from CSV import when analog data is involved. This amends commit 43bdef263420 which introduced support for analog channels in the CSV input module. And phrased the implementation for similarity with logic data's code paths, where bit manipulation is more complex, and only high bits get applied to a previously cleared sample memory. Which introduced that zero value ignoring issue. Depending on software versions which used single or double precision data types, either requires 2^20 or 2^19 samples to reproduce. input file content: CH1 5.1 5.2 5.3 5 ... 524280 more "5" values ... 5 0 0 0 ; last 0.0 sample 2^19 correctly imported as 0.0 0 ; wrongly imported as 5.1 (first sample from beginning) 0 ; wrongly imported as 5.2 (second sample from beginning) 0 ; wrongly imported as 5.3 (third sample from beginning) 5 5 5 command invocation: $ sigrok-cli -i example.csv -I csv:column_formats=a | tail incorrect output data: CH1: 5.000 CH1: 0.000 CH1: 0.000 CH1: 0.000 CH1: 5.100 CH1: 5.200 CH1: 5.300 CH1: 5.000 CH1: 5.000 CH1: 5.000 Reported-By: Markus Heidelberg --- diff --git a/src/input/csv.c b/src/input/csv.c index 4dcc77b8..0750a4eb 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -379,8 +379,6 @@ static void set_analog_value(struct context *inc, size_t ch_idx, csv_analog_t va { if (ch_idx >= inc->analog_channels) return; - if (!value) - return; inc->analog_sample_buffer[ch_idx * inc->analog_datafeed_buf_size] = value; }