X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=include%2Flibsigrok%2Fproto.h;h=2c3b255972d7f2a5655f8c5055c4db438b82b834;hp=c0d40b94679068a311b4b4f65e5a3faeeecbfa26;hb=HEAD;hpb=8ea0c90268574ccb4ff43344f7bb08f15c776a82 diff --git a/include/libsigrok/proto.h b/include/libsigrok/proto.h index c0d40b94..2c3b2559 100644 --- a/include/libsigrok/proto.h +++ b/include/libsigrok/proto.h @@ -30,17 +30,34 @@ SR_API int sr_analog_to_float(const struct sr_datafeed_analog *analog, float *buf); -SR_API int sr_analog_float_to_string(float value, unsigned int digits, - char **result); +SR_API const char *sr_analog_si_prefix(float *value, int *digits); +SR_API gboolean sr_analog_si_prefix_friendly(enum sr_unit unit); SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog *analog, char **result); SR_API void sr_rational_set(struct sr_rational *r, int64_t p, uint64_t q); +SR_API int sr_rational_eq(const struct sr_rational *a, const struct sr_rational *b); +SR_API int sr_rational_mult(struct sr_rational *res, const struct sr_rational *a, + const struct sr_rational *b); +SR_API int sr_rational_div(struct sr_rational *res, const struct sr_rational *num, + const struct sr_rational *div); /*--- backend.c -------------------------------------------------------------*/ SR_API int sr_init(struct sr_context **ctx); SR_API int sr_exit(struct sr_context *ctx); +SR_API GSList *sr_buildinfo_libs_get(void); +SR_API char *sr_buildinfo_host_get(void); +SR_API char *sr_buildinfo_scpi_backends_get(void); + +/*--- conversion.c ----------------------------------------------------------*/ + +SR_API int sr_a2l_threshold(const struct sr_datafeed_analog *analog, + float threshold, uint8_t *output, uint64_t count); +SR_API int sr_a2l_schmitt_trigger(const struct sr_datafeed_analog *analog, + float lo_thr, float hi_thr, uint8_t *state, uint8_t *output, + uint64_t count); + /*--- log.c -----------------------------------------------------------------*/ typedef int (*sr_log_callback)(void *cb_data, int loglevel, @@ -50,6 +67,7 @@ SR_API int sr_log_loglevel_set(int loglevel); SR_API int sr_log_loglevel_get(void); SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data); SR_API int sr_log_callback_set_default(void); +SR_API int sr_log_callback_get(sr_log_callback *cb, void **cb_data); /*--- device.c --------------------------------------------------------------*/ @@ -58,6 +76,10 @@ SR_API int sr_dev_channel_name_set(struct sr_channel *channel, SR_API int sr_dev_channel_enable(struct sr_channel *channel, gboolean state); SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key); +SR_API int sr_dev_config_capabilities_list(const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg, int key); +SR_API GArray *sr_dev_options(const struct sr_dev_driver *driver, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg); SR_API GSList *sr_dev_list(const struct sr_dev_driver *driver); SR_API int sr_dev_clear(const struct sr_dev_driver *driver); SR_API int sr_dev_open(struct sr_dev_inst *sdi); @@ -81,6 +103,7 @@ SR_API int sr_dev_inst_channel_add(struct sr_dev_inst *sdi, int index, int type, SR_API struct sr_dev_driver **sr_driver_list(const struct sr_context *ctx); SR_API int sr_driver_init(struct sr_context *ctx, struct sr_dev_driver *driver); +SR_API GArray *sr_driver_scan_options_list(const struct sr_dev_driver *driver); SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options); SR_API int sr_config_get(const struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, @@ -113,6 +136,8 @@ SR_API int sr_session_destroy(struct sr_session *session); SR_API int sr_session_dev_remove_all(struct sr_session *session); SR_API int sr_session_dev_add(struct sr_session *session, struct sr_dev_inst *sdi); +SR_API int sr_session_dev_remove(struct sr_session *session, + struct sr_dev_inst *sdi); SR_API int sr_session_dev_list(struct sr_session *session, GSList **devlist); SR_API int sr_session_trigger_set(struct sr_session *session, struct sr_trigger *trig); @@ -129,6 +154,10 @@ SR_API int sr_session_is_running(struct sr_session *session); SR_API int sr_session_stopped_callback_set(struct sr_session *session, sr_session_stopped_callback cb, void *cb_data); +SR_API int sr_packet_copy(const struct sr_datafeed_packet *packet, + struct sr_datafeed_packet **copy); +SR_API void sr_packet_free(struct sr_datafeed_packet *packet); + /*--- input/input.c ---------------------------------------------------------*/ SR_API const struct sr_input_module **sr_input_list(void); @@ -137,18 +166,18 @@ SR_API const char *sr_input_name_get(const struct sr_input_module *imod); SR_API const char *sr_input_description_get(const struct sr_input_module *imod); SR_API const char *const *sr_input_extensions_get( const struct sr_input_module *imod); -SR_API const struct sr_input_module *sr_input_find(char *id); +SR_API const struct sr_input_module *sr_input_find(const char *id); SR_API const struct sr_option **sr_input_options_get(const struct sr_input_module *imod); -SR_API gboolean sr_output_test_flag(const struct sr_output_module *omod, - uint64_t flag); SR_API void sr_input_options_free(const struct sr_option **options); SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, GHashTable *options); SR_API int sr_input_scan_buffer(GString *buf, const struct sr_input **in); SR_API int sr_input_scan_file(const char *filename, const struct sr_input **in); +SR_API const struct sr_input_module *sr_input_module_get(const struct sr_input *in); SR_API struct sr_dev_inst *sr_input_dev_inst_get(const struct sr_input *in); SR_API int sr_input_send(const struct sr_input *in, GString *buf); SR_API int sr_input_end(const struct sr_input *in); +SR_API int sr_input_reset(const struct sr_input *in); SR_API void sr_input_free(const struct sr_input *in); /*--- output/output.c -------------------------------------------------------*/ @@ -165,6 +194,8 @@ SR_API void sr_output_options_free(const struct sr_option **opts); SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod, GHashTable *params, const struct sr_dev_inst *sdi, const char *filename); +SR_API gboolean sr_output_test_flag(const struct sr_output_module *omod, + uint64_t flag); SR_API int sr_output_send(const struct sr_output *o, const struct sr_datafeed_packet *packet, GString **out); SR_API int sr_output_free(const struct sr_output *o); @@ -201,9 +232,11 @@ typedef int (*sr_resource_open_callback)(struct sr_resource *res, const char *name, void *cb_data); typedef int (*sr_resource_close_callback)(struct sr_resource *res, void *cb_data); -typedef ssize_t (*sr_resource_read_callback)(const struct sr_resource *res, +typedef gssize (*sr_resource_read_callback)(const struct sr_resource *res, void *buf, size_t count, void *cb_data); +SR_API GSList *sr_resourcepaths_get(int res_type); + SR_API int sr_resource_set_hooks(struct sr_context *ctx, sr_resource_open_callback open_cb, sr_resource_close_callback close_cb, @@ -213,13 +246,29 @@ SR_API int sr_resource_set_hooks(struct sr_context *ctx, SR_API char *sr_si_string_u64(uint64_t x, const char *unit); SR_API char *sr_samplerate_string(uint64_t samplerate); -SR_API char *sr_period_string(uint64_t frequency); +SR_API char *sr_period_string(uint64_t v_p, uint64_t v_q); SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q); SR_API int sr_parse_sizestring(const char *sizestring, uint64_t *size); SR_API uint64_t sr_parse_timestring(const char *timestring); SR_API gboolean sr_parse_boolstring(const char *boolstring); SR_API int sr_parse_period(const char *periodstr, uint64_t *p, uint64_t *q); SR_API int sr_parse_voltage(const char *voltstr, uint64_t *p, uint64_t *q); +SR_API char **sr_parse_probe_names(const char *spec, + const char **dflt_names, size_t dflt_count, + size_t max_count, size_t *ret_count); +SR_API void sr_free_probe_names(char **names); +SR_API int sr_sprintf_ascii(char *buf, const char *format, ...); +SR_API int sr_vsprintf_ascii(char *buf, const char *format, va_list args); +SR_API int sr_snprintf_ascii(char *buf, size_t buf_size, + const char *format, ...); +SR_API int sr_vsnprintf_ascii(char *buf, size_t buf_size, + const char *format, va_list args); +SR_API int sr_parse_rational(const char *str, struct sr_rational *ret); +SR_API char *sr_text_trim_spaces(char *s); +SR_API char *sr_text_next_line(char *s, size_t l, char **next, size_t *taken); +SR_API char *sr_text_next_word(char *s, char **next); + +SR_API int sr_next_power_of_two(size_t value, size_t *bits, size_t *power); /*--- version.c -------------------------------------------------------------*/