diff options
-rw-r--r-- | controller.c | 12 | ||||
-rw-r--r-- | sigrokdecode.h | 9 | ||||
-rw-r--r-- | type_decoder.c | 2 | ||||
-rw-r--r-- | type_logic.c | 6 |
4 files changed, 14 insertions, 15 deletions
diff --git a/controller.c b/controller.c index 963345c..9a663ff 100644 --- a/controller.c +++ b/controller.c @@ -283,11 +283,12 @@ int srd_instance_start(struct srd_decoder_instance *di, PyObject *args) * * @return SRD_OK upon success, a (negative) error code otherwise. */ -int srd_instance_decode(uint64_t timeoffset, uint64_t duration, +int srd_instance_decode(uint64_t start_samplenum, struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen) { PyObject *py_instance, *py_res; srd_logic *logic; + uint64_t end_samplenum; /* Return an error upon unusable input. */ if (di == NULL) @@ -304,14 +305,16 @@ int srd_instance_decode(uint64_t timeoffset, uint64_t duration, logic = PyObject_New(srd_logic, &srd_logic_type); Py_INCREF(logic); logic->di = di; + logic->start_samplenum = start_samplenum; logic->itercnt = 0; logic->inbuf = inbuf; logic->inbuflen = inbuflen; logic->sample = PyList_New(2); Py_INCREF(logic->sample); + end_samplenum = start_samplenum + inbuflen / di->unitsize; if (!(py_res = PyObject_CallMethod(py_instance, "decode", - "KKO", timeoffset, duration, logic))) { + "KKO", logic->start_samplenum, end_samplenum, logic))) { if (PyErr_Occurred()) PyErr_Print(); /* Returns void. */ @@ -360,14 +363,13 @@ int srd_session_start(int num_probes, int unitsize, uint64_t samplerate) } /* Feed logic samples to decoder session. */ -int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf, - uint64_t inbuflen) +int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen) { GSList *d; int ret; for (d = di_list; d; d = d->next) { - if ((ret = srd_instance_decode(timeoffset, duration, d->data, inbuf, + if ((ret = srd_instance_decode(start_samplenum, d->data, inbuf, inbuflen)) != SRD_OK) return ret; } diff --git a/sigrokdecode.h b/sigrokdecode.h index 863608b..1d8a79b 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -151,6 +151,7 @@ typedef struct { typedef struct { PyObject_HEAD struct srd_decoder_instance *di; + uint64_t start_samplenum; unsigned int itercnt; uint8_t *inbuf; uint64_t inbuflen; @@ -170,13 +171,11 @@ int srd_instance_set_probe(struct srd_decoder_instance *di, const char *probename, int num); struct srd_decoder_instance *srd_instance_find(char *instance_id); int srd_instance_start(struct srd_decoder_instance *di, PyObject *args); -int srd_instance_decode(uint64_t timeoffset, uint64_t duration, +int srd_instance_decode(uint64_t start_samplenum, struct srd_decoder_instance *dec, uint8_t *inbuf, uint64_t inbuflen); int srd_session_start(int num_probes, int unitsize, uint64_t samplerate); -int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf, - uint64_t inbuflen); -int pd_add(struct srd_decoder_instance *di, int output_type, - char *output_id); +int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf, uint64_t inbuflen); +int pd_add(struct srd_decoder_instance *di, int output_type, char *output_id); struct srd_decoder_instance *get_di_by_decobject(void *decobject); int srd_register_callback(int output_type, void *cb); void *srd_find_callback(int output_type); diff --git a/type_decoder.c b/type_decoder.c index 34b414e..e1e6796 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -177,7 +177,7 @@ static PyObject *Decoder_add(PyObject *self, PyObject *args) static PyMethodDef Decoder_methods[] = { {"put", Decoder_put, METH_VARARGS, - "Accepts a dictionary with the following keys: time, duration, data"}, + "Accepts a dictionary with the following keys: startsample, endsample, data"}, {"add", Decoder_add, METH_VARARGS, "Create a new output stream"}, {NULL, NULL, 0, NULL} }; diff --git a/type_logic.c b/type_logic.c index 2f79234..851a42e 100644 --- a/type_logic.c +++ b/type_logic.c @@ -56,16 +56,14 @@ PyObject *srd_logic_iternext(PyObject *self) sample >>= 1; } - /* TODO: samplenum should be in the inbuf feed, instead of time/duration. - * fake it for now... - */ /* Prepare the next samplenum/sample list in this iteration. */ - py_samplenum = PyLong_FromUnsignedLongLong(logic->itercnt++); + py_samplenum = PyLong_FromUnsignedLongLong(logic->start_samplenum + logic->itercnt); PyList_SetItem(logic->sample, 0, py_samplenum); py_samples = PyBytes_FromStringAndSize((const char *)probe_samples, logic->di->num_probes); PyList_SetItem(logic->sample, 1, py_samples); Py_INCREF(logic->sample); + logic->itercnt++; return logic->sample; } |