![]() |
libsigrokdecode
0.5.0
sigrok protocol decoding library
|
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 abs_start_samplenum, uint64_t abs_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... | |
Starting and handling decoding sessions.
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).
sess | The output session in which to register the callback. |
output_type | The output type this callback will receive. Only one callback per output type can be registered. |
cb | The function to call. Must not be NULL. |
cb_data | Private data for the callback function. Can be NULL. |
int srd_session_destroy | ( | struct srd_session * | sess | ) |
Destroy a decoding session.
All decoder instances and output callbacks are properly released.
sess | The session to be destroyed. |
Definition at line 306 of file session.c.
References srd_decoder_inst::sess, and SRD_ERR_ARG.
Referenced by srd_exit().
int srd_session_metadata_set | ( | struct srd_session * | sess, |
int | key, | ||
GVariant * | data | ||
) |
Set a metadata configuration key in a session.
sess | The session to configure. |
key | The configuration key (SRD_CONF_*). |
data | The 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. |
int srd_session_new | ( | struct srd_session ** | sess | ) |
Create a decoding session.
A session holds all decoder instances, their stack relationships and output callbacks.
sess | A pointer which will hold a pointer to a newly initialized session on return. |
Definition at line 71 of file session.c.
References srd_decoder_inst::sess, SRD_ERR_ARG, and SRD_OK.
int srd_session_send | ( | struct srd_session * | sess, |
uint64_t | abs_start_samplenum, | ||
uint64_t | abs_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.
The calls to this function must provide the samples that shall be used by the protocol decoder
The start- and end-sample numbers are absolute sample numbers (relative to the start of the whole capture/file/stream), i.e. they are not relative sample numbers within the chunk specified by 'inbuf' and 'inbuflen'.
Correct example (4096 samples total, 4 chunks @ 1024 samples each): srd_session_send(s, 0, 1023, inbuf, 1024, 1); srd_session_send(s, 1024, 2047, inbuf, 1024, 1); srd_session_send(s, 2048, 3071, inbuf, 1024, 1); srd_session_send(s, 3072, 4095, inbuf, 1024, 1);
The chunk size ('inbuflen') can be arbitrary and can differ between calls.
Correct example (4096 samples total, 7 chunks @ various samples each): srd_session_send(s, 0, 1023, inbuf, 1024, 1); srd_session_send(s, 1024, 1123, inbuf, 100, 1); srd_session_send(s, 1124, 1423, inbuf, 300, 1); srd_session_send(s, 1424, 1642, inbuf, 219, 1); srd_session_send(s, 1643, 2047, inbuf, 405, 1); srd_session_send(s, 2048, 3071, inbuf, 1024, 1); srd_session_send(s, 3072, 4095, inbuf, 1024, 1);
INCORRECT example (4096 samples total, 4 chunks @ 1024 samples each, but the start- and end-samplenumbers are not absolute): srd_session_send(s, 0, 1023, inbuf, 1024, 1); srd_session_send(s, 0, 1023, inbuf, 1024, 1); srd_session_send(s, 0, 1023, inbuf, 1024, 1); srd_session_send(s, 0, 1023, inbuf, 1024, 1);
sess | The session to use. Must not be NULL. |
abs_start_samplenum | The absolute starting sample number for the buffer's sample set, relative to the start of capture. |
abs_end_samplenum | The absolute ending sample number for the buffer's sample set, relative to the start of capture. |
inbuf | Pointer to sample data. Must not be NULL. |
inbuflen | Length in bytes of the buffer. Must be > 0. |
unitsize | The number of bytes per sample. Must be > 0. |
int srd_session_start | ( | struct srd_session * | sess | ) |