dev_acquisition_{start,stop}(): Drop duplicate 'cb_data' parameter.

These are always 'sdi', which is passed in already.
This commit is contained in:
Uwe Hermann 2016-03-28 00:40:16 +02:00
parent 208c1d3543
commit 695dc859c1
138 changed files with 444 additions and 691 deletions

View File

@ -1156,11 +1156,9 @@ struct sr_dev_driver {
/** 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(). */

View File

@ -55,9 +55,6 @@ struct dev_context {
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];

View File

@ -227,18 +227,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -248,9 +244,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -122,7 +122,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -305,7 +305,7 @@ static int recv_fetc(const struct sr_dev_inst *sdi, GMatchInfo *match)
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++;

View File

@ -225,7 +225,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -235,7 +235,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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
@ -245,7 +244,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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,
@ -254,9 +253,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -120,7 +120,7 @@ static void appa_55ii_live_data(struct sr_dev_inst *sdi, const uint8_t *buf)
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++;
@ -172,7 +172,7 @@ static void appa_55ii_log_data_parse(struct sr_dev_inst *sdi)
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++;
@ -216,7 +216,7 @@ static void appa_55ii_log_end(struct sr_dev_inst *sdi)
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,
@ -303,7 +303,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -311,8 +311,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -42,7 +42,6 @@ struct dev_context {
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. */

View File

@ -340,14 +340,12 @@ static int config_set(uint32_t key, GVariant *data,
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;
@ -366,7 +364,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -376,9 +374,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -266,7 +266,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -274,7 +274,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -301,7 +301,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -398,8 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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. */
@ -410,12 +408,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -908,7 +908,7 @@ static int download_capture(struct sr_dev_inst *sdi)
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);

View File

@ -218,7 +218,6 @@ struct dev_context {
struct sigma_trigger trigger;
int use_triggers;
struct sigma_state state;
void *cb_data;
};
extern SR_PRIV const uint64_t samplerates[];

View File

@ -460,14 +460,12 @@ static int dev_close(struct sr_dev_inst *sdi)
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;
@ -480,7 +478,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
@ -491,12 +489,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -349,7 +349,7 @@ static int dev_acquisition_open(const struct sr_dev_inst *sdi)
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 = {
@ -357,8 +357,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
.it_value = { 0, 0 }
};
(void)cb_data;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
@ -398,12 +396,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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)

View File

@ -750,7 +750,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
*/
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
@ -773,18 +773,18 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
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) {
@ -793,7 +793,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
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;
}

View File

@ -337,19 +337,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
#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;
@ -370,7 +365,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
@ -381,12 +376,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -64,7 +64,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
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,
@ -76,7 +76,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
bytes_remaining);
logic.data += trigger_offset;
sr_session_send(devc->cb_data, &packet);
sr_session_send(sdi, &packet);
devc->trigger_fired = TRUE;
}
@ -101,7 +101,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
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);
}

View File

@ -59,8 +59,6 @@ struct dev_context {
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;

View File

@ -249,12 +249,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -269,10 +267,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -330,7 +330,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -338,7 +338,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -194,7 +194,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -203,7 +203,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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
@ -213,7 +212,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *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 50ms, or whenever some data comes in. */
serial = sdi->conn;
@ -223,9 +222,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -42,7 +42,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
/* 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++;
}
}
@ -139,7 +139,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -147,7 +147,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -46,9 +46,6 @@ struct dev_context {
/** 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;

View File

@ -378,7 +378,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -387,12 +387,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -402,12 +401,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -140,12 +140,11 @@ static void process_mset(const struct sr_dev_inst *sdi)
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;
@ -199,12 +198,11 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data,
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;
}
@ -317,8 +315,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c,
* 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;
@ -342,7 +339,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c,
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;
}

View File

@ -104,7 +104,6 @@ struct dev_context {
gboolean enable_data_source_memory;
/* Temporary state across callbacks */
void *cb_data;
unsigned char cmd;
unsigned char token;
int buf_len;

View File

@ -204,8 +204,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -214,11 +213,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
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;
@ -228,9 +226,9 @@ static int dev_acquisition_start(const 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)
{
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);
}
@ -251,8 +249,8 @@ static GSList *dev_list_##X(const struct sr_dev_driver *d) { \
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) \

View File

@ -153,7 +153,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
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);
}
@ -235,7 +235,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
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;
}
@ -243,7 +243,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
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;
}
}

View File

@ -60,9 +60,6 @@ struct dev_context {
/** 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;

View File

@ -47,7 +47,7 @@ static const int32_t trigger_matches[] = {
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)
{
@ -92,7 +92,6 @@ static int add_device(int model, struct libusb_device_descriptor *des,
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. */
@ -478,7 +477,7 @@ static int receive_data(int fd, int revents, void *cb_data)
/* 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;
}
@ -499,14 +498,14 @@ static int receive_data(int fd, int revents, void *cb_data)
* 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];
@ -562,8 +561,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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). */
@ -578,10 +575,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);

