expose SRD_OUTPUT_* as symbols in the sigrokdecode module.
authorBert Vermeulen <bert@biot.com>
Sat, 7 Jan 2012 03:18:16 +0000 (04:18 +0100)
committerBert Vermeulen <bert@biot.com>
Sat, 7 Jan 2012 03:18:16 +0000 (04:18 +0100)
decoders/i2c.py
module_sigrokdecode.c
sigrokdecode.h

index 23b12c34f4791720067d068f82627aa42dd60972..2a10ab7408eb4c8950f27a46ff549a065c2a373a 100644 (file)
@@ -180,8 +180,8 @@ class Decoder(sigrokdecode.Decoder):
         self.oldsda = None
 
     def start(self, metadata):
-        self.output_protocol = self.output_new(1, 'i2c')
-        self.output_annotation = self.output_new(0, 'i2c')
+        self.output_protocol = self.output_new(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'i2c')
+        self.output_annotation = self.output_new(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'i2c')
 
     def report(self):
         pass
index b3bdafd792ce1c9ec0df73e5442ff1bf7ae9d8d3..9c8c72ef1c9f239e0687b96e1d0c797c5723303a 100644 (file)
@@ -220,6 +220,17 @@ PyMODINIT_FUNC PyInit_sigrokdecode(void)
        if (PyModule_AddObject(mod, "srd_logic", (PyObject *)&srd_logic_type) == -1)
                return NULL;
 
+       /* expose output types as symbols in the sigrokdecode module */
+       if(PyModule_AddObject(mod, "SRD_OUTPUT_ANNOTATION",
+                       PyLong_FromLong(SRD_OUTPUT_ANNOTATION)) == -1)
+               return NULL;
+       if(PyModule_AddObject(mod, "SRD_OUTPUT_PROTOCOL",
+                       PyLong_FromLong(SRD_OUTPUT_PROTOCOL)) == -1)
+               return NULL;
+       if(PyModule_AddObject(mod, "SRD_OUTPUT_BINARY",
+                       PyLong_FromLong(SRD_OUTPUT_BINARY)) == -1)
+               return NULL;
+
        return mod;
 }
 
index d58aea271cc0f299dbe4553b9418255868768f5b..1080b44c369d378d0e61efe129c7a2e3167f41db 100644 (file)
@@ -66,6 +66,9 @@ enum {
        SRD_OUTPUT_ANNOTATION,
        SRD_OUTPUT_PROTOCOL,
        SRD_OUTPUT_BINARY,
+       /* When adding an output type, don't forget to expose it to PDs
+        * in controller.c:PyInit_sigrokdecode()
+        */
 };
 
 #define SRD_MAX_NUM_PROBES   64