These are always 'sdi', which is passed in already.
/** Close device */
int (*dev_close) (struct sr_dev_inst *sdi);
/** Begin data acquisition on the specified device. */
- int (*dev_acquisition_start) (const struct sr_dev_inst *sdi,
- void *cb_data);
+ int (*dev_acquisition_start) (const struct sr_dev_inst *sdi);
/** End data acquisition on the specified device. */
- int (*dev_acquisition_stop) (struct sr_dev_inst *sdi,
- void *cb_data);
+ int (*dev_acquisition_stop) (struct sr_dev_inst *sdi);
/* Dynamic */
/** Device driver context, considered private. Initialized by init(). */
uint64_t limit_samples;
uint64_t limit_msec;
- /* Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/* Runtime. */
uint64_t num_samples;
int64_t jobqueue[8];
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- struct dev_context *devc;
struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- devc = sdi->priv;
- devc->cb_data = cb_data;
-
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
dispatch(sdi);
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
analog.data = &fvalue;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial;
struct dev_context *devc;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->session_cb_data = cb_data;
/*
* Reset the number of samples to take. If we've already collected our
devc->num_samples = 0;
devc->start_time = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->session_cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
devc->num_samples++;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->session_cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
devc->num_samples++;
if (devc->data_source != DATA_SOURCE_MEMORY)
return;
- sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
static const uint8_t *appa_55ii_parse_data(struct sr_dev_inst *sdi,
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
time = (g_get_monotonic_time() - devc->start_time) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi,
- devc->session_cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
uint64_t limit_samples; /**< The sampling limit (in number of samples). */
uint64_t limit_msec; /**< The time limit (in milliseconds). */
gboolean data_source; /**< Whether to read live samples or memory */
- void *session_cb_data; /**< Opaque pointer passed in by the frontend. */
/* Operational state */
uint64_t num_samples; /**< The number of already received samples. */
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
int ret;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
serial_source_add(sdi->session, serial, G_IO_IN, 100,
reloadpro_receive_data, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
memset(devc->buf, 0, RELOADPRO_BUFSIZE);
devc->buflen = 0;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
t = (g_get_monotonic_time() - devc->starttime) / 1000;
if (t > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct clockselect_50 clockselect;
gettimeofday(&devc->start_tv, 0);
sigma_set_register(WRITE_MODE, 0x0d, devc);
- devc->cb_data = cb_data;
-
std_session_send_df_header(sdi, LOG_PREFIX);
/* Add capture source. */
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
devc = sdi->priv;
devc->state.state = SIGMA_IDLE;
std_session_send_df_end(sdi, LOG_PREFIX);
- sdi->driver->dev_acquisition_stop(sdi, sdi);
+ sdi->driver->dev_acquisition_stop(sdi);
g_free(dram_line);
struct sigma_trigger trigger;
int use_triggers;
struct sigma_state state;
- void *cb_data;
};
extern SR_PRIV const uint64_t samplerates[];
return std_serial_dev_close(sdi);
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
uint8_t packet[PACKET_SIZE];
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 50,
atten_pps3xxx_receive_data, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Send a "channel" configuration packet now. */
memset(packet, 0, PACKET_SIZE);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return 0;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct itimerspec tspec = {
.it_value = { 0, 0 }
};
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
*/
for (i = 0; i < nrexpiration; i++) {
framep.type = SR_DF_FRAME_BEGIN;
- sr_session_send(cb_data, &framep);
+ sr_session_send(sdi, &framep);
/*
* Due to different units used in each channel we're sending
chp->val = read_sample(ch);
analog.data = &chp->val;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
framep.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &framep);
+ sr_session_send(sdi, &framep);
}
devc->samples_read++;
if (devc->limit_samples > 0 &&
devc->samples_read >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
devc->last_sample_fin = g_get_monotonic_time();
return TRUE;
} else if (devc->limit_msec > 0) {
if (elapsed_time >= devc->limit_msec) {
sr_info("Sampling time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
devc->last_sample_fin = g_get_monotonic_time();
return TRUE;
}
#define BUFUNIT_TIMEOUT_MS(devc) (100 + ((devc->bufunitsize * 1000) / \
(uint32_t)(devc->cur_samplerate)))
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc = sdi->priv;
struct sr_trigger *trigger;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- /* Save user pointer */
- devc->cb_data = cb_data;
-
/* Clear capture state */
devc->bytes_read = 0;
devc->offset = 0;
devc->trigger_fired = FALSE;
} else
devc->trigger_fired = TRUE;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Trigger and add poll on file */
beaglelogic_start(devc);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc = sdi->priv;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (devc->trigger_fired) {
/* Send the incoming transfer to the session bus. */
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
} else {
/* Check for trigger */
trigger_offset = soft_trigger_logic_check(devc->stl,
bytes_remaining);
logic.data += trigger_offset;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->trigger_fired = TRUE;
}
if (devc->bytes_read >= devc->limit_samples * logic.unitsize ||
packetsize == 0) {
/* Send EOA Packet, stop polling */
- std_session_send_df_end(devc->cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sr_session_source_remove_pollfd(sdi->session, &devc->pollfd);
}
uint32_t offset;
uint8_t *sample_buf; /* mmap'd kernel buffer here */
- void *cb_data;
-
/* Trigger logic */
struct soft_trigger_logic *stl;
gboolean trigger_fired;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached, stopping.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
time = (g_get_monotonic_time() - devc->start_time) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached, stopping.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
/*
* Reset the number of samples to take. If we've already collected our
devc->num_samples = 0;
devc->starttime = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
/* Got a measurement. */
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached, stopping.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
time = (g_get_monotonic_time() - devc->starttime) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached, stopping.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
devc->state = ST_INIT;
devc->num_samples = 0;
devc->buf_len = 0;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
analog.data = &devc->last_spl;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
break;
case TOKEN_RECORDING_ON:
devc->recording = TRUE;
analog.data = fbuf;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples += analog.num_samples;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
return;
}
* records. Otherwise the frontend would have no
* way to tell where stored data ends and live
* measurements begin. */
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
} else if (c == RECORD_DATA) {
devc->buf_len = 0;
devc->state = ST_GET_LOG_RECORD_DATA;
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL,
g_variant_new_uint64(devc->buf[7] * 1000));
meta.config = g_slist_append(NULL, src);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(src);
devc->buf_len = 0;
}
gboolean enable_data_source_memory;
/* Temporary state across callbacks */
- void *cb_data;
unsigned char cmd;
unsigned char token;
int buf_len;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi,
- void *cb_data, int idx)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
devc->num_samples = 0;
devc->starttime = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 500ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
static int dev_clear_##X(const struct sr_dev_driver *d) { \
(void)d; return dev_clear(X); }
#define HW_DEV_ACQUISITION_START(X) \
-static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
-void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
+static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
+) { return dev_acquisition_start(sdi, X); }
/* Driver structs and API function wrappers */
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
l = g_slist_append(l, g_slist_nth_data(sdi->channels, i));
analog.channels = l;
analog.data = &(info.temp[i]);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(l);
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
t = (g_get_monotonic_time() - devc->starttime) / 1000;
if (t > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
SR_TRIGGER_FALLING,
};
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static void clear_helper(void *priv)
{
devc->cur_samplerate = 0; /* Set later (different for LA8/LA16). */
devc->limit_msec = 0;
devc->limit_samples = 0;
- devc->cb_data = NULL;
memset(devc->mangled_buf, 0, BS);
devc->final_buf = NULL;
devc->trigger_pattern = 0x0000; /* Irrelevant, see trigger_mask. */
/* Get one block of data. */
if ((ret = cv_read_block(devc)) < 0) {
sr_err("Failed to read data block: %d.", ret);
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
return FALSE;
}
* full 8MByte first, only then the whole buffer contains valid data.
*/
for (i = 0; i < NUM_BLOCKS; i++)
- cv_send_block_to_session_bus(devc, i);
+ cv_send_block_to_session_bus(sdi, i);
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
uint8_t buf[8];
sr_dbg("Hardware acquisition started successfully.");
- devc->cb_data = cb_data;
-
std_session_send_df_header(sdi, LOG_PREFIX);
/* Time when we should be done (for detecting trigger timeouts). */
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
-SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
+SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int block)
{
int i, idx;
uint8_t sample, expected_sample, tmp8;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
int trigger_point; /* Relative trigger point (in this block). */
+ struct dev_context *devc;
/* Note: Caller ensures devc/devc->ftdic != NULL and block > 0. */
+ devc = sdi->priv;
+
/* TODO: Implement/test proper trigger support for the LA16. */
/* Check if we can find the trigger condition in this block. */
logic.length = BS;
logic.unitsize = devc->prof->num_channels / 8;
logic.data = devc->final_buf + (block * BS);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
return;
}
logic.length = trigger_point;
logic.unitsize = devc->prof->num_channels / 8;
logic.data = devc->final_buf + (block * BS);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
/* Send the SR_DF_TRIGGER packet to the session bus. */
(block * BS) + trigger_point);
packet.type = SR_DF_TRIGGER;
packet.payload = NULL;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
/* If at least one sample is located after the trigger... */
if (trigger_point < (BS - 1)) {
logic.length = BS - trigger_point;
logic.unitsize = devc->prof->num_channels / 8;
logic.data = devc->final_buf + (block * BS) + trigger_point;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
}
/** The current sampling limit (in number of samples). */
uint64_t limit_samples;
- void *cb_data;
-
/**
* A buffer containing some (mangled) samples from the device.
* Format: Pretty mangled-up (due to hardware reasons), see code.
SR_PRIV int cv_convert_trigger(const struct sr_dev_inst *sdi);
SR_PRIV int cv_set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
SR_PRIV int cv_read_block(struct dev_context *devc);
-SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block);
+SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int block);
#endif
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- struct dev_context *devc;
struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- devc = sdi->priv;
- devc->cb_data = cb_data;
-
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 150ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
if (devc->num_samples >= devc->limit_samples)
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
-
+ sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
}
SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
int state;
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
SR_PRIV struct sr_dev_driver demo_driver_info;
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{
if (devc->cur_samplerate <= 0 || devc->logic_unitsize <= 0
|| (devc->num_logic_channels <= 0
&& devc->num_analog_channels <= 0)) {
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
return G_SOURCE_CONTINUE;
}
}
}
sr_dbg("Requested number of samples reached.");
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
}
return G_SOURCE_CONTINUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
GHashTableIter iter;
void *value;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
uint64_t limit_samples;
uint64_t limit_msec;
- /* Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/* Runtime. */
uint64_t num_samples;
char buf[FLUKEDMM_BUFSIZE];
analog.mqflags = 0;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
/* Got a measurement. */
packet.type = SR_DF_ANALOG_OLD;
packet.payload = analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
g_free(analog->data);
g_free(analog);
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
ftdi_set_bitmode(devc->ftdic, 0, BITMODE_BITBANG);
- devc->cb_data = cb_data;
-
/* Properly reset internal variables before every new acquisition. */
devc->samples_sent = 0;
devc->bytes_received = 0;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
#include <ftdi.h>
#include "protocol.h"
-static void send_samples(struct dev_context *devc, uint64_t samples_to_send)
+static void send_samples(struct sr_dev_inst *sdi, uint64_t samples_to_send)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
+ struct dev_context *devc;
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
+ devc = sdi->priv;
+
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
logic.length = samples_to_send;
logic.unitsize = 1;
logic.data = devc->data_buf;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->samples_sent += samples_to_send;
devc->bytes_received -= samples_to_send;
if (bytes_read < 0) {
sr_err("Failed to read FTDI data (%d): %s.",
bytes_read, ftdi_get_error_string(devc->ftdic));
- sdi->driver->dev_acquisition_stop(sdi, sdi);
+ sdi->driver->dev_acquisition_stop(sdi);
return FALSE;
}
if (bytes_read == 0) {
n = devc->samples_sent + devc->bytes_received;
if (devc->limit_samples && (n >= devc->limit_samples)) {
- send_samples(devc, devc->limit_samples - devc->samples_sent);
+ send_samples(sdi, devc->limit_samples - devc->samples_sent);
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else {
- send_samples(devc, devc->bytes_received);
+ send_samples(sdi, devc->bytes_received);
}
return TRUE;
unsigned char *data_buf;
uint64_t samples_sent;
uint64_t bytes_received;
- void *cb_data;
};
SR_PRIV int ftdi_la_set_samplerate(struct dev_context *devc);
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di;
struct drv_context *drvc;
devc = sdi->priv;
devc->ctx = drvc->sr_ctx;
- devc->cb_data = cb_data;
devc->sent_samples = 0;
devc->empty_transfer_count = 0;
devc->acq_aborted = FALSE;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
devc = sdi->priv;
if (devc->dslogic)
}
-SR_PRIV void mso_send_data_proc(struct dev_context *devc,
+SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi,
uint8_t *data, size_t length, size_t sample_width)
{
size_t i;
+ struct dev_context *devc;
+
+ devc = sdi->priv;
+
sample_width = sample_width;
length /= 2;
/* Send the logic */
- for(i = 0; i < length; i++) {
+ for (i = 0; i < length; i++) {
devc->logic_buffer[i] = data[i * 2];
/* Rescale to -10V - +10V from 0-255. */
devc->analog_buffer[i] = data[i * 2 + 1] - 128.0f / 12.8f;
.type = SR_DF_LOGIC,
.payload = &logic
};
- sr_session_send(devc->cb_data, &logic_packet);
+
+ sr_session_send(sdi, &logic_packet);
const struct sr_datafeed_analog_old analog = {
.channels = devc->enabled_analog_channels,
.type = SR_DF_ANALOG_OLD,
.payload = &analog
};
- sr_session_send(devc->cb_data, &analog_packet);
+ sr_session_send(sdi, &analog_packet);
}
-SR_PRIV void la_send_data_proc(struct dev_context *devc,
+SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi,
uint8_t *data, size_t length, size_t sample_width)
{
const struct sr_datafeed_logic logic = {
.payload = &logic
};
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transfer)
else
num_samples = cur_sample_count;
- devc->send_data_proc(devc,
- (uint8_t*)transfer->buffer,
- num_samples * unitsize,
- unitsize);
+ devc->send_data_proc(sdi, (uint8_t *)transfer->buffer,
+ num_samples * unitsize, unitsize);
devc->sent_samples += num_samples;
}
} else {
num_samples > devc->limit_samples - devc->sent_samples)
num_samples = devc->limit_samples - devc->sent_samples;
- devc->send_data_proc(devc,
- (uint8_t*)transfer->buffer + trigger_offset * unitsize,
- num_samples * unitsize,
- unitsize);
+ devc->send_data_proc(sdi, (uint8_t *)transfer->buffer
+ + trigger_offset * unitsize,
+ num_samples * unitsize, unitsize);
devc->sent_samples += num_samples;
devc->trigger_fired = TRUE;
int submitted_transfers;
int empty_transfer_count;
- void *cb_data;
unsigned int num_transfers;
struct libusb_transfer **transfers;
struct sr_context *ctx;
- void (*send_data_proc)(struct dev_context *devc,
+ void (*send_data_proc)(struct sr_dev_inst *sdi,
uint8_t *data, size_t length, size_t sample_width);
uint8_t *logic_buffer;
float *analog_buffer;
SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc);
SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc);
SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc);
-SR_PRIV void la_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length,
- size_t sample_width);
-SR_PRIV void mso_send_data_proc(struct dev_context *devc, uint8_t *data, size_t length,
- size_t sample_width);
+SR_PRIV void la_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data,
+ size_t length, size_t sample_width);
+SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, uint8_t *data,
+ size_t length, size_t sample_width);
#endif
return SR_OK;
}
-static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi,
- void *cb_data)
+static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
devc->settings_ok = FALSE;
devc->buflen = 0;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Start timer, if required. */
if (devc->limit_msec)
return SR_OK;
}
-static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi,
- void *cb_data)
+static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
devc->settings_ok = FALSE;
devc->buflen = 0;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Start timer, if required. */
if (devc->limit_msec)
return req_meas14(sdi);
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
if (sdi && (devc = sdi->priv) && devc->limit_msec)
g_timer_stop(devc->elapsed_msec);
- return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, dev_close,
sdi->conn, LOG_PREFIX);
}
memset(&packet, 0, sizeof(struct sr_datafeed_packet));
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
/* If number of samples or time limit reached, stop acquisition. */
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
if (devc->limit_msec) {
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
if ((elapsed_s * 1000) >= devc->limit_msec)
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
return TRUE;
/* If number of samples or time limit reached, stop acquisition. */
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
if (devc->limit_msec) {
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
if ((elapsed_s * 1000) >= devc->limit_msec)
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
/* Request next data set, if required */
uint64_t limit_samples; /**< Target number of samples */
uint64_t limit_msec; /**< Target sampling time */
- /* Opaque pointer passed in by frontend. */
- void *cb_data;
-
/* Operational state */
gboolean settings_ok; /**< Settings msg received yet. */
int msg_type; /**< Message type (MSGID_INF, ...). */
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
- (void)cb_data;
-
scpi = sdi->conn;
devc = sdi->priv;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
struct sr_datafeed_packet packet;
- (void)cb_data;
-
scpi = sdi->conn;
devc = sdi->priv;
#define ANALOG_CHANNELS 2
#define VERTICAL_DIVISIONS 10
-static int read_data(struct sr_dev_inst *sdi, void *cb_data,
+static int read_data(struct sr_dev_inst *sdi,
struct sr_scpi_dev_inst *scpi, struct dev_context *devc,
int data_size)
{
data_size - devc->cur_rcv_buffer_position);
if (len < 0) {
sr_err("Read data error.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
devc->cur_rcv_buffer_position = 0;
return SR_ERR;
}
return SR_OK;
} else {
sr_err("Too many bytes read.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
devc->cur_rcv_buffer_position = 0;
return SR_ERR;
}
case START_ACQUISITION:
if (sr_scpi_send(scpi, ":TRIG:MOD 3") != SR_OK) {
sr_err("Failed to set trigger mode to SINGLE.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
if (sr_scpi_send(scpi, ":STOP") != SR_OK) {
sr_err("Failed to put the trigger system into STOP state.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
if (sr_scpi_send(scpi, ":RUN") != SR_OK) {
sr_err("Failed to put the trigger system into RUN state.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
if (((struct sr_channel *)g_slist_nth_data(sdi->channels, devc->cur_acq_channel))->enabled) {
if (sr_scpi_send(scpi, ":ACQ%d:MEM?", devc->cur_acq_channel+1) != SR_OK) {
sr_err("Failed to acquire memory.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
if (sr_scpi_read_begin(scpi) != SR_OK) {
sr_err("Could not begin reading SCPI response.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
devc->state = WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE;
/* All frames accquired. */
sr_spew("All frames acquired.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else {
/* Start acquiring next frame. */
}
break;
case WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) {
+ if (read_data(sdi, scpi, devc, 1) == SR_OK) {
if (devc->rcv_buffer[0] == '#')
devc->state = WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE;
}
break;
case WAIT_FOR_TRANSFER_OF_DATA_SIZE_DIGIT_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK) {
+ if (read_data(sdi, scpi, devc, 1) == SR_OK) {
if (devc->rcv_buffer[0] != '4' &&
devc->rcv_buffer[0] != '5' &&
devc->rcv_buffer[0] != '6') {
sr_err("Data size digits is not 4, 5 or 6 but "
"'%c'.", devc->rcv_buffer[0]);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else {
devc->data_size_digits = devc->rcv_buffer[0] - '0';
}
break;
case WAIT_FOR_TRANSFER_OF_DATA_SIZE_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, devc->data_size_digits) == SR_OK) {
+ if (read_data(sdi, scpi, devc, devc->data_size_digits) == SR_OK) {
devc->rcv_buffer[devc->data_size_digits] = 0;
if (sr_atoi(devc->rcv_buffer, &devc->data_size) != SR_OK) {
sr_err("Could not parse data size '%s'", devc->rcv_buffer);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else
devc->state = WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE;
}
break;
case WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, sizeof(float)) == SR_OK) {
+ if (read_data(sdi, scpi, devc, sizeof(float)) == SR_OK) {
/*
* Contrary to the documentation, this field is
* transfered with most significant byte first!
}
break;
case WAIT_FOR_TRANSFER_OF_CHANNEL_INDICATOR_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, 1) == SR_OK)
+ if (read_data(sdi, scpi, devc, 1) == SR_OK)
devc->state = WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE;
break;
case WAIT_FOR_TRANSFER_OF_RESERVED_DATA_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, 3) == SR_OK)
+ if (read_data(sdi, scpi, devc, 3) == SR_OK)
devc->state = WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE;
break;
case WAIT_FOR_TRANSFER_OF_CHANNEL_DATA_COMPLETE:
- if (read_data(sdi, cb_data, scpi, devc, devc->data_size - 8) == SR_OK) {
+ if (read_data(sdi, scpi, devc, devc->data_size - 8) == SR_OK) {
/* Fetch data needed for conversion from device. */
snprintf(command, sizeof(command), ":CHAN%d:SCAL?",
devc->cur_acq_channel + 1);
if (sr_scpi_get_string(scpi, command, &response) != SR_OK) {
sr_err("Failed to get volts per division.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
volts_per_division = g_ascii_strtod(response, &end_ptr);
analog.mqflags = 0;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
/* All channels acquired. */
if (devc->cur_acq_frame == devc->frame_limit - 1) {
/* All frames acquired. */
sr_spew("All frames acquired.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else {
/* Start acquiring next frame. */
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
GSList *l;
gboolean digital_added;
sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
hmo_receive_data, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
devc->current_channel = devc->enabled_channels;
return hmo_request_data(sdi);
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
- (void)cb_data;
-
std_session_send_df_end(sdi, LOG_PREFIX);
if (sdi->status != SR_ST_ACTIVE)
analog.mqflags = 0;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
g_array_free(data, TRUE);
data = NULL;
logic.data = data->data;
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_array_free(data, TRUE);
data = NULL;
break;
devc->current_channel = devc->current_channel->next;
hmo_request_data(sdi);
} else if (++devc->num_frames == devc->frame_limit) {
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
} else {
devc->current_channel = devc->enabled_channels;
hmo_request_data(sdi);
static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
{
analog.data[data_offset++] = (ch2_bit * *(buf + i * 2 + 1) - ch2_center);
}
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(analog.data);
}
PRIu64 " <= %" PRIu64, devc->limit_samples,
devc->samp_received);
send_data(sdi, devc->sample_buf, devc->limit_samples);
- sdi->driver->dev_acquisition_stop(sdi, NULL);
+ sdi->driver->dev_acquisition_stop(sdi);
} else if (devc->limit_msec && (g_get_monotonic_time() -
devc->aq_started) / 1000 >= devc->limit_msec) {
sr_info("Requested time limit reached, stopping. %d <= %d",
send_data(sdi, devc->sample_buf, devc->samp_received);
g_free(devc->sample_buf);
devc->sample_buf = NULL;
- sdi->driver->dev_acquisition_stop(sdi, NULL);
+ sdi->driver->dev_acquisition_stop(sdi);
} else {
read_channel(sdi, data_amount(sdi));
}
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_dev_driver *di = sdi->driver;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure channels.");
if (hantek_6xxx_init(sdi) != SR_OK)
return SR_ERR;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
devc->samp_received = 0;
devc->dev_state = FLUSH;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
struct dev_context {
const struct hantek_6xxx_profile *profile;
- void *cb_data;
GSList *enabled_channels;
/*
* We can't keep track of an FX2-based device after upgrading
SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
{
analog.data[data_offset++] = ch2;
}
}
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(analog.data);
}
/* Mark the end of this frame. */
packet.type = SR_DF_FRAME_END;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
if (devc->limit_frames && ++devc->num_frames == devc->limit_frames) {
/* Terminate session */
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_dev_driver *di = sdi->driver;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
if (configure_channels(sdi) != SR_OK) {
sr_err("Failed to configure channels.");
devc->dev_state = CAPTURE;
usb_source_add(sdi->session, drvc->sr_ctx, TICK, handle_event, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
struct dev_context {
const struct dso_profile *profile;
- void *cb_data;
uint64_t limit_frames;
uint64_t num_frames;
GSList *enabled_channels;
* channel in the scan list to the A/D converter. This way, we do not need to
* occupy the HP-IB bus to send channel select commands.
*/
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
int ret;
gboolean front_selected, rear_selected;
GArray *ch_list;
GSList *channels;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
devc = sdi->priv;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
g_slist_free(devc->active_channels);
return SR_OK;
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
struct channel_context *chanc;
- struct sr_dev_inst *sdi = cb_data;
+ struct sr_dev_inst *sdi;
(void)fd;
(void)revents;
ret = sr_scpi_get_double(scpi, NULL, &devc->last_channel_sync);
if (ret != SR_OK) {
sr_err("Cannot check channel synchronization.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return FALSE;
}
devc->acq_state = ACQ_GOT_CHANNEL_SYNC;
sr_err("Expected channel %u, but device says %u",
chanc->index,
(unsigned int)devc->last_channel_sync);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return FALSE;
}
/* All is good. Back to business. */
}
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return FALSE;
}
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc = sdi->priv;
int ret;
devc->factor /= relays[(devc->cctl[devc->channel - 1] >> 4) & 0x03];
}
devc->frame = 0;
- devc->cb_data = cb_data;
devc->state_known = TRUE;
devc->step = 0;
devc->adc2 = FALSE;
if (ret != SR_OK)
return ret;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
sr_session_source_add(sdi->session, -1, 0, 8,
hung_chang_dso_2100_poll, (void *)sdi);
return SR_OK;
}
-SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi,
- void *cb_data)
+SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi)
{
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sr_session_source_remove(sdi->session, -1);
hung_chang_dso_2100_move_to(sdi, 1);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return hung_chang_dso_2100_dev_acquisition_stop(sdi, cb_data);
+ return hung_chang_dso_2100_dev_acquisition_stop(sdi);
}
SR_PRIV struct sr_dev_driver hung_chang_dso_2100_driver_info = {
while (num--)
data[num] = (buf[num] - 0x80) * factor;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf)
};
push_samples(sdi, buf, 6);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
buf += 6;
num -= 6;
}
return FALSE;
}
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
if (devc->channel) {
while (read_subframe(sdi, buf)) {
}
packet.type = SR_DF_FRAME_END;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
if (++devc->frame >= devc->frame_limit)
- hung_chang_dso_2100_dev_acquisition_stop(sdi, devc->cb_data);
+ hung_chang_dso_2100_dev_acquisition_stop(sdi);
else
hung_chang_dso_2100_move_to(sdi, 0x21);
gboolean adc2;
/* Temporary state across callbacks */
- void *cb_data;
float *samples;
float factor;
gboolean state_known;
SR_PRIV uint8_t hung_chang_dso_2100_read_mbox(struct parport *port, float timeout);
SR_PRIV int hung_chang_dso_2100_move_to(const struct sr_dev_inst *sdi, uint8_t target);
SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data);
-SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data);
+SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi);
#endif
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
devc = sdi->priv;
drvc = di->context;
- devc->cb_data = cb_data;
devc->wait_data_ready_locked = TRUE;
devc->stopping_in_progress = FALSE;
devc->transfer_error = FALSE;
sr_dbg("Acquisition started successfully.");
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
devc->next_state = STATE_SAMPLE;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
static void stop_acquisition(struct sr_dev_inst *sdi)
{
struct drv_context *drvc = sdi->driver->context;
- struct dev_context *devc;
-
- devc = sdi->priv;
/* Remove USB file descriptors from polling. */
usb_source_remove(sdi->session, drvc->sr_ctx);
- std_session_send_df_end(devc->cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sdi->status = SR_ST_ACTIVE;
}
static void abort_acquisition(struct sr_dev_inst *sdi)
{
struct drv_context *drvc = sdi->driver->context;
- struct dev_context *devc;
-
- devc = sdi->priv;
/* Remove USB file descriptors from polling. */
usb_source_remove(sdi->session, drvc->sr_ctx);
- std_session_send_df_end(devc->cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sdi->driver->dev_close(sdi);
}
if (devc->trigger_type != TRIGGER_TYPE_NONE &&
devc->pre_trigger_samples == 0) {
packet.type = SR_DF_TRIGGER;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
}
logic.length = n;
logic.unitsize = 1;
logic.data = buffer;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
packet.type = SR_DF_TRIGGER;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
n = 0;
}
logic.length = n;
logic.unitsize = 1;
logic.data = buffer;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
}
/* Time that the trigger will be delayed in milliseconds. */
uint16_t after_trigger_delay;
- void *cb_data;
-
/* Array to provide an index based access to all channels. */
const struct sr_channel *channels[NUM_CHANNELS];
SR_PRIV struct sr_dev_driver ikalogic_scanaplus_driver_info;
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static void clear_helper(void *priv)
{
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
int ret;
struct dev_context *devc;
/* TODO: Configure channels later (thresholds etc.). */
- devc->cb_data = cb_data;
-
/* Properly reset internal variables before every new acquisition. */
devc->compressed_bytes_ignored = 0;
devc->samples_sent = 0;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
std_session_send_df_end(sdi, LOG_PREFIX);
}
}
-static void send_samples(struct dev_context *devc, uint64_t samples_to_send)
+static void send_samples(const struct sr_dev_inst *sdi, uint64_t samples_to_send)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
+ struct dev_context *devc;
+
+ devc = sdi->priv;
sr_spew("Sending %" PRIu64 " samples.", samples_to_send);
logic.length = samples_to_send * 2;
logic.unitsize = 2; /* We need 2 bytes for 9 channels. */
logic.data = devc->sample_buf;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->samples_sent += samples_to_send;
devc->bytes_received -= samples_to_send * 2;
if (bytes_read < 0) {
sr_err("Failed to read FTDI data (%d): %s.",
bytes_read, ftdi_get_error_string(devc->ftdic));
- sdi->driver->dev_acquisition_stop(sdi, sdi);
+ sdi->driver->dev_acquisition_stop(sdi);
return FALSE;
}
if (bytes_read == 0) {
max = (SR_MHZ(100) / 1000) * devc->limit_msec;
if (devc->limit_samples && (n >= devc->limit_samples)) {
- send_samples(devc, devc->limit_samples - devc->samples_sent);
+ send_samples(sdi, devc->limit_samples - devc->samples_sent);
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else if (devc->limit_msec && (n >= max)) {
- send_samples(devc, max - devc->samples_sent);
+ send_samples(sdi, max - devc->samples_sent);
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else {
- send_samples(devc, devc->bytes_received / 2);
+ send_samples(sdi, devc->bytes_received / 2);
}
return TRUE;
/** The current sampling limit (in number of samples). */
uint64_t limit_samples;
- void *cb_data;
-
uint8_t *compressed_buf;
uint64_t compressed_bytes_ignored;
uint8_t *sample_buf;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
devc = sdi->priv;
usb = sdi->conn;
- devc->cb_data = cb_data;
devc->num_samples = 0;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
if (devc->data_source == DATA_SOURCE_LIVE) {
/* Force configuration. */
devc->stored_samples = (buf[7] << 8) | buf[8];
if (devc->stored_samples == 0) {
/* Notify frontend of empty log by sending start/end packets. */
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
packet.type = SR_DF_META;
packet.payload = &meta;
meta.config = g_slist_append(NULL, src);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(src);
}
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (sdi->status == SR_ST_STOPPING) {
libusb_free_transfer(devc->xfer);
usb_source_remove(sdi->session, drvc->sr_ctx);
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sdi->status = SR_ST_ACTIVE;
return TRUE;
}
if (ret != 0 || len != 1) {
sr_dbg("Failed to request new acquisition: %s",
libusb_error_name(ret));
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
libusb_submit_transfer(devc->xfer);
if (ret != 0 || len != 4) {
sr_dbg("Failed to request next chunk: %s",
libusb_error_name(ret));
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
libusb_submit_transfer(devc->xfer);
analog.data = buf;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
-
+ sr_session_send(sdi, &packet);
}
SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer *transfer)
switch (transfer->status) {
case LIBUSB_TRANSFER_NO_DEVICE:
/* USB device was unplugged. */
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return;
case LIBUSB_TRANSFER_COMPLETED:
case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
send_data(sdi, fvalue, 1);
devc->num_samples++;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
} else {
/* let USB event handler fire off another
* request when the time is right. */
send_data(sdi, fvalue, 1);
devc->num_samples += num_samples;
if (devc->num_samples >= devc->stored_samples) {
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
} else {
/* let USB event handler fire off another
* request when the time is right. */
gboolean config_dirty;
uint64_t num_samples;
uint64_t stored_samples;
- void *cb_data;
struct libusb_transfer *xfer;
unsigned char buf[128];
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
serial = sdi->conn;
sr_spew("Set O1 mode (continuous values, stable and unstable ones).");
devc->num_samples = 0;
devc->starttime = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
/* Got a measurement. */
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
time = (g_get_monotonic_time() - devc->starttime) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/** The time limit (in milliseconds). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
devc->starttime = g_get_monotonic_time();
devc->num_samples = 0;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
t = (g_get_monotonic_time() - devc->starttime) / 1000;
if (t > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
int64_t req_sent_at;
gboolean reply_pending;
- void *cb_data;
-
/* Operational state */
float current; /**< Last current value [A] read from device. */
float current_max; /**< Output current set. */
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
struct sr_datafeed_packet packet;
drvc = di->context;
devc = sdi->priv;
usb = sdi->conn;
- devc->cb_data = cb_data;
if (lascar_proc_config(sdi) != SR_OK)
return SR_ERR;
sr_dbg("Starting log retrieval.");
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
interval = (devc->config[0x1c] | (devc->config[0x1d] << 8)) * 1000;
packet.type = SR_DF_META;
packet.payload = &meta;
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, g_variant_new_uint64(interval));
meta.config = g_slist_append(NULL, src);
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(src);
if (devc->logged_samples == 0) {
/* This ensures the frontend knows the session is done. */
- std_session_send_df_end(devc->cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
buf = g_malloc(4096);
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
- buf, 4096, lascar_el_usb_receive_transfer, cb_data, 100);
+ buf, 4096, lascar_el_usb_receive_transfer,
+ (struct sr_dev_inst *)sdi, 100);
if ((ret = libusb_submit_transfer(xfer_in) != 0)) {
sr_err("Unable to submit transfer: %s.", libusb_error_name(ret));
libusb_free_transfer(xfer_in);
return SR_OK;
}
-SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- (void)cb_data;
if (!di->context) {
sr_err("Driver was not initialized.");
else
analog.unit = SR_UNIT_CELSIUS;
analog.data = temp;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
}
analog.mq = SR_MQ_RELATIVE_HUMIDITY;
analog.unit = SR_UNIT_PERCENTAGE;
analog.data = rh;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
}
if (analog.data[i] < 0.0)
analog.data[i] = 0.0;
}
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_free(analog.data);
break;
default:
if (sdi->status == SR_ST_STOPPING) {
usb_source_remove(sdi->session, drvc->sr_ctx);
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
memset(&tv, 0, sizeof(struct timeval));
switch (transfer->status) {
case LIBUSB_TRANSFER_NO_DEVICE:
/* USB device was unplugged. */
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
return;
case LIBUSB_TRANSFER_COMPLETED:
case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
devc->rcvd_bytes, devc->log_size,
devc->rcvd_samples, devc->logged_samples);
if (devc->rcvd_bytes >= devc->log_size)
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
}
if (sdi->status == SR_ST_ACTIVE) {
libusb_error_name(ret));
g_free(transfer->buffer);
libusb_free_transfer(transfer);
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
}
} else {
/* This was the last transfer we're going to receive, so
/** Private, per-device-instance driver context. */
struct dev_context {
- void *cb_data;
const struct elusb_profile *profile;
/* Generic EL-USB */
unsigned char config[MAX_CONFIGBLOCK_SIZE];
SR_PRIV int lascar_start_logging(const struct sr_dev_inst *sdi);
SR_PRIV int lascar_stop_logging(const struct sr_dev_inst *sdi);
SR_PRIV int lascar_is_logging(const struct sr_dev_inst *sdi);
-SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi);
#endif
(void)fd;
(void)revents;
- drvc = (struct drv_context *) cb_data;
+ drvc = (struct drv_context *)cb_data;
tv.tv_sec = 0;
tv.tv_usec = 0;
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct drv_context *drvc;
int ret;
if ((ret = lls_start_acquisition(sdi)) < 0)
return ret;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
return usb_source_add(sdi->session, drvc->sr_ctx, 100,
receive_usb_data, drvc);
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
int ret = SR_ERR;
/* Reset trigger state. */
devc->trigger_state = 0x00;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Our first channel is analog, the other 8 are of type 'logic'. */
/* TODO. */
serial_source_add(sdi->session, devc->serial, G_IO_IN, -1,
- mso_receive_data, cb_data);
+ mso_receive_data, sdi);
return SR_OK;
}
/* This stops acquisition on ALL devices, ignoring dev_index. */
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
stop_acquisition(sdi);
return SR_OK;
logic.length = 1024;
logic.unitsize = 1;
logic.data = logic_out;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples += 1024;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi, sdi);
}
return TRUE;
double dso_trigger_voltage;
uint16_t dso_trigger_width;
struct mso_prototrig protocol_trigger;
- void *cb_data;
uint16_t buffer_n;
char buffer[4096];
};
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
devc->starttime = g_get_monotonic_time();
devc->num_samples = 0;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
t = (g_get_monotonic_time() - devc->starttime) / 1000;
if (t > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
int64_t req_sent_at;
gboolean reply_pending;
- void *cb_data;
-
float current; /**< Last current value [A] read from device. */
float current_max; /**< Output current set. */
float current_max_device;/**< Device-provided maximum output current. */
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_modbus_dev_inst *modbus;
int ret;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return maynuo_m97_capture_start(sdi);
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_modbus_dev_inst *modbus;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc->expecting_registers = 0;
if (sr_modbus_read_holding_registers(modbus, -1, 4, registers) == SR_OK) {
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
maynuo_m97_session_send_value(sdi, sdi->channels->data,
RBFL(registers + 0),
SR_MQ_CURRENT, SR_UNIT_AMPERE);
packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
t = (g_get_monotonic_time() - devc->starttime) / 1000;
if (t > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi,
- void *cb_data, int idx)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
devc->num_samples = 0;
devc->starttime = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \
return config_list(key, data, sdi, cg, X); }
#define HW_DEV_ACQUISITION_START(X) \
-static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
-void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
+static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi \
+) { return dev_acquisition_start(sdi, X); }
/* Driver structs and API function wrappers */
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
meaning.mq = SR_MQ_TEMPERATURE;
meaning.unit = SR_UNIT_CELSIUS; /* TODO: Use C/F correctly. */
analog.data = &temperature;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(l);
/* Humidity. */
meaning.mq = SR_MQ_RELATIVE_HUMIDITY;
meaning.unit = SR_UNIT_PERCENTAGE;
analog.data = &humidity;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(l);
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
t = (g_get_monotonic_time() - devc->starttime) / 1000;
if (t > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
serial_source_add(sdi->session, serial, G_IO_IN, 50,
motech_lps_30x_receive_data, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Start timer, if required. */
if (devc->limit_msec)
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
if (sdi && (devc = sdi->priv) && devc->limit_msec)
g_timer_stop(devc->elapsed_msec);
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
/* If number of samples or time limit reached, stop acquisition. */
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples))
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
if (devc->limit_msec) {
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
if ((elapsed_s * 1000) >= devc->limit_msec)
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
/* Only request the next packet if required. */
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Start timer, if required. */
if (devc->limit_msec)
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
if (sdi && (devc = sdi->priv) && devc->limit_msec)
g_timer_stop(devc->elapsed_msec);
- return std_serial_dev_acquisition_stop(sdi, cb_data, dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, dev_close,
sdi->conn, LOG_PREFIX);
}
memset(&packet, 0, sizeof(struct sr_datafeed_packet));
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
/* Finish processing. */
devc->num_samples++;
/* If number of samples or time limit reached, stop acquisition. */
terminating = FALSE;
if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
terminating = TRUE;
}
if (devc->limit_msec) {
elapsed_s = g_timer_elapsed(devc->elapsed_msec, NULL);
if ((elapsed_s * 1000) >= devc->limit_msec) {
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
terminating = TRUE;
}
}
uint64_t limit_samples; /**< Target number of samples */
uint64_t limit_msec; /**< Target sampling time */
- /* Opaque pointer passed in by frontend. */
- void *cb_data;
-
/* Operational state */
int last_req; /**< Last request. */
int64_t req_sent_at; /**< Request sent. */
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0;
memset(devc->sample, 0, 4);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* If the device stops sending for longer than it takes to send a byte,
* that means it's finished. But wait at least 100 ms to be safe.
*/
serial_source_add(sdi->session, serial, G_IO_IN, 100,
- ols_receive_data, cb_data);
+ ols_receive_data, (struct sr_dev_inst *)sdi);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
abort_acquisition(sdi);
return SR_OK;
logic.unitsize = 4;
logic.data = devc->raw_sample_buf +
(devc->limit_samples - devc->num_samples) * 4;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
/* Send the trigger. */
packet.type = SR_DF_TRIGGER;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
/* Send post-trigger samples. */
packet.type = SR_DF_LOGIC;
logic.unitsize = 4;
logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
(devc->limit_samples - devc->num_samples) * 4;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
} else {
/* no trigger was used */
packet.type = SR_DF_LOGIC;
logic.unitsize = 4;
logic.data = devc->raw_sample_buf +
(devc->limit_samples - devc->num_samples) * 4;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
g_free(devc->raw_sample_buf);
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
uint32_t samplecount, readcount, delaycount;
devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0;
memset(devc->sample, 0, 4);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Hook up a dummy handler to receive data from the device. */
sr_session_source_add(sdi->session, -1, 0, 10, p_ols_receive_data,
- cb_data);
+ (struct sr_dev_inst *)sdi);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
sr_session_source_remove(sdi->session, -1);
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
if (bytes_read < 0) {
sr_err("Failed to read FTDI data (%d): %s.",
bytes_read, ftdi_get_error_string(devc->ftdic));
- sdi->driver->dev_acquisition_stop(sdi, sdi);
+ sdi->driver->dev_acquisition_stop(sdi);
return FALSE;
}
if (bytes_read == 0) {
logic.unitsize = 4;
logic.data = devc->raw_sample_buf +
(devc->limit_samples - devc->num_samples) * 4;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
/* Send the trigger. */
packet.type = SR_DF_TRIGGER;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
/* Send post-trigger samples. */
packet.type = SR_DF_LOGIC;
logic.unitsize = 4;
logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
(devc->limit_samples - devc->num_samples) * 4;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
} else {
/* no trigger was used */
packet.type = SR_DF_LOGIC;
logic.unitsize = 4;
logic.data = devc->raw_sample_buf +
(devc->limit_samples - devc->num_samples) * 4;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
g_free(devc->raw_sample_buf);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
return TRUE;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
rigol_ds_receive, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
devc->channel_entry = devc->enabled_channels;
/* Start of first frame. */
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
- (void)cb_data;
-
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE) {
if (len == -1) {
sr_err("Read error, aborting capture.");
packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sr_session_send(sdi, &packet);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
/* At slow timebases in live capture the DS2072
if (len == -1) {
sr_err("Read error, aborting capture.");
packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sr_session_send(sdi, &packet);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
analog.mqflags = 0;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
} else {
logic.length = len;
logic.data = devc->buffer;
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
if (devc->num_block_read == devc->num_block_bytes) {
if (!sr_scpi_read_complete(scpi)) {
sr_err("Read should have been completed");
packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sr_session_send(sdi, &packet);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
devc->num_block_read = 0;
} else {
/* Done with this frame. */
packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
if (++devc->num_frames == devc->limit_frames) {
/* Last frame, stop capture. */
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
} else {
/* Get the next frame, starting with the first channel. */
devc->channel_entry = devc->enabled_channels;
/* Start of next frame. */
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
}
/* Acquisition settings */
GSList *enabled_channels;
uint64_t limit_frames;
- void *cb_data;
enum data_source data_source;
uint64_t analog_frame_size;
uint64_t digital_frame_size;
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
struct dev_context *devc;
return SR_ERR;
}
- devc->cb_data = cb_data;
devc->sent_samples = 0;
devc->empty_transfer_count = 0;
devc->cur_channel = 0;
usb_source_add(sdi->session, devc->ctx, timeout, receive_data, (void *)sdi);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
if ((ret = logic16_start_acquisition(sdi)) != SR_OK) {
abort_acquisition(devc);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
int ret;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
logic.length = new_samples * 2;
logic.unitsize = 2;
logic.data = devc->convbuffer;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->sent_samples += new_samples;
} else {
trigger_offset = soft_trigger_logic_check(devc->stl,
logic.length = num_samples * 2;
logic.unitsize = 2;
logic.data = devc->convbuffer + trigger_offset * 2;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->sent_samples += num_samples;
devc->trigger_fired = TRUE;
struct soft_trigger_logic *stl;
gboolean trigger_fired;
- void *cb_data;
unsigned int num_transfers;
struct libusb_transfer **transfers;
struct sr_context *ctx;
return ret;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
devc = sdi->priv;
scpi = sdi->conn;
- devc->cb_data = cb_data;
if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10,
scpi_pps_receive_data, (void *)sdi)) != SR_OK)
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_scpi_dev_inst *scpi;
float f;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
/* Model-specific information */
const struct scpi_pps *device;
- /* Acquisition settings */
- void *cb_data;
-
/* Operational state */
gboolean beeper_was_set;
struct channel_spec *channels;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->cb_data = cb_data;
/*
* Reset the number of samples to take. If we've already collected our
devc->num_samples = 0;
devc->starttime = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
/* Got a measurement. */
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
time = (g_get_monotonic_time() - devc->starttime) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/** The time limit (in milliseconds). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
* configured trigger conditions are met, or immediately if no triggers
* are configured.
*/
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
/* Request that a running capture operation be stopped.
*/
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_serial_dev_inst *serial = sdi->conn;
struct dev_context *devc;
return SR_ERR_DEV_CLOSED;
devc = sdi->priv;
- devc->session_cb_data = cb_data;
/*
* Reset the number of samples to take. If we've already collected our
devc->num_samples = 0;
devc->start_time = g_get_monotonic_time();
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
static void teleinfo_send_value(struct sr_dev_inst *sdi, const char *channel_name,
float value, int mq, int unit)
{
- struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog_old analog;
struct sr_channel *ch;
- devc = sdi->priv;
ch = teleinfo_find_channel(sdi, channel_name);
if (!ch || !ch->enabled)
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->session_cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
}
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
time = (g_get_monotonic_time() - devc->start_time) / 1000;
if (time > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, devc->session_cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/* Acquisition settings */
uint64_t limit_samples; /**< The sampling limit (in number of samples). */
uint64_t limit_msec; /**< The time limit (in milliseconds). */
- void *session_cb_data; /**< Opaque pointer passed in by the frontend. */
/* Operational state */
enum optarif optarif; /**< The device mode (which measures are reported) */
#define SERIALCOMM "115200/8n1"
SR_PRIV struct sr_dev_driver testo_driver_info;
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static const uint32_t scanopts[] = {
SR_CONF_CONN,
devc->reply_size = 0;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
- dev_acquisition_stop(sdi, devc->cb_data);
+ dev_acquisition_stop(sdi);
else
testo_request_packet(sdi);
if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) {
/* USB device was unplugged. */
- dev_acquisition_stop(sdi, devc->cb_data);
+ dev_acquisition_stop(sdi);
} else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
/* First two bytes in any transfer are FTDI status bytes. */
if (transfer->actual_length > 2)
libusb_error_name(ret));
g_free(transfer->buffer);
libusb_free_transfer(transfer);
- dev_acquisition_stop(sdi, devc->cb_data);
+ dev_acquisition_stop(sdi);
}
} else {
/* This was the last transfer we're going to receive, so
if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000;
if (now > devc->end_time)
- dev_acquisition_stop(sdi, devc->cb_data);
+ dev_acquisition_stop(sdi);
}
if (sdi->status == SR_ST_STOPPING) {
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
devc = sdi->priv;
usb = sdi->conn;
- devc->cb_data = cb_data;
devc->end_time = 0;
devc->num_samples = 0;
devc->reply_size = 0;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
usb_source_add(sdi->session, drvc->sr_ctx, 100,
handle_events, (void *)sdi);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- (void)cb_data;
if (!di->context) {
sr_err("Driver was not initialized.");
receive_transfer, (void *)sdi, 100);
if ((ret = libusb_submit_transfer(devc->out_transfer) != 0)) {
sr_err("Failed to request packet: %s.", libusb_error_name(ret));
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
return SR_ERR;
}
sr_dbg("Requested new packet.");
/* Acquisition settings */
uint64_t limit_msec;
uint64_t limit_samples;
- void *cb_data;
/* Operational state */
gint64 end_time;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
- struct dev_context *devc;
struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- devc = sdi->priv;
- devc->cb_data = cb_data;
-
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 500ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
analog.data = &floatval;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
/* Stop acquisition if we acquired enough samples. */
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
return TRUE;
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
devc = sdi->priv;
- devc->cb_data = cb_data;
devc->starttime = g_get_monotonic_time();
std_session_send_df_header(sdi, LOG_PREFIX);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)cb_data;
-
sr_dbg("Stopping acquisition.");
std_session_send_df_end(sdi, LOG_PREFIX);
sr_session_source_remove(sdi->session, -1);
analog.data = &floatval;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
/* Increase sample count. */
devc->num_samples++;
/* Abort acquisition if we acquired enough samples. */
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
if (devc->limit_msec) {
time_ms = (g_get_monotonic_time() - devc->starttime) / 1000;
if (time_ms > (int64_t)devc->limit_msec) {
sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
}
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc;
devc = sdi->priv;
usb = sdi->conn;
- devc->cb_data = cb_data;
devc->num_samples = 0;
devc->packet_len = 0;
return SR_ERR;
}
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
if (!(devc->xfer = libusb_alloc_transfer(0)))
return SR_ERR;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
-
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
analog.data = &temp;
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
g_slist_free(analog.channels);
}
}
* memory slots come through as "----" measurements. */
devc->num_samples++;
if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
- sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi,
- devc->cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
}
}
if (sdi->status == SR_ST_STOPPING) {
usb_source_remove(sdi->session, drvc->sr_ctx);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Tell the device to stop sending USB packets. */
usb = sdi->conn;
uint64_t num_samples;
unsigned char buf[8];
struct libusb_transfer *xfer;
- void *cb_data;
/* Temporary state across callbacks */
unsigned char packet[32];
#define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1)
SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data);
+static int dev_acquisition_stop(struct sr_dev_inst *sdi);
static const uint32_t drvopts[] = {
SR_CONF_MULTIMETER,
devc = sdi->priv;
if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) {
/* USB device was unplugged. */
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
} else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
sr_dbg("Got %d-byte packet.", transfer->actual_length);
if (transfer->actual_length == DMM_DATA_SIZE) {
victor_dmm_receive_data(sdi, transfer->buffer);
if (devc->limit_samples) {
if (devc->num_samples >= devc->limit_samples)
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
}
}
}
libusb_error_name(ret));
g_free(transfer->buffer);
libusb_free_transfer(transfer);
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
}
} else {
/* This was the last transfer we're going to receive, so
if (devc->limit_msec) {
now = g_get_monotonic_time() / 1000;
if (now > devc->end_time)
- dev_acquisition_stop(sdi, sdi);
+ dev_acquisition_stop(sdi);
}
if (sdi->status == SR_ST_STOPPING) {
return TRUE;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- struct dev_context *devc;
struct drv_context *drvc = di->context;
struct sr_usb_dev_inst *usb;
struct libusb_transfer *transfer;
return SR_ERR;
}
- devc = sdi->priv;
usb = sdi->conn;
- devc->cb_data = cb_data;
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
usb_source_add(sdi->session, drvc->sr_ctx, 100,
handle_events, (void *)sdi);
* handling above. */
libusb_fill_interrupt_transfer(transfer, usb->devhdl,
VICTOR_ENDPOINT, buf, DMM_DATA_SIZE, receive_transfer,
- cb_data, 100);
+ (struct sr_dev_inst *)sdi, 100);
if ((ret = libusb_submit_transfer(transfer) != 0)) {
sr_err("Unable to submit transfer: %s.", libusb_error_name(ret));
libusb_free_transfer(transfer);
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct sr_dev_driver *di = sdi->driver;
- (void)cb_data;
if (!di->context) {
sr_err("Driver was not initialized.");
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
devc->num_samples++;
}
/** The current sampling limit (in ms). */
uint64_t limit_msec;
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The current number of already received samples. */
uint64_t num_samples;
gint64 end_time;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
GSList *l;
gboolean digital_added;
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
- (void)cb_data;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
- (void)cb_data;
-
std_session_send_df_end(sdi, LOG_PREFIX);
if (sdi->status != SR_ST_ACTIVE)
* As of now we only support importing the current acquisition
* data so we're going to stop at this point.
*/
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
} else
devc->current_channel = devc->current_channel->next;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
sr_info("Ramsize trigger = 0x%x.", ramsize_trigger);
sr_info("Memory size = 0x%x.", memory_size);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Check for empty capture */
if ((status & STATUS_READY) && !stop_address) {
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
logic.length = (trigger_offset - samples_read) * 4;
logic.unitsize = 4;
logic.data = buf + buf_offset;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
len -= logic.length;
samples_read += logic.length / 4;
buf_offset += logic.length;
/* Send out trigger */
packet.type = SR_DF_TRIGGER;
packet.payload = NULL;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
/* Send out data (or data after trigger) */
logic.length = len;
logic.unitsize = 4;
logic.data = buf + buf_offset;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
samples_read += len / 4;
}
analyzer_read_stop(usb->devhdl);
g_free(buf);
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
- std_session_send_df_end(cb_data, LOG_PREFIX);
+ std_session_send_df_end(sdi, LOG_PREFIX);
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL", __func__);
/** Private, per-device-instance driver context. */
struct dev_context {
- /** Opaque pointer passed in by the frontend. */
- void *cb_data;
-
/** The number of frames. */
struct dev_limit_counter frame_count;
static int do_config_update(struct sr_dev_inst *sdi, uint32_t key,
GVariant *var)
{
- struct dev_context *devc;
-
- devc = sdi->priv;
-
- return send_config_update_key(devc->cb_data, key, var);
+ return send_config_update_key(sdi, key, var);
}
static int send_freq_update(struct sr_dev_inst *sdi, unsigned int freq)
if (analog.mq >= 0) {
if (!frame) {
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
frame = TRUE;
}
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
g_slist_free(analog.channels);
if (analog.mq >= 0) {
if (!frame) {
packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
frame = TRUE;
}
packet.type = SR_DF_ANALOG_OLD;
packet.payload = &analog;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
g_slist_free(analog.channels);
if (frame) {
packet.type = SR_DF_FRAME_END;
- sr_session_send(devc->cb_data, &packet);
+ sr_session_send(sdi, &packet);
dev_limit_counter_inc(&devc->frame_count);
}
}
if (dev_limit_counter_limit_reached(&devc->frame_count) ||
dev_time_limit_reached(&devc->time_count))
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sdi->driver->dev_acquisition_stop(sdi);
return TRUE;
}
return SR_OK;
}
-SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi,
- void *cb_data)
+SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
if (!(devc = sdi->priv))
return SR_ERR_BUG;
- devc->cb_data = cb_data;
-
dev_limit_counter_start(&devc->frame_count);
dev_time_counter_start(&devc->time_count);
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi,
- void *cb_data)
+SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data,
+ return std_serial_dev_acquisition_stop(sdi, sdi,
std_serial_dev_close, sdi->conn, LOG_PREFIX);
}
SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg);
-SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi,
- void *cb_data);
-SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi,
- void *cb_data);
+SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi);
+SR_PRIV int es51919_serial_acquisition_stop(struct sr_dev_inst *sdi);
/*--- hardware/dmm/ut372.c --------------------------------------------------*/
sr_strerror(ret));
return ret;
}
- if ((ret = sdi->driver->dev_acquisition_start(sdi,
- sdi)) != SR_OK) {
+ if ((ret = sdi->driver->dev_acquisition_start(sdi)) != SR_OK) {
sr_err("Failed to start acquisition of device in "
"running session (%s)", sr_strerror(ret));
return ret;
/* Have all devices start acquisition. */
for (l = session->devs; l; l = l->next) {
sdi = l->data;
- ret = sdi->driver->dev_acquisition_start(sdi, sdi);
+ ret = sdi->driver->dev_acquisition_start(sdi);
if (ret != SR_OK) {
sr_err("Could not start %s device %s acquisition.",
sdi->driver->name, sdi->connection_id);
for (l = session->devs; l != lend; l = l->next) {
sdi = l->data;
if (sdi->driver->dev_acquisition_stop)
- sdi->driver->dev_acquisition_stop(sdi, sdi);
+ sdi->driver->dev_acquisition_stop(sdi);
}
/* TODO: Handle delayed stops. Need to iterate the event
* sources... */
for (node = session->devs; node; node = node->next) {
sdi = node->data;
if (sdi->driver && sdi->driver->dev_acquisition_stop)
- sdi->driver->dev_acquisition_stop(sdi, sdi);
+ sdi->driver->dev_acquisition_stop(sdi);
}
return G_SOURCE_REMOVE;
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct session_vdev *vdev;
int ret;
GSList *l;
struct sr_channel *ch;
- (void)cb_data;
-
vdev = sdi->priv;
vdev->bytes_read = 0;
vdev->cur_analog_channel = 0;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
struct session_vdev *vdev;
- (void)cb_data;
vdev = sdi->priv;
vdev->finished = TRUE;