View File

@ -401,16 +401,19 @@ SR_PRIV int cv_read_block(struct dev_context *devc)
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. */
@ -458,7 +461,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int 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;
}
@ -481,7 +484,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
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. */
@ -489,7 +492,7 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
(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)) {
@ -502,6 +505,6 @@ SR_PRIV void cv_send_block_to_session_bus(struct dev_context *devc, int block)
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);
}
}

View File

@ -69,8 +69,6 @@ struct dev_context {
/** 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.
@ -137,6 +135,6 @@ SR_PRIV int cv_write(struct dev_context *devc, uint8_t *buf, int size);
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

View File

@ -171,18 +171,14 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -192,9 +188,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -169,13 +169,11 @@ static void process_packet(const struct sr_dev_inst *sdi)
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)

View File

@ -39,9 +39,6 @@ struct dev_context {
/** 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;

View File

@ -182,20 +182,16 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;

View File

@ -177,7 +177,7 @@ static const uint8_t pattern_sigrok[] = {
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)
{
@ -757,7 +757,7 @@ static int prepare_data(int fd, int revents, void *cb_data)
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;
}
@ -841,20 +841,18 @@ static int prepare_data(int fd, int revents, void *cb_data)
}
}
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;
@ -877,10 +875,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);

View File

@ -251,7 +251,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -260,9 +260,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -279,9 +278,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -52,9 +52,6 @@ struct dev_context {
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];

View File

@ -399,7 +399,7 @@ static void handle_qm_19x_data(const struct sr_dev_inst *sdi, char **tokens)
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++;
}
@ -467,7 +467,7 @@ static void handle_line(const struct sr_dev_inst *sdi)
/* 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);
@ -509,7 +509,7 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
}
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;
}

View File

@ -457,12 +457,10 @@ static int config_list(uint32_t key, GVariant **data,
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)
@ -473,8 +471,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -488,10 +484,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -20,19 +20,22 @@
#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;
@ -76,7 +79,7 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data)
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) {
@ -89,12 +92,12 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data)
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;

View File

@ -48,7 +48,6 @@ struct dev_context {
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);

View File

@ -844,7 +844,7 @@ static int configure_channels(const struct sr_dev_inst *sdi)
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;
@ -860,7 +860,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -894,12 +893,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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)

View File

@ -385,15 +385,19 @@ static void resubmit_transfer(struct libusb_transfer *transfer)
}
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;
@ -409,7 +413,8 @@ SR_PRIV void mso_send_data_proc(struct dev_context *devc,
.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,
@ -424,11 +429,11 @@ SR_PRIV void mso_send_data_proc(struct dev_context *devc,
.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 = {
@ -442,7 +447,7 @@ SR_PRIV void la_send_data_proc(struct dev_context *devc,
.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)
@ -512,10 +517,8 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
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 {
@ -528,10 +531,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
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;

View File

@ -122,11 +122,10 @@ struct dev_context {
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;
@ -148,9 +147,9 @@ SR_PRIV void LIBUSB_CALL fx2lafw_receive_transfer(struct libusb_transfer *transf
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

View File

@ -460,8 +460,7 @@ static int config_list_bd(uint32_t key, GVariant **data, const struct sr_dev_ins
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;
@ -470,11 +469,10 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi,
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)
@ -488,8 +486,7 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi,
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;
@ -498,11 +495,10 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi,
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)
@ -517,7 +513,7 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi,
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;
@ -525,7 +521,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -668,7 +668,7 @@ static void send_value(struct sr_dev_inst *sdi)
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++;
}
@ -1173,12 +1173,12 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data)
/* 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;
@ -1224,12 +1224,12 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data)
/* 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 */

View File

@ -90,9 +90,6 @@ struct dev_context {
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, ...). */

View File

@ -209,13 +209,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -231,14 +229,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -23,7 +23,7 @@
#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)
{
@ -34,7 +34,7 @@ static int read_data(struct sr_dev_inst *sdi, void *cb_data,
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;
}
@ -54,7 +54,7 @@ static int read_data(struct sr_dev_inst *sdi, void *cb_data,
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;
}
@ -92,17 +92,17 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -113,12 +113,12 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
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;
@ -132,7 +132,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
/* 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. */
@ -154,19 +154,19 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
}
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';
@ -175,18 +175,18 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
}
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!
@ -206,21 +206,21 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
}
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);
@ -245,7 +245,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
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. */
@ -255,7 +255,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
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. */

