libsigrokdecode  0.4.0
sigrok protocol decoding library
Functions
Session handling

Starting and handling decoding sessions. More...

Functions

int srd_session_new (struct srd_session **sess)
 Create a decoding session. More...
 
int srd_session_start (struct srd_session *sess)
 Start a decoding session. More...
 
int srd_session_metadata_set (struct srd_session *sess, int key, GVariant *data)
 Set a metadata configuration key in a session. More...
 
int srd_session_send (struct srd_session *sess, uint64_t start_samplenum, uint64_t end_samplenum, const uint8_t *inbuf, uint64_t inbuflen, uint64_t unitsize)
 Send a chunk of logic sample data to a running decoder session. More...
 
int srd_session_destroy (struct srd_session *sess)
 Destroy a decoding session. More...
 
int srd_pd_output_callback_add (struct srd_session *sess, int output_type, srd_pd_output_callback cb, void *cb_data)
 Register/add a decoder output callback function. More...
 

Detailed Description

Starting and handling decoding sessions.

Function Documentation

int srd_pd_output_callback_add ( struct srd_session *  sess,
int  output_type,
srd_pd_output_callback  cb,
void *  cb_data 
)

Register/add a decoder output callback function.

The function will be called when a protocol decoder sends output back to the PD controller (except for Python objects, which only go up the stack).

Parameters
sessThe output session in which to register the callback.
output_typeThe output type this callback will receive. Only one callback per output type can be registered.
cbThe function to call. Must not be NULL.
cb_dataPrivate data for the callback function. Can be NULL.
Since
0.3.0

Definition at line 299 of file session.c.

References srd_pd_callback::cb, srd_pd_callback::cb_data, srd_pd_callback::output_type, SRD_ERR_ARG, and SRD_OK.

int srd_session_destroy ( struct srd_session *  sess)

Destroy a decoding session.

All decoder instances and output callbacks are properly released.

Parameters
sessThe session to be destroyed.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.3.0

Definition at line 262 of file session.c.

References SRD_ERR_ARG, and SRD_OK.

Referenced by srd_exit().

+ Here is the caller graph for this function:

int srd_session_metadata_set ( struct srd_session *  sess,
int  key,
GVariant *  data 
)

Set a metadata configuration key in a session.

Parameters
sessThe session to configure.
keyThe configuration key (SRD_CONF_*).
dataThe new value for the key, as a GVariant with GVariantType appropriate to that key. A floating reference can be passed in; its refcount will be sunk and unreferenced after use.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.3.0

Definition at line 161 of file session.c.

References SRD_CONF_SAMPLERATE, SRD_ERR_ARG, and SRD_OK.

int srd_session_new ( struct srd_session **  sess)

Create a decoding session.

A session holds all decoder instances, their stack relationships and output callbacks.

Parameters
sessA pointer which will hold a pointer to a newly initialized session on return.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.3.0

Definition at line 71 of file session.c.

References SRD_ERR_ARG, and SRD_OK.

int srd_session_send ( struct srd_session *  sess,
uint64_t  start_samplenum,
uint64_t  end_samplenum,
const uint8_t *  inbuf,
uint64_t  inbuflen,
uint64_t  unitsize 
)

Send a chunk of logic sample data to a running decoder session.

If no channel map has been set up, the logic samples must be arranged in channel order, in the least amount of space possible. The default channel set consists of all required channels + all optional channels.

The size of a sample in inbuf is 'unitsize' bytes. If no channel map has been configured, it is the minimum number of bytes needed to store the default channels.

Parameters
sessThe session to use.
start_samplenumThe sample number of the first sample in this chunk.
end_samplenumThe sample number of the last sample in this chunk.
inbufPointer to sample data.
inbuflenLength in bytes of the buffer.
unitsizeThe number of bytes per sample.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.4.0

Definition at line 230 of file session.c.

References SRD_ERR_ARG, and SRD_OK.

int srd_session_start ( struct srd_session *  sess)

Start a decoding session.

Decoders, instances and stack must have been prepared beforehand, and all SRD_CONF parameters set.

Parameters
sessThe session to start.
Returns
SRD_OK upon success, a (negative) error code otherwise.
Since
0.3.0

Definition at line 103 of file session.c.

References SRD_ERR, and SRD_OK.