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.
*/
enum {
SRD_OUTPUT_ANN,
- SRD_OUTPUT_PROTO,
+ SRD_OUTPUT_PYTHON,
SRD_OUTPUT_BINARY,
+ SRD_OUTPUT_META,
};
#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;
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;
};
int output_type;
struct srd_decoder_inst *di;
char *proto_id;
+ /* Only used for OUTPUT_META. */
+ const GVariantType *meta_type;
+ char *meta_name;
+ char *meta_descr;
};
struct srd_proto_data {
uint64_t start_sample;
uint64_t end_sample;
struct srd_pd_output *pdo;
- int ann_format;
void *data;
};
+struct srd_proto_data_annotation {
+ int ann_format;
+ char **ann_text;
+};
typedef void (*srd_pd_output_callback_t)(struct srd_proto_data *pdata,
void *cb_data);
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 -------------------------------------------------------------*/