View File

@ -710,7 +710,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
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;
@ -757,20 +757,18 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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)

View File

@ -773,7 +773,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
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;
@ -792,7 +792,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
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;
@ -808,7 +808,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
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);

View File

@ -78,7 +78,7 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info;
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)
{
@ -611,7 +611,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
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);
}
@ -699,7 +699,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
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",
@ -708,7 +708,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
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));
}
@ -770,7 +770,7 @@ static int handle_event(int fd, int revents, void *cb_data)
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;
@ -780,7 +780,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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.");
@ -790,7 +789,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -805,12 +804,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -101,7 +101,6 @@ struct hantek_6xxx_profile {
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

View File

@ -162,7 +162,7 @@ static const char *coupling[] = {
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)
{
@ -755,7 +755,7 @@ static void send_chunk(struct sr_dev_inst *sdi, unsigned char *buf,
analog.data[data_offset++] = ch2;
}
}
sr_session_send(devc->cb_data, &packet);
sr_session_send(sdi, &packet);
g_free(analog.data);
}
@ -844,7 +844,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
/* 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 */
@ -967,7 +967,7 @@ static int handle_event(int fd, int revents, void *cb_data)
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;
@ -977,7 +977,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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.");
@ -993,17 +992,15 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -162,7 +162,6 @@ struct dso_profile {
struct dev_context {
const struct dso_profile *profile;
void *cb_data;
uint64_t limit_frames;
uint64_t num_frames;
GSList *enabled_channels;

View File

@ -376,7 +376,7 @@ static void create_channel_index_list(GSList *channels, GArray **arr)
* 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;
@ -387,8 +387,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
GArray *ch_list;
GSList *channels;
(void)cb_data;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
@ -448,16 +446,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -388,7 +388,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
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;
@ -435,7 +435,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
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;
@ -456,7 +456,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
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. */
@ -464,7 +464,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
}
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;
}

View File

@ -686,7 +686,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -702,7 +702,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -712,7 +711,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
@ -720,22 +719,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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 = {

View File

@ -348,7 +348,7 @@ static void push_samples(const struct sr_dev_inst *sdi, uint8_t *buf, size_t num
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)
@ -393,7 +393,7 @@ 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;
}
@ -439,7 +439,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
return FALSE;
}
sr_session_send(devc->cb_data, &packet);
sr_session_send(sdi, &packet);
if (devc->channel) {
while (read_subframe(sdi, buf)) {
@ -453,10 +453,10 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
}
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);

View File

@ -52,7 +52,6 @@ struct dev_context {
gboolean adc2;
/* Temporary state across callbacks */
void *cb_data;
float *samples;
float factor;
gboolean state_known;
@ -64,6 +63,6 @@ SR_PRIV void hung_chang_dso_2100_write_mbox(struct parport *port, uint8_t val);
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

View File

@ -383,7 +383,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -398,7 +398,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -466,17 +465,15 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -27,14 +27,11 @@ extern uint64_t sl2_samplerates[NUM_SAMPLERATES];
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;
}
@ -42,14 +39,11 @@ static void stop_acquisition(struct sr_dev_inst *sdi)
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);
}
@ -134,7 +128,7 @@ static void process_sample_data(const struct sr_dev_inst *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);
}
}
@ -172,10 +166,10 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
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;
}
@ -188,7 +182,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi)
logic.length = n;
logic.unitsize = 1;
logic.data = buffer;
sr_session_send(devc->cb_data, &packet);
sr_session_send(sdi, &packet);
}
}

View File

@ -147,8 +147,6 @@ struct dev_context {
/* 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];

View File

@ -46,7 +46,7 @@ static const uint64_t samplerates[1] = { SR_MHZ(100) };
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)
{
@ -350,7 +350,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -365,8 +365,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
/* 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;
@ -386,10 +384,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);

View File

@ -107,10 +107,13 @@ static void scanaplus_uncompress_block(struct dev_context *devc,
}
}
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);
@ -119,7 +122,7 @@ static void send_samples(struct dev_context *devc, uint64_t 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;
@ -317,7 +320,7 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
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) {
@ -354,17 +357,17 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
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;

View File

@ -43,8 +43,6 @@ struct dev_context {
/** 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;

View File

@ -413,7 +413,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -434,10 +434,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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. */
@ -460,7 +459,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
}
@ -475,7 +474,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}
@ -522,12 +521,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -53,7 +53,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
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;
}
@ -69,8 +69,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
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);
@ -91,8 +90,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
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);
@ -119,8 +117,7 @@ static void send_data(const struct sr_dev_inst *sdi, void *buf, unsigned int buf
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)
@ -137,8 +134,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_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 */
@ -159,8 +155,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
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. */
@ -180,8 +175,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
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. */

