#include "sigrokdecode.h"
Go to the source code of this file.
Functions | |
SRD_PRIV int | srd_decoder_searchpath_add (const char *path) |
Add an additional search directory for the protocol decoders. More... | |
SRD_PRIV int | srd_inst_start (struct srd_decoder_inst *di, PyObject *args) |
SRD_PRIV int | srd_inst_decode (uint64_t start_samplenum, const struct srd_decoder_inst *dec, const uint8_t *inbuf, uint64_t inbuflen) |
Run the specified decoder function. More... | |
SRD_PRIV void | srd_inst_free (struct srd_decoder_inst *di) |
SRD_PRIV void | srd_inst_free_all (GSList *stack) |
SRD_PRIV int | srd_inst_pd_output_add (struct srd_decoder_inst *di, int output_type, const char *output_id) |
SRD_PRIV void * | srd_pd_output_callback_find (int output_type) |
SRD_PRIV void | srd_exception_catch (const char *format,...) |
SRD_PRIV int | srd_log (int loglevel, const char *format,...) |
SRD_PRIV int | srd_spew (const char *format,...) |
SRD_PRIV int | srd_dbg (const char *format,...) |
SRD_PRIV int | srd_info (const char *format,...) |
SRD_PRIV int | srd_warn (const char *format,...) |
SRD_PRIV int | srd_err (const char *format,...) |
SRD_PRIV int | py_attr_as_str (const PyObject *py_obj, const char *attr, char **outstr) |
Get the value of a Python object's attribute, returned as a newly allocated char *. More... | |
SRD_PRIV int | py_dictitem_as_str (const PyObject *py_obj, const char *key, char **outstr) |
Get the value of a Python dictionary item, returned as a newly allocated char *. More... | |
SRD_PRIV int | py_str_as_str (const PyObject *py_str, char **outstr) |
Get the value of a Python unicode string object, returned as a newly allocated char *. More... | |
SRD_PRIV int | py_strlist_to_char (const PyObject *py_strlist, char ***outstr) |
Convert a Python list of unicode strings to a NULL-terminated UTF8-encoded char * array. More... | |
SRD_PRIV struct srd_decoder_inst * | srd_inst_find_by_obj (const GSList *stack, const PyObject *obj) |
Find a decoder instance by its Python object. More... | |
SRD_PRIV int py_attr_as_str | ( | const PyObject * | py_obj, |
const char * | attr, | ||
char ** | outstr | ||
) |
Get the value of a Python object's attribute, returned as a newly allocated char *.
py_obj | The object to probe. |
attr | Name of the attribute to retrieve. |
outstr | ptr to char * storage to be filled in. |
Definition at line 36 of file util.c.
References py_str_as_str(), srd_dbg(), SRD_ERR_PYTHON, and srd_exception_catch().
Referenced by srd_decoder_load().
SRD_PRIV int py_dictitem_as_str | ( | const PyObject * | py_obj, |
const char * | key, | ||
char ** | outstr | ||
) |
Get the value of a Python dictionary item, returned as a newly allocated char *.
py_obj | The dictionary to probe. |
key | Key of the item to retrieve. |
outstr | Pointer to char * storage to be filled in. |
Definition at line 77 of file util.c.
References py_str_as_str(), srd_dbg(), and SRD_ERR_PYTHON.
SRD_PRIV int py_str_as_str | ( | const PyObject * | py_str, |
char ** | outstr | ||
) |
Get the value of a Python unicode string object, returned as a newly allocated char *.
py_str | The unicode string object. |
outstr | ptr to char * storage to be filled in. |
Definition at line 115 of file util.c.
References srd_dbg(), SRD_ERR_MALLOC, SRD_ERR_PYTHON, srd_exception_catch(), and SRD_OK.
Referenced by py_attr_as_str(), py_dictitem_as_str(), srd_decoder_doc_get(), srd_decoder_searchpath_add(), srd_exception_catch(), and srd_inst_option_set().
SRD_PRIV int py_strlist_to_char | ( | const PyObject * | py_strlist, |
char *** | outstr | ||
) |
Convert a Python list of unicode strings to a NULL-terminated UTF8-encoded char * array.
The caller must g_free() each string when finished.
py_strlist | The list object. |
outstr | ptr to char ** storage to be filled in. |
Definition at line 169 of file util.c.
References srd_err(), SRD_ERR_MALLOC, SRD_ERR_PYTHON, and SRD_OK.
Referenced by srd_decoder_load().
SRD_PRIV int srd_dbg | ( | const char * | format, |
... | |||
) |
Definition at line 221 of file log.c.
References SRD_LOG_DBG.
Referenced by py_attr_as_str(), py_dictitem_as_str(), py_str_as_str(), srd_decoder_load(), srd_decoder_searchpath_add(), srd_decoder_unload(), srd_exception_catch(), srd_exit(), srd_init(), srd_inst_decode(), srd_inst_free(), srd_inst_new(), srd_inst_pd_output_add(), srd_inst_probe_set_all(), srd_inst_start(), srd_log_logdomain_set(), srd_log_loglevel_set(), srd_pd_output_callback_add(), srd_session_send(), and srd_session_start().
SRD_PRIV int srd_decoder_searchpath_add | ( | const char * | path | ) |
Add an additional search directory for the protocol decoders.
The specified directory is prepended (not appended!) to Python's sys.path, in order to search for sigrok protocol decoders in the specified directories first, and in the generic Python module directories (and in the current working directory) last. This avoids conflicts if there are Python modules which have the same name as a sigrok protocol decoder in sys.path or in the current working directory.
path | Path to the directory containing protocol decoders which shall be added to the Python sys.path, or NULL. |
Definition at line 148 of file controller.c.
References py_str_as_str(), srd_dbg(), SRD_ERR_MALLOC, and SRD_OK.
Referenced by srd_init().
SRD_PRIV int srd_err | ( | const char * | format, |
... | |||
) |
Definition at line 260 of file log.c.
References SRD_LOG_ERR.
Referenced by py_strlist_to_char(), srd_decoder_load(), srd_decoder_load_all(), srd_exception_catch(), srd_inst_new(), srd_inst_option_set(), srd_inst_pd_output_add(), srd_inst_probe_set_all(), srd_inst_stack(), srd_inst_start(), srd_log_callback_set(), srd_log_logdomain_set(), srd_log_loglevel_set(), srd_pd_output_callback_add(), and srd_session_start().
SRD_PRIV void srd_exception_catch | ( | const char * | format, |
... | |||
) |
Definition at line 27 of file exception.c.
References py_str_as_str(), srd_dbg(), and srd_err().
Referenced by py_attr_as_str(), py_str_as_str(), srd_decoder_doc_get(), srd_decoder_load(), srd_inst_decode(), srd_inst_new(), srd_inst_option_set(), and srd_inst_start().
SRD_PRIV int srd_info | ( | const char * | format, |
... | |||
) |
Definition at line 234 of file log.c.
References SRD_LOG_INFO.
SRD_PRIV int srd_inst_decode | ( | uint64_t | start_samplenum, |
const struct srd_decoder_inst * | di, | ||
const uint8_t * | inbuf, | ||
uint64_t | inbuflen | ||
) |
Run the specified decoder function.
start_samplenum | The starting sample number for the buffer's sample set, relative to the start of capture. |
di | The decoder instance to call. Must not be NULL. |
inbuf | The buffer to decode. Must not be NULL. |
inbuflen | Length of the buffer. Must be > 0. |
Definition at line 612 of file controller.c.
References srd_decoder_inst::data_unitsize, srd_logic::di, srd_logic::inbuf, srd_logic::inbuflen, srd_decoder_inst::inst_id, srd_logic::itercnt, srd_decoder_inst::py_inst, srd_logic::sample, srd_dbg(), SRD_ERR_ARG, SRD_ERR_PYTHON, srd_exception_catch(), srd_logic_type, SRD_OK, and srd_logic::start_samplenum.
Referenced by srd_session_send().
|
read |
Find a decoder instance by its Python object.
I.e. find that instance's instantiation of the sigrokdecode.Decoder class. This will recurse to find the instance anywhere in the stack tree.
stack | Pointer to a GSList of struct srd_decoder_inst, indicating the stack to search. To start searching at the bottom level of decoder instances, pass NULL. |
obj | The Python class instantiation. |
Definition at line 543 of file controller.c.
References srd_decoder_inst::next_di, srd_decoder_inst::py_inst, and srd_inst_find_by_obj().
Referenced by srd_inst_find_by_obj().
SRD_PRIV void srd_inst_free | ( | struct srd_decoder_inst * | di | ) |
Definition at line 665 of file controller.c.
References srd_decoder_inst::dec_probemap, srd_decoder_inst::inst_id, srd_decoder_inst::next_di, srd_decoder_inst::pd_output, srd_pd_output::proto_id, srd_decoder_inst::py_inst, and srd_dbg().
Referenced by srd_inst_free_all().
SRD_PRIV void srd_inst_free_all | ( | GSList * | stack | ) |
Definition at line 684 of file controller.c.
References srd_decoder_inst::next_di, srd_inst_free(), and srd_inst_free_all().
Referenced by srd_decoder_unload(), and srd_inst_free_all().
SRD_PRIV int srd_inst_pd_output_add | ( | struct srd_decoder_inst * | di, |
int | output_type, | ||
const char * | output_id | ||
) |
Definition at line 826 of file controller.c.
References srd_pd_output::di, srd_decoder_inst::inst_id, srd_pd_output::output_type, srd_decoder_inst::pd_output, srd_pd_output::pdo_id, srd_pd_output::proto_id, srd_dbg(), and srd_err().
SRD_PRIV int srd_inst_start | ( | struct srd_decoder_inst * | di, |
PyObject * | args | ||
) |
Definition at line 562 of file controller.c.
References srd_decoder_inst::inst_id, srd_decoder_inst::next_di, srd_decoder_inst::py_inst, srd_dbg(), srd_err(), SRD_ERR_PYTHON, srd_exception_catch(), srd_inst_start(), and SRD_OK.
Referenced by srd_inst_start(), and srd_session_start().
SRD_PRIV int srd_log | ( | int | loglevel, |
const char * | format, | ||
... | |||
) |
SRD_PRIV void* srd_pd_output_callback_find | ( | int | output_type | ) |
Definition at line 807 of file controller.c.
References srd_pd_callback::cb, and srd_pd_callback::output_type.
SRD_PRIV int srd_spew | ( | const char * | format, |
... | |||
) |
Definition at line 208 of file log.c.
References SRD_LOG_SPEW.
SRD_PRIV int srd_warn | ( | const char * | format, |
... | |||
) |
Definition at line 247 of file log.c.
References SRD_LOG_WARN.