From: Gerhard Sittig Date: Sat, 2 May 2020 13:08:41 +0000 (+0200) Subject: sae_j1850_vpw: drop the part which duplicates the timing decoder X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fcf7bf485a886370573c2e40a2eadb95acb3c936;p=libsigrokdecode.git sae_j1850_vpw: drop the part which duplicates the timing decoder The SAE J1850 Variable Pulse Width decoder used to track and annotate the width of pulses between edges, which duplicates existing features of the 'timing' decoder. Remove this part from J1850, users can always connect the input signal to multiple decoders as needed.. Also sort annotation rows while we are here. Top to bottom represents raw wire bits to highest interpretation layer, as in other decoders. --- diff --git a/decoders/sae_j1850_vpw/pd.py b/decoders/sae_j1850_vpw/pd.py index 4ecba5c..fd2389e 100644 --- a/decoders/sae_j1850_vpw/pd.py +++ b/decoders/sae_j1850_vpw/pd.py @@ -25,22 +25,9 @@ class SamplerateError(Exception): def timeuf(t): return int (t * 1000.0 * 1000.0) -def normalize_time(t): - if t >= 1.0: - return '%d s' % t - elif t >= 0.001: - return '%d ms' % (t * 1000.0) - elif t >= 0.000001: - return '%d μs' % (t * 1000.0 * 1000.0) - elif t >= 0.000000001: - return '%d ns' % (t * 1000.0 * 1000.0 * 1000.0) - else: - return '%f' % t - class Ann: - ANN_TIME, \ ANN_RAW, ANN_SOF, ANN_IFS, ANN_DATA, \ - ANN_PACKET = range(6) + ANN_PACKET = range(5) class Decoder(srd.Decoder): api_version = 3 @@ -56,7 +43,6 @@ class Decoder(srd.Decoder): {'id': 'data', 'name': 'Data', 'desc': 'Data line'}, ) annotations = ( - ('time', 'Time'), ('raw', 'Raw'), ('sof', 'SOF'), ('ifs', 'EOF/IFS'), @@ -64,10 +50,9 @@ class Decoder(srd.Decoder): ('packet', 'Packet'), ) annotation_rows = ( - ('packets', 'Packets', (Ann.ANN_PACKET,)), - ('bytes', 'Bytes', (Ann.ANN_DATA,)), ('raws', 'Raws', (Ann.ANN_RAW, Ann.ANN_SOF, Ann.ANN_IFS,)), - ('times', 'Times', (Ann.ANN_TIME,)), + ('bytes', 'Bytes', (Ann.ANN_DATA,)), + ('packets', 'Packets', (Ann.ANN_PACKET,)), ) def __init__(self): @@ -147,8 +132,6 @@ class Decoder(srd.Decoder): es = self.samplenum samples = es - ss - txt = normalize_time(samples / self.samplerate) - self.put(ss, es, self.out_ann, [Ann.ANN_TIME, [txt]]) t = timeuf(samples / self.samplerate) if self.state == 'IDLE': # detect and set speed from the size of sof if pin == self.active and t in range(self.sofl , self.sofh):