X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Frfm12%2Fpd.py;h=d3df13a9eb3dfeb024cf7cf836b43a672d269920;hb=6cbba91f23b9f9ace75b4722c9c0776b9211008d;hp=c82a898f8e062c87eb9c27dd27de947dc3e63aca;hpb=4ef0ff313b3ac48d585f581593738c1a3e607f26;p=libsigrokdecode.git diff --git a/decoders/rfm12/pd.py b/decoders/rfm12/pd.py index c82a898..d3df13a 100644 --- a/decoders/rfm12/pd.py +++ b/decoders/rfm12/pd.py @@ -1,7 +1,7 @@ ## ## This file is part of the libsigrokdecode project. ## -## Copyright (C) 2014 Sławek Piotrowski +## Copyright (C) 2014 Sławek Piotrowski ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,21 +14,21 @@ ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## along with this program; if not, see . ## import sigrokdecode as srd class Decoder(srd.Decoder): - api_version = 2 + api_version = 3 id = 'rfm12' name = 'RFM12' - longname = 'RFM12 control protocol' - desc = 'Protocol for controlling RFM12 wireless transceivers from HoperRF' + longname = 'HopeRF RFM12' + desc = 'HopeRF RFM12 wireless transceiver control protocol.' license = 'gplv2+' inputs = ['spi'] - outputs = ['rfm12'] + outputs = [] + tags = ['Wireless/RF'] annotations = ( ('cmd', 'Command'), ('params', 'Command parameters'), @@ -43,7 +43,10 @@ class Decoder(srd.Decoder): ('interpretation', 'Interpretation', (5,)), ) - def __init__(self, **kwargs): + def __init__(self): + self.reset() + + def reset(self): self.mosi_bytes, self.miso_bytes = [], [] self.mosi_bits, self.miso_bits = [], [] self.row_pos = [0, 0, 0] @@ -120,7 +123,7 @@ class Decoder(srd.Decoder): self.describe_bits(bits, NAMES) self.describe_changed_bits(bits, old_bits, NAMES) - FREQUENCIES = ['Reserved', '433', '868', '912'] + FREQUENCIES = ['315', '433', '868', '915'] f = FREQUENCIES[(cmd[1] & 0x30) >> 4] + 'MHz' self.putx(1, 2, ['Frequency: ' + f, f]) if cmd[1] & 0x30 != self.last_config & 0x30: @@ -264,17 +267,17 @@ class Decoder(srd.Decoder): else: self.advance_ann(5, 2) - range = (cmd[1] & 0x30) >> 4 + range_limit = (cmd[1] & 0x30) >> 4 FREQ_TABLE = [0.0, 2.5, 5.0, 7.5] freq_delta = FREQ_TABLE[(self.last_config & 0x30) >> 4] - if range == 0: + if range_limit == 0: self.putx(0, 2, ['Range: No limit']) - elif range == 1: + elif range_limit == 1: self.putx(0, 2, ['Range: +/-%dkHz' % (15 * freq_delta)]) - elif range == 2: + elif range_limit == 2: self.putx(0, 2, ['Range: +/-%dkHz' % (7 * freq_delta)]) - elif range == 3: + elif range_limit == 3: self.putx(0, 2, ['Range: +/-%dkHz' % (3 * freq_delta)]) if (cmd[1] & 0x30) != (self.last_afc & 0x30): @@ -460,7 +463,7 @@ class Decoder(srd.Decoder): else: c = '%02x %02x' % tuple(cmd) r = '%02x %02x' % tuple(ret) - self.putx(0, 16, ['Uknown command: %s (reply: %s)!' % (c, r)]) + self.putx(0, 16, ['Unknown command: %s (reply: %s)!' % (c, r)]) def decode(self, ss, es, data): ptype, mosi, miso = data