Bug 950 - raw_analog input loses precision upon import
Summary: raw_analog input loses precision upon import
Status: RESOLVED FIXED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: Input: raw_analog (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-26 10:09 CEST by Gerhard Sittig
Modified: 2018-09-20 21:48 CEST (History)
2 users (show)



Attachments
notes and test data for raw_analog input (2.45 KB, application/zip)
2017-05-26 10:09 CEST, Gerhard Sittig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Sittig 2017-05-26 10:09:25 CEST
Created attachment 306 [details]
notes and test data for raw_analog input

David C. Wiens reported to the ML (2017-05-25) that the raw_analog input 
yields unexpected waveforms in Pulseview ("mix of mostly sawtooth and 
vertical lines"). Reproduction shows that sigrok-cli does not present 
expected values either, the libsigrok input module appears to lose precision 
which might be an issue in addition to the waveform display in the GUI.

See the attachment for (how to generate) test input data, how to invoke 
the CLI tool for reproduction, and how to potentially adjust the input 
module's source.

Haven't looked into the GUI waveform presentation and whether it deserves 
a separate report for the Pulseview component.
Comment 1 Martin Ling 2018-09-20 03:53:09 CEST
Fixed on this branch:

https://github.com/martinling/libsigrok/commits/analog-fixes

The key issue was that raw_analog was setting the 'digits' field of sr_analog_encoding to zero, meaning that the values after the decimal point were not significant.

The analog output module also needed fixing, because it didn't know how to select a sufficient number of decimal digits to display a given number of binary ones.

Finally, sr_analog_si_prefix_friendly() had a bug too, which is why you were getting SI prefixes in the output for unitless data.

Output is now as expected:

CH1: 0.000 
CH2: 0.125 
CH1: 0.250 
CH2: 0.375 
CH1: 0.500 
CH2: 0.625 
CH1: 0.750 
CH2: 0.875 
CH1: -1.000 
CH2: -0.875 
CH1: -0.750 
CH2: -0.625 
CH1: -0.500 
CH2: -0.375 
CH1: -0.250 
CH2: -0.125
Comment 2 Uwe Hermann 2018-09-20 21:48:55 CEST
Thanks a lot! Fixed in:

5e5fde6e2c3aabfc61bcd35a53ab0d401b2176ba
cd1e7fd20dde8475ab766425c352f8ad4247747c
56bcbbffd059b0049e530481e2842a5ac48fd447

(hashes changed as I mentioned the bug number in the commit msg)