diff options
author | Kristoffer Sjöberg <ksjoberg@q1.se> | 2011-11-13 03:11:40 +0100 |
---|---|---|
committer | Gareth McMullin <gareth@blacksphere.co.nz> | 2011-11-20 16:31:47 +1300 |
commit | 9d29ffadbe10efe400b1ced74636b8ee203f1e48 (patch) | |
tree | 4ebeba513d74584efe2dbb7093433ff29207f8a3 /decode.c | |
parent | 71a133c83c0df02d8c016ec8c192f070ad8a37fd (diff) | |
download | libsigrokdecode-9d29ffadbe10efe400b1ced74636b8ee203f1e48.tar.gz libsigrokdecode-9d29ffadbe10efe400b1ced74636b8ee203f1e48.zip |
Pass multiple samples to the protocol decoder and adapt transitioncounter.py to work with this.
Diffstat (limited to 'decode.c')
-rw-r--r-- | decode.c | 55 |
1 files changed, 28 insertions, 27 deletions
@@ -342,8 +342,11 @@ int srd_run_decoder(struct srd_decoder *dec, uint8_t **outbuf, uint64_t *outbuflen) { PyObject *py_mod, *py_func, *py_args, *py_value, *py_res; - uint64_t inbuf_pos = 0; int r, ret; + + /* FIXME: Don't have a timebase available here. Make one up. */ + static int _timehack = 0; + _timehack += inbuflen; /* TODO: Use #defines for the return codes. */ @@ -371,33 +374,31 @@ int srd_run_decoder(struct srd_decoder *dec, goto err_run_decref_func; } - while (inbuf_pos < inbuflen) { - /* Get the input buffer as Python "string" (byte array). */ - /* TODO: int vs. uint64_t for 'inbuflen'? */ - - py_value = Py_BuildValue("{sisiss#}", - "time", inbuf_pos / _unitsize, - "duration", 10, - "data", &inbuf[inbuf_pos], _unitsize - ); - - /* - * IMPORTANT: PyTuple_SetItem() "steals" a reference to py_value! - * That means we are no longer responsible for Py_XDECREF()'ing it. - * It will automatically be free'd when the 'py_args' tuple is free'd. - */ - if (PyTuple_SetItem(py_args, 0, py_value) != 0) { /* STEAL */ - ret = SRD_ERR_PYTHON; /* TODO: More specific error? */ - Py_XDECREF(py_value); /* TODO: Ref. stolen upon error? */ - goto err_run_decref_args; - } - - if (!(py_res = PyObject_CallObject(py_func, py_args))) { /* NEWREF */ - ret = SRD_ERR_PYTHON; /* TODO: More specific error? */ - goto err_run_decref_args; - } - inbuf_pos++; + /* Get the input buffer as Python "string" (byte array). */ + /* TODO: int vs. uint64_t for 'inbuflen'? */ + + py_value = Py_BuildValue("{sisiss#}", + "time", _timehack, + "duration", 10, + "data", inbuf, inbuflen / _unitsize + ); + + /* + * IMPORTANT: PyTuple_SetItem() "steals" a reference to py_value! + * That means we are no longer responsible for Py_XDECREF()'ing it. + * It will automatically be free'd when the 'py_args' tuple is free'd. + */ + if (PyTuple_SetItem(py_args, 0, py_value) != 0) { /* STEAL */ + ret = SRD_ERR_PYTHON; /* TODO: More specific error? */ + Py_XDECREF(py_value); /* TODO: Ref. stolen upon error? */ + goto err_run_decref_args; } + + if (!(py_res = PyObject_CallObject(py_func, py_args))) { /* NEWREF */ + ret = SRD_ERR_PYTHON; /* TODO: More specific error? */ + goto err_run_decref_args; + } + ret = SRD_OK; |