libsigrokdecode  0.3.0
sigrok protocol decoding library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Decoder instances

Decoder instance handling. More...

Functions

int srd_inst_option_set (struct srd_decoder_inst *di, GHashTable *options)
 Set one or more options in a decoder instance. More...
 
int srd_inst_channel_set_all (struct srd_decoder_inst *di, GHashTable *new_channels, int unit_size)
 Set all channels in a decoder instance. More...
 
struct srd_decoder_instsrd_inst_new (struct srd_session *sess, const char *decoder_id, GHashTable *options)
 Create a new protocol decoder instance. More...
 
int srd_inst_stack (struct srd_session *sess, struct srd_decoder_inst *di_bottom, struct srd_decoder_inst *di_top)
 Stack a decoder instance on top of another. More...
 
struct srd_decoder_instsrd_inst_find_by_id (struct srd_session *sess, const char *inst_id)
 Find a decoder instance by its instance ID. More...
 

Detailed Description

Decoder instance handling.

Function Documentation

int srd_inst_channel_set_all ( struct srd_decoder_inst di,
GHashTable *  new_channels,
int  unit_size 
)

Set all channels in a decoder instance.

This function sets all channels for the specified decoder instance, i.e., it overwrites any channels that were already defined (if any).

Parameters
diDecoder instance.
new_channelsA GHashTable of channels to set. Key is channel name, value is the channel number. Samples passed to this instance will be arranged in this order.
unit_sizeNumber of bytes per sample in the data stream to be passed to the decoder. The highest channel index specified in the channel map must lie within a sample unit.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.3.0

Definition at line 197 of file instance.c.

References srd_decoder::channels, srd_decoder_inst::data_unitsize, srd_decoder_inst::dec_channelmap, srd_decoder_inst::dec_num_channels, srd_decoder_inst::decoder, srd_channel::id, srd_decoder_inst::inst_id, srd_decoder::name, srd_decoder::opt_channels, srd_channel::order, SRD_ERR, SRD_ERR_ARG, SRD_ERR_MALLOC, and SRD_OK.

struct srd_decoder_inst* srd_inst_find_by_id ( struct srd_session *  sess,
const char *  inst_id 
)

Find a decoder instance by its instance ID.

Only the bottom level of instances are searched – instances already stacked on top of another one will not be found.

Parameters
sessThe session holding the protocol decoder instance.
inst_idThe instance ID to be found.
Returns
Pointer to struct srd_decoder_inst, or NULL if not found.
Since
0.3.0

Definition at line 442 of file instance.c.

References srd_decoder_inst::inst_id, and SRD_OK.

struct srd_decoder_inst* srd_inst_new ( struct srd_session *  sess,
const char *  decoder_id,
GHashTable *  options 
)

Create a new protocol decoder instance.

Parameters
sessThe session holding the protocol decoder instance.
decoder_idDecoder 'id' field.
optionsGHashtable of options which override the defaults set in the decoder class. May be NULL.
Returns
Pointer to a newly allocated struct srd_decoder_inst, or NULL in case of failure.
Since
0.3.0

Definition at line 306 of file instance.c.

References srd_decoder_inst::channel_samples, srd_decoder::channels, srd_decoder_inst::data_unitsize, srd_decoder_inst::dec_channelmap, srd_decoder_inst::dec_num_channels, srd_decoder_inst::decoder, srd_decoder_inst::inst_id, srd_decoder::opt_channels, srd_decoder::py_dec, srd_decoder_inst::py_inst, srd_decoder_inst::sess, srd_decoder_get_by_id(), srd_inst_option_set(), and SRD_OK.

+ Here is the call graph for this function:

int srd_inst_option_set ( struct srd_decoder_inst di,
GHashTable *  options 
)

Set one or more options in a decoder instance.

Handled options are removed from the hash.

Parameters
diDecoder instance.
optionsA GHashTable of options to set.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.1.0

Definition at line 64 of file instance.c.

References srd_decoder_inst::decoder, srd_decoder_option::def, srd_decoder_option::id, srd_decoder_inst::inst_id, srd_decoder::options, srd_decoder::py_dec, srd_decoder_inst::py_inst, SRD_ERR_ARG, SRD_ERR_PYTHON, and SRD_OK.

Referenced by srd_inst_new().

+ Here is the caller graph for this function:

int srd_inst_stack ( struct srd_session *  sess,
struct srd_decoder_inst di_bottom,
struct srd_decoder_inst di_top 
)

Stack a decoder instance on top of another.

Parameters
sessThe session holding the protocol decoder instances.
di_bottomThe instance on top of which di_top will be stacked.
di_topThe instance to go on top.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.3.0

Definition at line 401 of file instance.c.

References srd_decoder_inst::inst_id, srd_decoder_inst::next_di, SRD_ERR_ARG, and SRD_OK.