X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=libsigrokdecode.h.in;h=3eaace655d6e1cc28cafc1c10f8d730a747e7973;hp=877aeb15401d45e8f44e12f0098647fa16bb7963;hb=8915b34659332288aab38780d8f10d75c4c83e7f;hpb=c1f86f02a149f46609273e1bd5b42696d544727a diff --git a/libsigrokdecode.h.in b/libsigrokdecode.h.in index 877aeb1..3eaace6 100644 --- a/libsigrokdecode.h.in +++ b/libsigrokdecode.h.in @@ -30,6 +30,8 @@ extern "C" { #endif +struct srd_session; + /** * @file * @@ -79,11 +81,9 @@ extern "C" { #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 @@ -92,24 +92,35 @@ extern "C" { * 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. @@ -155,6 +166,10 @@ enum { #define SRD_MAX_NUM_PROBES 64 +enum { + SRD_CONF_SAMPLERATE = 10000, +}; + struct srd_decoder { /** The decoder ID. Must be non-NULL and unique for all decoders. */ char *id; @@ -219,14 +234,13 @@ struct srd_decoder_option { struct srd_decoder_inst { struct srd_decoder *decoder; + struct srd_session *sess; PyObject *py_inst; char *inst_id; GSList *pd_output; int dec_num_probes; int *dec_probemap; - int data_num_probes; int data_unitsize; - uint64_t data_samplerate; GSList *next_di; }; @@ -278,16 +292,22 @@ SRD_API int srd_inst_option_set(struct srd_decoder_inst *di, 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_metadata_set(struct srd_session *sess, int key, + GVariant *data); +SRD_API int srd_session_send(struct srd_session *sess, + uint64_t start_samplenum, uint64_t end_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 -------------------------------------------------------------*/ @@ -323,6 +343,11 @@ SRD_API int srd_lib_version_revision_get(void); 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