return di;
}
+/**
+ * Stack a decoder instance on top of another.
+ *
+ * @param di_from The instance to move.
+ * @param di_to The instance on top of which di_from will be stacked.
+ *
+ * @return SRD_OK upon success, a (negative) error code otherwise.
+ */
SRD_API int srd_inst_stack(struct srd_decoder_inst *di_from,
struct srd_decoder_inst *di_to)
{
}
}
+/**
+ * Start a decoding session.
+ *
+ * Decoders, instances and stack must have been prepared beforehand.
+ *
+ * @param num_probes The number of probes which the incoming feed will contain.
+ * @param unitsize The number of bytes per sample in the incoming feed.
+ * @param The samplerate of the incoming feed.
+ *
+ * @return SRD_OK upon success, a (negative) error code otherwise.
+ */
SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate)
{
PyObject *args;
return ret;
}
-/* Feed logic samples to decoder session. */
-SRD_API int srd_session_feed(uint64_t start_samplenum, uint8_t * inbuf,
+/**
+ * Feed a chunk of logic sample data to a running decoder session.
+ *
+ * @param start_samplenum The sample number of the first sample in this chunk.
+ * @param inbuf Pointer to sample data.
+ * @param inbuf Length in bytes of the buffer.
+ *
+ * @return SRD_OK upon success, a (negative) error code otherwise.
+ */
+SRD_API int srd_session_feed(uint64_t start_samplenum, uint8_t *inbuf,
uint64_t inbuflen)
{
GSList *d;
return SRD_OK;
}
+/**
+ * Register 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).
+ *
+ * @param output_type The output type this callback will receive. Only one
+ * callback per output type can be registered.
+ * @param cb The function to call.
+ * @param user_data Unused.
+ */
SRD_API int srd_register_callback(int output_type,
srd_pd_output_callback_t cb, void *user_data)
{
return SRD_OK;
}
-SRD_API void *srd_find_callback(int output_type)
+SRD_PRIV void *srd_find_callback(int output_type)
{
GSList *l;
struct srd_pd_callback *pd_cb;
* Get the decoder with the specified ID.
*
* @param id The ID string of the decoder to return.
+ *
* @return The decoder with the specified ID, or NULL if not found.
*/
SRD_API struct srd_decoder *srd_get_decoder_by_id(const char *id)
return ret;
}
+/**
+ * Return a protocol decoder's docstring.
+ *
+ * @param dec The loaded protocol decoder.
+ *
+ * @return A newly allocated buffer containing the docstring. The caller should
+ * free this after use.
+ */
SRD_API char *srd_decoder_doc(struct srd_decoder *dec)
{
PyObject *py_str;
return SRD_OK;
}
+/**
+ * Load all protocol decoders libsigrokdecode knows about.
+ *
+ * @return SRD_OK upon success, a (negative) error code otherwise.
+ */
SRD_API int srd_load_all_decoders(void)
{
GDir *dir;
}
/**
- * TODO
+ * Unload all loaded protocol decoders.
+ *
+ * @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_unload_all_decoders(void)
{
*
* @param loglevel The loglevel to set (SRD_LOG_NONE, SRD_LOG_ERR,
* SRD_LOG_WARN, SRD_LOG_INFO, SRD_LOG_DBG, or SRD_LOG_SPEW).
+ *
* @return SRD_OK upon success, SRD_ERR_ARG upon invalid loglevel.
*/
SRD_API int srd_log_loglevel_set(int loglevel)
* In order to not use a logdomain, pass an empty string.
* The function makes its own copy of the input string, i.e.
* the caller does not need to keep it around.
+ *
* @return SRD_OK upon success, SRD_ERR_ARG upon invalid logdomain.
*/
SRD_API int srd_log_logdomain_set(const char *logdomain)
* and is never used or interpreted in any way. The pointer
* is allowed to be NULL if the caller doesn't need/want to
* pass any data.
+ *
* @return SRD_OK upon success, SRD_ERR_ARG upon invalid arguments.
*/
SRD_API int srd_log_handler_set(srd_log_handler_t handler, void *user_data)
*
* Additionally, the internal 'srd_log_handler_data' pointer is set to NULL.
*
- * @return SRD_OK upon success, a negative error code otherwise.
+ * @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_log_handler_set_default(void)
{
SRD_PRIV int pd_add(struct srd_decoder_inst *di, int output_type,
char *output_id);
+/*--- decoder.c -------------------------------------------------------------*/
+SRD_PRIV void *srd_find_callback(int output_type);
+
/*--- exception.c -----------------------------------------------------------*/
SRD_PRIV void catch_exception(const char *format, ...);
SRD_API struct srd_decoder_inst *get_di_by_decobject(void *decobject);
SRD_API int srd_register_callback(int output_type,
srd_pd_output_callback_t cb, void *user_data);
-SRD_API void *srd_find_callback(int output_type);
/*--- decoder.c -------------------------------------------------------------*/
logic->inbuf + logic->itercnt * logic->di->data_unitsize,
logic->di->data_unitsize);
for (i = 0; i < logic->di->dec_num_probes; i++)
- probe_samples[i] =
- sample & (1 << logic->di->dec_probemap[i]) ? 1 : 0;
+ probe_samples[i] = sample & (1 << logic->di->dec_probemap[i]) ? 1 : 0;
/* Prepare the next samplenum/sample list in this iteration. */
py_samplenum =