Hi guys,

 

First, thanks a ton for all the devs' work on Sigrok!  It's really a great,

easy to use tool.

 

I'm using the CSV output and some Python to do signal analysis for firmware

testing, and ran into a bug where the reported CSV time was advancing too

fast, causing errors in my post-processing of the CSV file:

    https://sigrok.org/bugzilla/show_bug.cgi?id=1027

 

The error is caused because there is a round-down error when 1/sampling

rate is not an integer number of nanoseconds.  That slightly too small

"period" variable is accumulated on each sample, leading to a speed-up

in the reported time in the CSV.

 

I've got a simple patch which avoids the error by doing the math at the

point of use, and not accumulating error.

 

https://github.com/earlephilhower/libsigrok/commit/5f314d2f708ae0721e743814f
5236df46dee538a

 

I've tested in my own use case (show below sampling a 1khz waveform with

a 12mhz samplerate), and it's easy to reproduce with any other non-integer

period sampling rate.

 

Thanks,

-Earle F. Philhower, III

earlephilho...@yahoo.com <mailto:earlephilho...@yahoo.com> 

 

---without patch---

earle@server:~/src/libsigrok$ sigrok-cli -d fx2lafw -C D1 -c
samplerate=12mhz -O csv:dedup=true --samples 100000

; CSV generated by libsigrok 0.5.0

; from fx2lafw (generic driver for FX2 based LAs) on Sat May  2 10:56:54
2020

; Channels (1/8): D1

; Samplerate: 12 MHz

nanoseconds,logic

83,0

252403,1

750486,0

1248486,1

1746569,0

2244569,1

2742652,0

3240652,1

3738735,0

4236818,1

4734901,0

5232901,1

5730984,0

6228984,1

6727067,0

7225067,1

7723150,0

8221150,1

8300000,1

 

---with-patch---

earle@server:~/src/libsigrok$ sigrok-cli -d fx2lafw -C D1 -c
samplerate=12mhz -O csv:dedup=true --samples 100000

; CSV generated by libsigrok 0.5.0

; from fx2lafw (generic driver for FX2 based LAs) on Sat May  2 10:40:51
2020

; Channels (1/8): D1

; Samplerate: 12 MHz

nanoseconds,logic

0,0

273583,1

773583,0

1273666,1

1773750,0

2273750,1

2773833,0

3273833,1

3773916,0

4274000,1

4774083,0

5274166,1

5774250,0

_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to