]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/ir_rc5/pd.py
ir_rc5: Convert to PD API version 3.
[libsigrokdecode.git] / decoders / ir_rc5 / pd.py
index e1dd42f3c0a0b60f382232146fc6b468bff23201..0b39e709698f935610fa30d475b35c42b8ee0ff4 100644 (file)
@@ -14,8 +14,7 @@
 ## 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 <http://www.gnu.org/licenses/>.
 ##
 
 import sigrokdecode as srd
@@ -25,7 +24,7 @@ class SamplerateError(Exception):
     pass
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'ir_rc5'
     name = 'IR RC-5'
     longname = 'IR RC-5'
@@ -56,7 +55,7 @@ class Decoder(srd.Decoder):
         ('fields', 'Fields', (1, 2, 3, 4, 5, 6)),
     )
 
-    def __init__(self, **kwargs):
+    def __init__(self):
         self.samplerate = None
         self.samplenum = None
         self.edges, self.bits, self.ss_es_bits = [], [], []
@@ -135,12 +134,12 @@ class Decoder(srd.Decoder):
         self.edges, self.bits, self.ss_es_bits = [], [], []
         self.state = 'IDLE'
 
-    def decode(self, ss, es, data):
+    def decode(self):
         if not self.samplerate:
             raise SamplerateError('Cannot decode without samplerate.')
-        for (self.samplenum, pins) in data:
+        while True:
 
-            self.ir = pins[0]
+            (self.ir,) = self.wait({'skip': 1})
 
             # Wait for any edge (rising or falling).
             if self.old_ir == self.ir: