}
}
-static int receive_data(int fd, int revents, void *user_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
- struct sr_dev_inst *sdi = user_data;
+ struct sr_dev_inst *sdi = cb_data;
struct context *ctx = sdi->priv;
struct sr_datafeed_packet packet;
struct sr_analog_sample *sample;
packet.length = count * sample_size;
packet.unitsize = sample_size;
packet.payload = outb;
- sr_session_send(user_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(outb);
ctx->limit_samples -= count;
} while (ctx->limit_samples > 0);
packet.type = SR_DF_END;
- sr_session_send(user_data, &packet);
+ sr_session_send(sdi, &packet);
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
{
struct sr_dev_inst *sdi;
struct context *ctx;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
{
/* Avoid compiler warnings. */
dev_index = dev_index;
"asix-sigma-phasor.fw", /* Frequency counter */
};
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
+static int hw_dev_acquisition_stop(int dev_index, void *session_data);
static int sigma_read(void *buf, size_t size, struct context *ctx)
{
return SR_OK;
}
-static int receive_data(int fd, int revents, void *session_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
- struct sr_dev_inst *sdi = session_data;
+ struct sr_dev_inst *sdi = cb_data;
struct context *ctx = sdi->priv;
struct sr_datafeed_packet packet;
const int chunks_per_read = 32;
if (running_msec < ctx->limit_msec && numchunks < 32767)
return FALSE;
- hw_dev_acquisition_stop(sdi->index, session_data);
+ hw_dev_acquisition_stop(sdi->index, sdi);
return FALSE;
} else if (ctx->state.state == SIGMA_DOWNLOAD) {
&ctx->state.lastts,
&ctx->state.lastsample,
ctx->state.triggerpos & 0x1ff,
- limit_chunk, session_data);
+ limit_chunk, sdi);
else
decode_chunk_ts(buf + (i * CHUNK_SIZE),
&ctx->state.lastts,
&ctx->state.lastsample,
- -1, limit_chunk, session_data);
+ -1, limit_chunk, sdi);
++ctx->state.chunks_downloaded;
}
return SR_OK;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct context *ctx;
struct triggerinout triggerinout_conf;
struct triggerlut lut;
- /* Avoid compiler warnings. */
- (void)session_data;
-
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_stop(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct context *ctx;
/* Function prototypes. */
static int la8_close_usb_reset_sequencer(struct context *ctx);
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
+static int hw_dev_acquisition_stop(int dev_index, void *session_data);
static int la8_reset(struct context *ctx);
static void fill_supported_samplerates_if_needed(void)
}
}
-static int receive_data(int fd, int revents, void *session_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
int i, ret;
struct sr_dev_inst *sdi;
(void)fd;
(void)revents;
- if (!(sdi = session_data)) {
- sr_err("la8: %s: session_data was NULL", __func__);
+ if (!(sdi = cb_data)) {
+ sr_err("la8: %s: cb_data was NULL", __func__);
return FALSE;
}
/* Get one block of data. */
if ((ret = la8_read_block(ctx)) < 0) {
sr_err("la8: %s: la8_read_block error: %d", __func__, ret);
- hw_dev_acquisition_stop(sdi->index, session_data);
+ hw_dev_acquisition_stop(sdi->index, sdi);
return FALSE;
}
for (i = 0; i < NUM_BLOCKS; i++)
send_block_to_session_bus(ctx, i);
- hw_dev_acquisition_stop(sdi->index, session_data);
+ hw_dev_acquisition_stop(sdi->index, sdi);
// return FALSE; /* FIXME? */
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct context *ctx;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_stop(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct context *ctx;
static GThread *my_thread;
static int thread_running;
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data);
+static int hw_dev_acquisition_stop(int dev_index, void *session_data);
static int hw_init(const char *devinfo)
{
}
/* Callback handling data */
-static int receive_data(int fd, int revents, void *session_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
logic.length = z;
logic.unitsize = 1;
logic.data = c;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
samples_received += z;
}
} while (z > 0);
/* Send last packet. */
packet.type = SR_DF_END;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
return FALSE;
}
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_stop(int dev_index, void *session_data)
{
/* Avoid compiler warnings. */
(void)dev_index;
static GSList *dev_insts = NULL;
static libusb_context *usb_context = NULL;
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id);
+static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id);
/**
* Check the USB configuration to determine if this is an fx2lafw device.
return ret;
}
-static int receive_data(int fd, int revents, void *user_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
struct timeval tv;
/* Avoid compiler warnings. */
(void)fd;
(void)revents;
- (void)user_data;
+ (void)cb_data;
tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout(usb_context, &tv);
}
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct sr_datafeed_packet *packet;
}
/* This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_stop(int dev_index, void *session_data)
{
struct sr_datafeed_packet packet;
#define MSO_TRIGGER_DATAREADY '6'
/* FIXME: Pass errors? */
-static int receive_data(int fd, int revents, void *user_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
- struct sr_dev_inst *sdi = user_data;
+ struct sr_dev_inst *sdi = cb_data;
struct context *ctx = sdi->priv;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
{
struct sr_dev_inst *sdi;
struct context *ctx;
}
/* FIXME */
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
{
struct sr_datafeed_packet packet;
return ret;
}
-static int receive_data(int fd, int revents, void *session_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
* finished. We'll double that to 30ms to be sure...
*/
sr_source_remove(fd);
- sr_source_add(fd, G_IO_IN, 30, receive_data, session_data);
+ sr_source_add(fd, G_IO_IN, 30, receive_data, cb_data);
ctx->raw_sample_buf = g_try_malloc(ctx->limit_samples * 4);
if (!ctx->raw_sample_buf) {
sr_err("ols: %s: ctx->raw_sample_buf malloc failed",
logic.unitsize = 4;
logic.data = ctx->raw_sample_buf +
(ctx->limit_samples - ctx->num_samples) * 4;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
}
/* send the trigger */
packet.type = SR_DF_TRIGGER;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
/* send post-trigger samples */
packet.type = SR_DF_LOGIC;
logic.unitsize = 4;
logic.data = ctx->raw_sample_buf + ctx->trigger_at * 4 +
(ctx->limit_samples - ctx->num_samples) * 4;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
} else {
/* no trigger was used */
packet.type = SR_DF_LOGIC;
logic.unitsize = 4;
logic.data = ctx->raw_sample_buf +
(ctx->limit_samples - ctx->num_samples) * 4;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
}
g_free(ctx->raw_sample_buf);
serial_flush(fd);
serial_close(fd);
packet.type = SR_DF_END;
- sr_session_send(session_data, &packet);
+ sr_session_send(cb_data, &packet);
}
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
{
struct sr_datafeed_packet packet;
static int new_saleae_logic_firmware = 0;
static int hw_dev_config_set(int dev_index, int hwcap, void *value);
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id);
+static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id);
/**
* Check the USB configuration to determine if this is a Saleae Logic.
return ret;
}
-static int receive_data(int fd, int revents, void *user_data)
+static int receive_data(int fd, int revents, void *cb_data)
{
struct timeval tv;
/* Avoid compiler warnings. */
(void)fd;
(void)revents;
- (void)user_data;
+ (void)cb_data;
tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout(usb_context, &tv);
}
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct sr_datafeed_packet *packet;
}
/* This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_stop(int dev_index, void *session_data)
{
struct sr_datafeed_packet packet;
}
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
+static int hw_dev_acquisition_start(int dev_index, void *session_data)
{
struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
}
/* This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_stop(int dev_index, void *session_dev_id)
{
struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
}
SR_PRIV void sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *user_data)
+ sr_receive_data_callback_t cb, void *cb_data)
{
- sr_session_source_add(fd, events, timeout, cb, user_data);
+ sr_session_source_add(fd, events, timeout, cb, cb_data);
}
static int sr_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
/* Function prototype. */
-static int sr_logv(void *data, int loglevel, const char *format, va_list args);
+static int sr_logv(void *cb_data, int loglevel, const char *format,
+ va_list args);
/* Pointer to the currently selected log handler. Default: sr_logv(). */
static sr_log_handler_t sr_log_handler = sr_logv;
*
* @param handler Function pointer to the log handler function to use.
* Must not be NULL.
- * @param data Pointer to private data to be passed on. This can be used by
- * the caller to pass arbitrary data to the log functions. This
- * pointer is only stored or passed on by libsigrok, and
- * is never used or interpreted in any way. The pointer is allowed
- * to be NULL if the caller doesn't need/want to pass any data.
+ * @param cb_data Pointer to private data to be passed on. This can be used by
+ * the caller to pass arbitrary data to the log functions. This
+ * pointer is only stored or passed on by libsigrok, and is
+ * never used or interpreted in any way. The pointer is allowed
+ * to be NULL if the caller doesn't need/want to pass any data.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
*/
-SR_API int sr_log_handler_set(sr_log_handler_t handler, void *data)
+SR_API int sr_log_handler_set(sr_log_handler_t handler, void *cb_data)
{
if (!handler) {
sr_err("log: %s: handler was NULL", __func__);
return SR_ERR_ARG;
}
- /* Note: 'data' is allowed to be NULL. */
+ /* Note: 'cb_data' is allowed to be NULL. */
sr_log_handler = handler;
- sr_log_handler_data = data;
+ sr_log_handler_data = cb_data;
return SR_OK;
}
return SR_OK;
}
-static int sr_logv(void *data, int loglevel, const char *format, va_list args)
+static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args)
{
int ret;
/* This specific log handler doesn't need the void pointer data. */
- (void)data;
+ (void)cb_data;
/* Only output messages of at least the selected loglevel(s). */
if (loglevel > sr_loglevel)
int events;
int timeout;
sr_receive_data_callback_t cb;
- void *user_data;
+ void *cb_data;
};
/* There can only be one session at a time. */
* asked for that timeout.
*/
if (!sources[i].cb(fds[i].fd, fds[i].revents,
- sources[i].user_data))
+ sources[i].cb_data))
sr_session_source_remove(sources[i].fd);
}
}
if (num_sources == 1 && sources[0].fd == -1) {
/* Dummy source, freewheel over it. */
while (session->running)
- sources[0].cb(-1, 0, sources[0].user_data);
+ sources[0].cb(-1, 0, sources[0].cb_data);
} else {
/* Real sources, use g_poll() main loop. */
sr_session_run_poll();
* @param events TODO.
* @param timeout TODO.
* @param cb TODO.
- * @param user_data TODO.
+ * @param cb_data TODO.
*
* @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
* SR_ERR_MALLOC upon memory allocation errors.
*/
SR_API int sr_session_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *user_data)
+ sr_receive_data_callback_t cb, void *cb_data)
{
struct source *new_sources, *s;
return SR_ERR_ARG;
}
- /* Note: user_data can be NULL, that's not a bug. */
+ /* Note: cb_data can be NULL, that's not a bug. */
new_sources = g_try_malloc0(sizeof(struct source) * (num_sources + 1));
if (!new_sources) {
s->events = events;
s->timeout = timeout;
s->cb = cb;
- s->user_data = user_data;
+ s->cb_data = cb_data;
sources = new_sources;
if (timeout != source_timeout && timeout > 0
return SR_OK;
}
-static int hw_dev_acquisition_start(int dev_index, gpointer session_dev_id)
+static int hw_dev_acquisition_start(int dev_index, void *session_dev_id)
{
struct zip_stat zs;
struct session_vdev *vdev;
SR_PRIV void sr_source_remove(int fd);
SR_PRIV void sr_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *user_data);
+ sr_receive_data_callback_t cb, void *cb_data);
/*--- hardware/common/serial.c ----------------------------------------------*/
/*--- log.c -----------------------------------------------------------------*/
-typedef int (*sr_log_handler_t)(void *data, int loglevel, const char *format,
+typedef int (*sr_log_handler_t)(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_handler_set(sr_log_handler_t handler, void *data);
+SR_API int sr_log_handler_set(sr_log_handler_t handler, void *cb_data);
SR_API int sr_log_handler_set_default(void);
SR_API int sr_log_logdomain_set(const char *logdomain);
SR_API char *sr_log_logdomain_get(void);
SR_API int sr_session_stop(void);
SR_API int sr_session_save(const char *filename);
SR_API int sr_session_source_add(int fd, int events, int timeout,
- sr_receive_data_callback_t cb, void *user_data);
+ sr_receive_data_callback_t cb, void *cb_data);
SR_API int sr_session_source_remove(int fd);
/*--- input/input.c ---------------------------------------------------------*/
/* Marks private, non-public libsigrok symbols (not part of the API). */
#define SR_PRIV __attribute__((visibility("hidden")))
-typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *user_data);
+typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *cb_data);
/* Data types used by hardware drivers for dev_config_set() */
enum {
int (*dev_status_get) (int dev_index);
int *(*hwcap_get_all) (void);
int (*dev_config_set) (int dev_index, int hwcap, void *value);
- int (*dev_acquisition_start) (int dev_index, gpointer session_dev_id);
- int (*dev_acquisition_stop) (int dev_index, gpointer session_dev_id);
+ int (*dev_acquisition_start) (int dev_index, void *session_dev_id);
+ int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);
};
struct sr_session {