SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
uint8_t *buf, size_t *buflen,
packet_length_t get_packet_size,
- packet_valid_t is_valid,
+ packet_valid_callback is_valid,
uint64_t timeout_ms, int baudrate)
{
int64_t start, time, byte_delay_us;
SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
uint8_t *buf, size_t *buflen,
packet_length_t get_packet_size,
- packet_valid_t is_valid,
+ packet_valid_callback is_valid,
uint64_t timeout_ms, int baudrate);
#endif
* SR_ERR_MALLOC upon memory allocation errors.
*/
SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data)
+ int timeout, sr_receive_data_callback cb, void *cb_data)
{
return scpi->source_add(scpi->priv, events, timeout, cb, cb_data);
}
}
static int scpi_serial_source_add(void *priv, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
struct scpi_serial *sscpi = priv;
struct sr_serial_dev_inst *serial = sscpi->serial;
}
static int scpi_tcp_source_add(void *priv, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
struct scpi_tcp *tcp = priv;
}
static int scpi_usbtmc_source_add(void *priv, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
struct usbtmc_scpi *uscpi = priv;
struct sr_usbtmc_dev_inst *usbtmc = uscpi->usbtmc;
}
static int scpi_usbtmc_libusb_source_add(void *priv, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
struct scpi_usbtmc_libusb *uscpi = priv;
(void)events;
}
static int scpi_visa_source_add(void *priv, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
(void) priv;
}
static int scpi_vxi_source_add(void *priv, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
(void)priv;
*/
SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
uint8_t *buf, size_t *buflen,
- size_t packet_size, packet_valid_t is_valid,
+ size_t packet_size,
+ packet_valid_callback is_valid,
uint64_t timeout_ms, int baudrate)
{
uint64_t start, time, byte_delay_us;
#endif
SR_PRIV int serial_source_add(struct sr_serial_dev_inst *serial, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data)
+ int timeout, sr_receive_data_callback cb, void *cb_data)
{
enum sp_event mask = 0;
unsigned int i;
#endif
SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
if (ctx->usb_source_present) {
sr_err("A USB event source is already present.");
* @see sr_session_source_add()
*/
SR_PRIV int sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
return sr_session_source_add(fd, events, timeout, cb, cb_data);
}
GMutex usb_mutex;
HANDLE usb_event;
GPollFD usb_pollfd;
- sr_receive_data_callback_t usb_cb;
+ sr_receive_data_callback usb_cb;
void *usb_cb_data;
#endif
#endif
SR_PRIV void sr_config_free(struct sr_config *src);
SR_PRIV int sr_source_remove(int fd);
SR_PRIV int sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data);
+ sr_receive_data_callback cb, void *cb_data);
/*--- session.c -------------------------------------------------------------*/
/*--- std.c -----------------------------------------------------------------*/
-typedef int (*dev_close_t)(struct sr_dev_inst *sdi);
-typedef void (*std_dev_clear_t)(void *priv);
+typedef int (*dev_close_callback)(struct sr_dev_inst *sdi);
+typedef void (*std_dev_clear_callback)(void *priv);
SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di,
const char *prefix);
#ifdef HAVE_LIBSERIALPORT
SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi);
SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,
- void *cb_data, dev_close_t dev_close_fn,
+ void *cb_data, dev_close_callback dev_close_fn,
struct sr_serial_dev_inst *serial, const char *prefix);
#endif
SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
const char *prefix);
SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
- std_dev_clear_t clear_private);
+ std_dev_clear_callback clear_private);
SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi);
/*--- strutil.c -------------------------------------------------------------*/
SERIAL_NONBLOCK = 4,
};
-typedef gboolean (*packet_valid_t)(const uint8_t *buf);
+typedef gboolean (*packet_valid_callback)(const uint8_t *buf);
SR_PRIV int serial_open(struct sr_serial_dev_inst *serial, int flags);
SR_PRIV int serial_close(struct sr_serial_dev_inst *serial);
int *buflen, gint64 timeout_ms);
SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
uint8_t *buf, size_t *buflen,
- size_t packet_size, packet_valid_t is_valid,
+ size_t packet_size,
+ packet_valid_callback is_valid,
uint64_t timeout_ms, int baudrate);
SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device,
const char **serial_options);
SR_PRIV int serial_source_add(struct sr_serial_dev_inst *serial, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data);
+ int timeout, sr_receive_data_callback cb, void *cb_data);
SR_PRIV int serial_source_remove(struct sr_serial_dev_inst *serial);
SR_PRIV GSList *sr_serial_find_usb(uint16_t vendor_id, uint16_t product_id);
#endif
SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn);
SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb);
SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout,
- sr_receive_data_callback_t cb, void *cb_data);
+ sr_receive_data_callback cb, void *cb_data);
SR_PRIV int usb_source_remove(struct sr_context *ctx);
#endif
const char *resource, char **params, const char *serialcomm);
int (*open)(void *priv);
int (*source_add)(void *priv, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data);
+ int timeout, sr_receive_data_callback cb, void *cb_data);
int (*source_remove)(void *priv);
int (*send)(void *priv, const char *command);
int (*read_begin)(void *priv);
const char *resource, const char *serialcomm);
SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi);
SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data);
+ int timeout, sr_receive_data_callback cb, void *cb_data);
SR_PRIV int sr_scpi_source_remove(struct sr_scpi_dev_inst *scpi);
SR_PRIV int sr_scpi_send(struct sr_scpi_dev_inst *scpi,
const char *format, ...);
#endif
/** Type definition for callback function for data reception. */
-typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *cb_data);
+typedef int (*sr_receive_data_callback)(int fd, int revents, void *cb_data);
/** Data types used by sr_config_info(). */
enum sr_datatype {
va_list args);
/* Pointer to the currently selected log callback. Default: sr_logv(). */
-static sr_log_callback_t sr_log_callback = sr_logv;
+static sr_log_callback sr_log_cb = sr_logv;
/*
* Pointer to private data that can be passed to the log callback.
* This can be used (for example) by C++ GUIs to pass a "this" pointer.
*/
-static void *sr_log_callback_data = NULL;
+static void *sr_log_cb_data = NULL;
/* Log domain (a short string that is used as prefix for all messages). */
/** @cond PRIVATE */
*
* @since 0.1.0
*/
-SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data)
+SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data)
{
if (!cb) {
sr_err("log: %s: cb was NULL", __func__);
/* Note: 'cb_data' is allowed to be NULL. */
- sr_log_callback = cb;
- sr_log_callback_data = cb_data;
+ sr_log_cb = cb;
+ sr_log_cb_data = cb_data;
return SR_OK;
}
/**
* Set the libsigrok log callback to the default built-in one.
*
- * Additionally, the internal 'sr_log_callback_data' pointer is set to NULL.
+ * Additionally, the internal 'sr_log_cb_data' pointer is set to NULL.
*
* @return SR_OK upon success, a negative error code otherwise.
*
* Note: No log output in this function, as it should safely work
* even if the currently set log callback is buggy/broken.
*/
- sr_log_callback = sr_logv;
- sr_log_callback_data = NULL;
+ sr_log_cb = sr_logv;
+ sr_log_cb_data = NULL;
return SR_OK;
}
va_list args;
va_start(args, format);
- ret = sr_log_callback(sr_log_callback_data, loglevel, format, args);
+ ret = sr_log_cb(sr_log_cb_data, loglevel, format, args);
va_end(args);
return ret;
va_list args;
va_start(args, format);
- ret = sr_log_callback(sr_log_callback_data, SR_LOG_SPEW, format, args);
+ ret = sr_log_cb(sr_log_cb_data, SR_LOG_SPEW, format, args);
va_end(args);
return ret;
va_list args;
va_start(args, format);
- ret = sr_log_callback(sr_log_callback_data, SR_LOG_DBG, format, args);
+ ret = sr_log_cb(sr_log_cb_data, SR_LOG_DBG, format, args);
va_end(args);
return ret;
va_list args;
va_start(args, format);
- ret = sr_log_callback(sr_log_callback_data, SR_LOG_INFO, format, args);
+ ret = sr_log_cb(sr_log_cb_data, SR_LOG_INFO, format, args);
va_end(args);
return ret;
va_list args;
va_start(args, format);
- ret = sr_log_callback(sr_log_callback_data, SR_LOG_WARN, format, args);
+ ret = sr_log_cb(sr_log_cb_data, SR_LOG_WARN, format, args);
va_end(args);
return ret;
va_list args;
va_start(args, format);
- ret = sr_log_callback(sr_log_callback_data, SR_LOG_ERR, format, args);
+ ret = sr_log_cb(sr_log_cb_data, SR_LOG_ERR, format, args);
va_end(args);
return ret;
/*--- log.c -----------------------------------------------------------------*/
-typedef int (*sr_log_callback_t)(void *cb_data, int loglevel,
- const char *format, va_list args);
+typedef int (*sr_log_callback)(void *cb_data, int loglevel,
+ const char *format, va_list args);
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_t cb, void *cb_data);
+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_logdomain_set(const char *logdomain);
SR_API char *sr_log_logdomain_get(void);
/*--- session.c -------------------------------------------------------------*/
-typedef void (*sr_datafeed_callback_t)(const struct sr_dev_inst *sdi,
+typedef void (*sr_datafeed_callback)(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *packet, void *cb_data);
/* Session setup */
/* Datafeed setup */
SR_API int sr_session_datafeed_callback_remove_all(void);
-SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb,
+SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback cb,
void *cb_data);
/* Session control */
SR_API int sr_session_append(const char *filename, unsigned char *buf,
int unitsize, int units);
SR_API int sr_session_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data);
+ sr_receive_data_callback cb, void *cb_data);
SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout,
- sr_receive_data_callback_t cb, void *cb_data);
+ sr_receive_data_callback cb, void *cb_data);
SR_API int sr_session_source_add_channel(GIOChannel *channel, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data);
+ int timeout, sr_receive_data_callback cb, void *cb_data);
SR_API int sr_session_source_remove(int fd);
SR_API int sr_session_source_remove_pollfd(GPollFD *pollfd);
SR_API int sr_session_source_remove_channel(GIOChannel *channel);
struct source {
int timeout;
- sr_receive_data_callback_t cb;
+ sr_receive_data_callback cb;
void *cb_data;
/* This is used to keep track of the object (fd, pollfd or channel) which is
};
struct datafeed_callback {
- sr_datafeed_callback_t cb;
+ sr_datafeed_callback cb;
void *cb_data;
};
* @retval SR_OK Success.
* @retval SR_ERR_BUG No session exists.
*/
-SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb, void *cb_data)
+SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback cb, void *cb_data)
{
struct datafeed_callback *cb_struct;
* @retval SR_ERR_MALLOC Memory allocation error.
*/
static int _sr_session_source_add(GPollFD *pollfd, int timeout,
- sr_receive_data_callback_t cb, void *cb_data, gintptr poll_object)
+ sr_receive_data_callback cb, void *cb_data, gintptr poll_object)
{
struct source *new_sources, *s;
GPollFD *new_pollfds;
* @retval SR_ERR_MALLOC Memory allocation error.
*/
SR_API int sr_session_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
GPollFD p;
* @retval SR_ERR_MALLOC Memory allocation error.
*/
SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout,
- sr_receive_data_callback_t cb, void *cb_data)
+ sr_receive_data_callback cb, void *cb_data)
{
return _sr_session_source_add(pollfd, timeout, cb,
cb_data, (gintptr)pollfd);
* @retval SR_ERR_MALLOC Memory allocation error.
*/
SR_API int sr_session_source_add_channel(GIOChannel *channel, int events,
- int timeout, sr_receive_data_callback_t cb, void *cb_data)
+ int timeout, sr_receive_data_callback cb, void *cb_data)
{
GPollFD p;
* @retval SR_ERR Other errors.
*/
SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,
- void *cb_data, dev_close_t dev_close_fn,
+ void *cb_data, dev_close_callback dev_close_fn,
struct sr_serial_dev_inst *serial, const char *prefix)
{
int ret;
* @return SR_OK on success.
*/
SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
- std_dev_clear_t clear_private)
+ std_dev_clear_callback clear_private)
{
struct drv_context *drvc;
struct sr_dev_inst *sdi;