extern "C" {
#endif
+struct srd_session;
+
/**
* @file
*
#define SRD_LIB_VERSION_STRING "@SRD_LIB_VERSION@"
/*
- * Status/error codes returned by libsigrokdecode functions.
- *
* All possible return codes of libsigrokdecode functions must be listed here.
* Functions should never return hardcoded numbers as status, but rather
- * use these #defines instead. All error codes are negative numbers.
+ * use these enum values. All error codes are negative numbers.
*
* The error codes are globally unique in libsigrokdecode, i.e. if one of the
* libsigrokdecode functions returns a "malloc error" it must be exactly the
* same return code.
*
* Also, for compatibility reasons, no defined return codes are ever removed
- * or reused for different #defines later. You can only add new #defines and
+ * or reused for different errors later. You can only add new entries and
* return codes, but never remove or redefine existing ones.
*/
-#define SRD_OK 0 /**< No error */
-#define SRD_ERR -1 /**< Generic/unspecified error */
-#define SRD_ERR_MALLOC -2 /**< Malloc/calloc/realloc error */
-#define SRD_ERR_ARG -3 /**< Function argument error */
-#define SRD_ERR_BUG -4 /**< Errors hinting at internal bugs */
-#define SRD_ERR_PYTHON -5 /**< Python C API error */
-#define SRD_ERR_DECODERS_DIR -6 /**< Protocol decoder path invalid */
+
+/** Status/error codes returned by libsigrokdecode functions. */
+enum {
+ SRD_OK = 0, /**< No error */
+ SRD_ERR = -1, /**< Generic/unspecified error */
+ SRD_ERR_MALLOC = -2, /**< Malloc/calloc/realloc error */
+ SRD_ERR_ARG = -3, /**< Function argument error */
+ SRD_ERR_BUG = -4, /**< Errors hinting at internal bugs */
+ SRD_ERR_PYTHON = -5, /**< Python C API error */
+ SRD_ERR_DECODERS_DIR = -6, /**< Protocol decoder path invalid */
+
+ /*
+ * Note: When adding entries here, don't forget to also update the
+ * srd_strerror() and srd_strerror_name() functions in error.c.
+ */
+};
/* libsigrokdecode loglevels. */
-#define SRD_LOG_NONE 0 /**< Output no messages at all. */
-#define SRD_LOG_ERR 1 /**< Output error messages. */
-#define SRD_LOG_WARN 2 /**< Output warnings. */
-#define SRD_LOG_INFO 3 /**< Output informational messages. */
-#define SRD_LOG_DBG 4 /**< Output debug messages. */
-#define SRD_LOG_SPEW 5 /**< Output very noisy debug messages. */
+enum {
+ SRD_LOG_NONE = 0, /**< Output no messages at all. */
+ SRD_LOG_ERR = 1, /**< Output error messages. */
+ SRD_LOG_WARN = 2, /**< Output warnings. */
+ SRD_LOG_INFO = 3, /**< Output informational messages. */
+ SRD_LOG_DBG = 4, /**< Output debug messages. */
+ SRD_LOG_SPEW = 5, /**< Output very noisy debug messages. */
+};
/*
* Use SRD_API to mark public API symbols, and SRD_PRIV for private symbols.
#define SRD_MAX_NUM_PROBES 64
+enum {
+ SRD_CONF_NUM_PROBES = 10000,
+ SRD_CONF_UNITSIZE,
+ SRD_CONF_SAMPLERATE,
+};
+
struct srd_decoder {
/** The decoder ID. Must be non-NULL and unique for all decoders. */
char *id;
struct srd_decoder_inst {
struct srd_decoder *decoder;
+ struct srd_session *sess;
PyObject *py_inst;
char *inst_id;
GSList *pd_output;
GHashTable *options);
SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
GHashTable *probes);
-SRD_API struct srd_decoder_inst *srd_inst_new(const char *id,
- GHashTable *options);
-SRD_API int srd_inst_stack(struct srd_decoder_inst *di_from,
- struct srd_decoder_inst *di_to);
-SRD_API struct srd_decoder_inst *srd_inst_find_by_id(const char *inst_id);
-SRD_API int srd_session_start(int num_probes, int unitsize, uint64_t samplerate);
-SRD_API int srd_session_send(uint64_t start_samplenum, const uint8_t *inbuf,
- uint64_t inbuflen);
-SRD_API int srd_pd_output_callback_add(int output_type,
- srd_pd_output_callback_t cb, void *cb_data);
+SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess,
+ const char *id, GHashTable *options);
+SRD_API int srd_inst_stack(struct srd_session *sess,
+ struct srd_decoder_inst *di_from, struct srd_decoder_inst *di_to);
+SRD_API struct srd_decoder_inst *srd_inst_find_by_id(struct srd_session *sess,
+ const char *inst_id);
+SRD_API int srd_session_new(struct srd_session **sess);
+SRD_API int srd_session_start(struct srd_session *sess);
+SRD_API int srd_session_config_set(struct srd_session *sess, int key,
+ GVariant *data);
+SRD_API int srd_session_send(struct srd_session *sess,
+ uint64_t start_samplenum, const uint8_t *inbuf, uint64_t inbuflen);
+SRD_API int srd_session_destroy(struct srd_session *sess);
+SRD_API int srd_pd_output_callback_add(struct srd_session *sess,
+ int output_type, srd_pd_output_callback_t cb, void *cb_data);
/*--- decoder.c -------------------------------------------------------------*/
SRD_API int srd_lib_version_age_get(void);
SRD_API const char *srd_lib_version_string_get(void);
+/*--- error.c ---------------------------------------------------------------*/
+
+SRD_API const char *srd_strerror(int error_code);
+SRD_API const char *srd_strerror_name(int error_code);
+
#ifdef __cplusplus
}
#endif