diff options
-rw-r--r-- | sigrokdecode.h | 8 | ||||
-rw-r--r-- | type_decoder.c | 22 |
2 files changed, 23 insertions, 7 deletions
diff --git a/sigrokdecode.h b/sigrokdecode.h index 0f332b2..dca2f98 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -67,10 +67,10 @@ enum { SRD_OUTPUT_ANN, SRD_OUTPUT_PROTO, SRD_OUTPUT_BINARY, - /* When adding an output type, don't forget to expose it to PDs in: - * controller.c:PyInit_sigrokdecode() - * and add a check in: - * module_sigrokdecode.c:Decoder_put() + /* When adding an output type, don't forget to... + * - expose it to PDs in controller.c:PyInit_sigrokdecode() + * - add a check in module_sigrokdecode.c:Decoder_put() + * - add a debug string in type_decoder.c:OUTPUT_TYPES */ }; diff --git a/type_decoder.c b/type_decoder.c index 86ccf02..1434cf2 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -22,6 +22,14 @@ #include "config.h" +/* This is only used for nicer srd_dbg() output. */ +char *OUTPUT_TYPES[] = { + "OUTPUT_ANN", + "OUTPUT_PROTO", + "OUTPUT_BINARY", +}; + + static int convert_pyobj(struct srd_decoder_instance *di, PyObject *obj, int *ann_format, char ***ann) { @@ -87,10 +95,16 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) int output_id; void (*cb)(); - if (!(di = get_di_by_decobject(self))) + if (!(di = get_di_by_decobject(self))) { + /* Shouldn't happen. */ + srd_dbg("srd: put(): self instance not found."); return NULL; + } if (!PyArg_ParseTuple(args, "KKiO", &start_sample, &end_sample, &output_id, &data)) + /* This throws an exception, but by returning NULL here we let python + * raise it. This results in a much better trace in controller.c + * on the decode() method call. */ return NULL; if (!(l = g_slist_nth(di->pd_output, output_id))) { @@ -100,6 +114,9 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args) } pdo = l->data; + srd_spew("srd: instance %s put %d-%d %s %d", di->instance_id, + start_sample, end_sample, OUTPUT_TYPES[output_id], output_id); + if (!(pdata = g_try_malloc0(sizeof(struct srd_proto_data)))) return NULL; pdata->start_sample = start_sample; @@ -154,13 +171,12 @@ static PyObject *Decoder_add(PyObject *self, PyObject *args) int output_type, pdo_id; if (!(di = get_di_by_decobject(self))) { - srd_dbg("srd: decoder instance not found"); PyErr_SetString(PyExc_Exception, "decoder instance not found"); return NULL; } if (!PyArg_ParseTuple(args, "is", &output_type, &proto_id)) { - catch_exception(""); + /* Let python raise this exception. */ return NULL; } |