{
int ret;
- srd_dbg("srd: initializing");
+ srd_dbg("Initializing libsigrokdecode.");
/* Add our own module to the list of built-in modules. */
PyImport_AppendInittab("sigrokdecode", PyInit_sigrokdecode);
int srd_exit(void)
{
- srd_dbg("srd: exiting");
+ srd_dbg("Exiting libsigrokdecode.");
srd_unload_all_decoders();
g_slist_free(pd_list);
if (key)
g_free(key);
if (PyErr_Occurred())
- catch_exception("srd: stray exception in srd_instance_set_options()");
+ catch_exception("Stray exception in srd_instance_set_options().");
return ret;
}
int i;
char *instance_id;
- srd_dbg("srd: creating new %s instance", decoder_id);
+ srd_dbg("Creating new %s instance.", decoder_id);
if (!(dec = srd_get_decoder_by_id(decoder_id))) {
srd_err("Protocol decoder %s not found.", decoder_id);
GSList *l;
struct srd_decoder_instance *next_di;
- srd_dbg("srd: calling start() method on protocol decoder instance %s",
- di->instance_id);
+ srd_dbg("Calling start() method on protocol decoder instance %s.",
+ di->instance_id);
if (!(py_name = PyUnicode_FromString("start"))) {
srd_err("Unable to build python object for 'start'.");
* Run the specified decoder function.
*
* @param start_samplenum The starting sample number for the buffer's sample
- * set, relative to the start of capture.
- * @param di The decoder instance to call.
- * @param inbuf The buffer to decode.
- * @param inbuflen Length of the buffer.
+ * set, relative to the start of capture.
+ * @param di The decoder instance to call. Must not be NULL.
+ * @param inbuf The buffer to decode. Must not be NULL.
+ * @param inbuflen Length of the buffer. Must be > 0.
*
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
int srd_instance_decode(uint64_t start_samplenum,
- struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen)
+ struct srd_decoder_instance *di, uint8_t *inbuf, uint64_t inbuflen)
{
PyObject *py_res;
srd_logic *logic;
uint64_t end_samplenum;
- srd_dbg("srd: calling decode() on instance %s with %d bytes starting "
- "at sample %d", di->instance_id, inbuflen, start_samplenum);
+ srd_dbg("Calling decode() on instance %s with %d bytes starting "
+ "at sample %d.", di->instance_id, inbuflen, start_samplenum);
/* Return an error upon unusable input. */
- if (di == NULL) {
- srd_dbg("srd: empty decoder instance");
+ if (!di) {
+ srd_dbg("empty decoder instance");
return SRD_ERR_ARG;
}
- if (inbuf == NULL) {
- srd_dbg("srd: NULL buffer pointer");
+ if (!inbuf) {
+ srd_dbg("NULL buffer pointer");
return SRD_ERR_ARG;
}
if (inbuflen == 0) {
- srd_dbg("srd: empty buffer");
+ srd_dbg("empty buffer");
return SRD_ERR_ARG;
}
struct srd_decoder_instance *di;
int ret;
- srd_dbg("srd: calling start() on all instances with %d probes, "
- "unitsize %d samplerate %d", num_probes, unitsize, samplerate);
+ srd_dbg("Calling start() on all instances with %d probes, "
+ "unitsize %d samplerate %d.", num_probes, unitsize, samplerate);
/* Currently only one item of metadata is passed along to decoders,
* samplerate. This can be extended as needed.
GSList *d;
int ret;
- srd_dbg("srd: calling decode() on all instances with starting sample "
- "number %"PRIu64", %"PRIu64" bytes at 0x%p", start_samplenum,
- inbuflen, inbuf);
+ srd_dbg("Calling decode() on all instances with starting sample "
+ "number %"PRIu64", %"PRIu64" bytes at 0x%p", start_samplenum,
+ inbuflen, inbuf);
for (d = di_list; d; d = d->next) {
if ((ret = srd_instance_decode(start_samplenum, d->data, inbuf,
{
struct srd_pd_callback *pd_cb;
- srd_dbg("srd: registering new callback for output type %d", output_type);
+ srd_dbg("Registering new callback for output type %d.", output_type);
if (!(pd_cb = g_try_malloc(sizeof(struct srd_pd_callback))))
return SRD_ERR_MALLOC;
/* This is the backend function to python sigrokdecode.add() call. */
-int pd_add(struct srd_decoder_instance *di, int output_type,
- char *proto_id)
+int pd_add(struct srd_decoder_instance *di, int output_type, char *proto_id)
{
struct srd_pd_output *pdo;
- srd_dbg("srd: instance %s creating new output type %d for %s",
- di->instance_id, output_type, proto_id);
+ srd_dbg("Instance %s creating new output type %d for %s.",
+ di->instance_id, output_type, proto_id);
if (!(pdo = g_try_malloc(sizeof(struct srd_pd_output))))
return -1;
if (!(di = srd_instance_find_by_obj(NULL, self))) {
/* Shouldn't happen. */
- srd_dbg("srd: put(): self instance not found.");
+ srd_dbg("put(): self instance not found.");
return NULL;
}
}
pdo = l->data;
- srd_spew("srd: instance %s put %d-%d %s on oid %d", di->instance_id,
- start_sample, end_sample, OUTPUT_TYPES[pdo->output_type], output_id);
+ srd_spew("Instance %s put %d-%d %s on oid %d.", di->instance_id,
+ start_sample, end_sample, OUTPUT_TYPES[pdo->output_type],
+ output_id);
if (!(pdata = g_try_malloc0(sizeof(struct srd_proto_data))))
return NULL;
next_di = l->data;
/* TODO: is this needed? */
Py_XINCREF(next_di->py_instance);
- srd_spew("srd: sending %d-%d to instance %s",
- start_sample, end_sample, next_di->instance_id);
+ srd_spew("Sending %d-%d to instance %s",
+ start_sample, end_sample, next_di->instance_id);
if (!(py_res = PyObject_CallMethod(next_di->py_instance, "decode",
"KKO", start_sample, end_sample, data))) {
catch_exception("calling %s decode(): ", next_di->instance_id);
int ret;
if (!PyObject_HasAttrString(py_obj, attr)) {
- srd_dbg("srd: %s object has no attribute '%s'.",
- Py_TYPE(py_obj)->tp_name, attr);
+ srd_dbg("%s object has no attribute '%s'.",
+ Py_TYPE(py_obj)->tp_name, attr);
return SRD_ERR_PYTHON;
}
}
if (!PyUnicode_Check(py_str)) {
- srd_dbg("srd: %s attribute should be a string, but is a %s.",
- attr, Py_TYPE(py_str)->tp_name);
+ srd_dbg("%s attribute should be a string, but is a %s.",
+ attr, Py_TYPE(py_str)->tp_name);
Py_DecRef(py_str);
return SRD_ERR_PYTHON;
}
int ret;
if (!PyDict_Check(py_obj)) {
- srd_dbg("srd: Object is a %s, not a dictionary.", Py_TYPE(py_obj)->tp_name);
+ srd_dbg("Object is a %s, not a dictionary.", Py_TYPE(py_obj)->tp_name);
return SRD_ERR_PYTHON;
}
if (!(py_value = PyDict_GetItemString(py_obj, key))) {
- srd_dbg("srd: Dictionary has no attribute '%s'.", key);
+ srd_dbg("Dictionary has no attribute '%s'.", key);
return SRD_ERR_PYTHON;
}
if (!PyUnicode_Check(py_value)) {
- srd_dbg("srd: Dictionary value for %s should be a string, but is a %s.",
- key, Py_TYPE(py_value)->tp_name);
+ srd_dbg("Dictionary value for %s should be a string, but is a %s.",
+ key, Py_TYPE(py_value)->tp_name);
return SRD_ERR_PYTHON;
}
ret = SRD_OK;
if (!PyUnicode_Check(py_str)) {
- srd_dbg("srd: object is a %s, not a string object", Py_TYPE(py_str)->tp_name);
+ srd_dbg("Object is a %s, not a string object.", Py_TYPE(py_str)->tp_name);
ret = SRD_ERR_PYTHON;
goto err_out;
}
}
if (!(*outstr = g_strdup(str))) {
- srd_dbg("srd: malloc failed");
+ srd_dbg("outstr malloc failed");
ret = SRD_ERR_MALLOC;
goto err_out;
}