libsigrokdecode
 All Data Structures Files Functions Variables Typedefs Enumerator Macros
Functions
sigrokdecode-internal.h File Reference
#include "sigrokdecode.h"
Include dependency graph for sigrokdecode-internal.h:
This graph shows which files directly or indirectly include this file:

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_instsrd_inst_find_by_obj (const GSList *stack, const PyObject *obj)
 Find a decoder instance by its Python object. More...
 

Function Documentation

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 *.

Parameters
py_objThe object to probe.
attrName of the attribute to retrieve.
outstrptr to char * storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a malloc()ed string upon success.

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().

Here is the call graph for this function:

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 *.

Parameters
py_objThe dictionary to probe.
keyKey of the item to retrieve.
outstrPointer to char * storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a malloc()ed string upon success.

Definition at line 77 of file util.c.

References py_str_as_str(), srd_dbg(), and SRD_ERR_PYTHON.

Here is the call graph for this function:

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 *.

Parameters
py_strThe unicode string object.
outstrptr to char * storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a malloc()ed string upon success.

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().

Here is the call graph for this function:

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.

Parameters
py_strlistThe list object.
outstrptr to char ** storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a g_malloc()ed char** upon success.

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().

Here is the call graph for this function:

SRD_PRIV int srd_dbg ( const char *  format,
  ... 
)
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.

Parameters
pathPath to the directory containing protocol decoders which shall be added to the Python sys.path, or NULL.
Returns
SRD_OK upon success, a (negative) error code otherwise.

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().

Here is the call graph for this function:

SRD_PRIV int srd_err ( const char *  format,
  ... 
)
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().

Here is the call graph for this function:

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.

Parameters
start_samplenumThe starting sample number for the buffer's sample set, relative to the start of capture.
diThe decoder instance to call. Must not be NULL.
inbufThe buffer to decode. Must not be NULL.
inbuflenLength of the buffer. Must be > 0.
Returns
SRD_OK upon success, a (negative) error code otherwise.

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().

Here is the call graph for this function:

SRD_PRIV struct srd_decoder_inst* srd_inst_find_by_obj ( const GSList *  stack,
const PyObject *  obj 
)
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.

Parameters
stackPointer 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.
objThe Python class instantiation.
Returns
Pointer to struct srd_decoder_inst, or NULL if not found.

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().

Here is the call graph for this function:

SRD_PRIV void srd_inst_free ( struct srd_decoder_inst di)
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().

Here is the call graph for this function:

SRD_PRIV int srd_inst_pd_output_add ( struct srd_decoder_inst di,
int  output_type,
const char *  output_id 
)
SRD_PRIV int srd_inst_start ( struct srd_decoder_inst di,
PyObject *  args 
)
SRD_PRIV int srd_log ( int  loglevel,
const char *  format,
  ... 
)

Definition at line 196 of file log.c.

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.