View File

@ -81,7 +81,6 @@ struct dev_context {
gboolean config_dirty;
uint64_t num_samples;
uint64_t stored_samples;
void *cb_data;
struct libusb_transfer *xfer;
unsigned char buf[128];

View File

@ -183,7 +183,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -192,7 +192,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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).");
@ -203,7 +202,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *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 50ms, or whenever some data comes in. */
serial_source_add(sdi->session, serial, G_IO_IN, 50,
@ -212,9 +211,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -53,7 +53,7 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi,
/* 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++;
}
}
@ -124,7 +124,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -132,7 +132,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -55,9 +55,6 @@ struct dev_context {
/** 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;

View File

@ -381,7 +381,7 @@ static int config_list(uint32_t key, GVariant **data,
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;
@ -390,9 +390,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -406,12 +405,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -378,7 +378,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -386,7 +386,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -83,8 +83,6 @@ struct dev_context {
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. */

View File

@ -323,7 +323,7 @@ static int lascar_proc_config(const struct sr_dev_inst *sdi)
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;
@ -349,26 +349,25 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
}
@ -434,7 +433,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
@ -445,10 +445,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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.");

View File

@ -430,7 +430,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
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);
}
@ -440,7 +440,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
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);
}
@ -463,7 +463,7 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
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:
@ -487,7 +487,7 @@ SR_PRIV int lascar_el_usb_handle_events(int fd, int revents, void *cb_data)
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));
@ -511,7 +511,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
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 */
@ -530,7 +530,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
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) {
@ -540,7 +540,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
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

View File

@ -41,7 +41,6 @@
/** 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];
@ -80,6 +79,6 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
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

View File

@ -498,7 +498,7 @@ static int receive_usb_data(int fd, int revents, void *cb_data)
(void)fd;
(void)revents;
drvc = (struct drv_context *) cb_data;
drvc = (struct drv_context *)cb_data;
tv.tv_sec = 0;
tv.tv_usec = 0;
@ -509,7 +509,7 @@ static int receive_usb_data(int fd, int revents, void *cb_data)
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;
@ -522,16 +522,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -391,7 +391,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
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;
@ -446,22 +446,20 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
/* 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;

View File

@ -416,13 +416,13 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data)
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;

View File

@ -115,7 +115,6 @@ struct dev_context {
double dso_trigger_voltage;
uint16_t dso_trigger_width;
struct mso_prototrig protocol_trigger;
void *cb_data;
uint16_t buffer_n;
char buffer[4096];
};

View File

@ -387,7 +387,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -396,9 +396,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -413,9 +412,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -227,7 +227,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -235,7 +235,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -75,8 +75,6 @@ struct dev_context {
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. */

View File

@ -453,14 +453,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -479,12 +477,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -178,7 +178,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
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),
@ -188,13 +188,13 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
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;
}
@ -202,7 +202,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
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;
}
}

View File

@ -212,8 +212,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -222,11 +221,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
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;
@ -236,9 +234,9 @@ static int dev_acquisition_start(const 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)
{
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);
}
@ -263,8 +261,8 @@ static int config_list_##X(uint32_t key, GVariant **data, \
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) \

View File

@ -127,7 +127,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
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. */
@ -138,7 +138,7 @@ static int handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int idx)
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);
}
@ -213,7 +213,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
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;
}
@ -221,7 +221,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
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;
}
}

View File

@ -60,9 +60,6 @@ struct dev_context {
/** 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;

View File

@ -796,7 +796,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -811,7 +811,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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)
@ -823,7 +823,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -831,7 +831,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -181,12 +181,12 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data)
/* 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. */

View File

@ -249,7 +249,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
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;
@ -258,9 +258,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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)
@ -274,7 +273,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -282,7 +281,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
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);
}

View File

@ -366,7 +366,7 @@ static void nma_process_line(const struct sr_dev_inst *sdi)
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++;
@ -414,14 +414,14 @@ SR_PRIV int norma_dmm_receive_data(int fd, int revents, void *cb_data)
/* 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;
}
}

View File

@ -64,9 +64,6 @@ struct dev_context {
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. */

View File

@ -463,7 +463,7 @@ static int set_trigger(const struct sr_dev_inst *sdi, int stage)
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;
@ -569,21 +569,19 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;

View File

@ -472,12 +472,12 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
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;
@ -486,7 +486,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
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;
@ -495,7 +495,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
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);

View File

@ -535,7 +535,7 @@ static int disable_trigger(const struct sr_dev_inst *sdi, int stage)
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;
@ -688,16 +688,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
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;
@ -712,7 +712,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
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;
}

Some files were not shown because too many files have changed in this diff Show More