Add sr_dev_acquisition_start(), factor out SR_ERR_DEV_CLOSED check.

This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.
This commit is contained in:
Uwe Hermann 2017-07-05 22:37:10 +02:00
parent d2f7c417fd
commit f670835f1f
62 changed files with 24 additions and 182 deletions

View File

@ -311,9 +311,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc->cur_channel = sr_next_enabled_channel(sdi, NULL); devc->cur_channel = sr_next_enabled_channel(sdi, NULL);
devc->cur_conf = sr_next_enabled_channel(sdi, NULL); devc->cur_conf = sr_next_enabled_channel(sdi, NULL);
devc->cur_sample = 1; devc->cur_sample = 1;

View File

@ -200,9 +200,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
serial = sdi->conn; serial = sdi->conn;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -308,9 +308,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
serial = sdi->conn; serial = sdi->conn;

View File

@ -299,9 +299,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
uint8_t clock_bytes[sizeof(clockselect)]; uint8_t clock_bytes[sizeof(clockselect)];
size_t clock_idx; size_t clock_idx;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (sigma_convert_trigger(sdi) != SR_OK) { if (sigma_convert_trigger(sdi) != SR_OK) {

View File

@ -439,9 +439,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
uint8_t packet[PACKET_SIZE]; uint8_t packet[PACKET_SIZE];
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
memset(devc->packet, 0x44, PACKET_SIZE); memset(devc->packet, 0x44, PACKET_SIZE);
devc->packet_size = 0; devc->packet_size = 0;

View File

@ -316,9 +316,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
.it_value = { 0, 0 } .it_value = { 0, 0 }
}; };
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (dev_acquisition_open(sdi)) if (dev_acquisition_open(sdi))
return SR_ERR; return SR_ERR;

View File

@ -294,9 +294,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
struct sr_trigger *trigger; struct sr_trigger *trigger;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
/* Clear capture state */ /* Clear capture state */
devc->bytes_read = 0; devc->bytes_read = 0;
devc->offset = 0; devc->offset = 0;

View File

@ -210,9 +210,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{ {
struct dev_context *devc; struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->sw_limits); sr_sw_limits_acquisition_start(&devc->sw_limits);

View File

@ -160,9 +160,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->sw_limits); sr_sw_limits_acquisition_start(&devc->sw_limits);

View File

@ -346,9 +346,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
devc->state = ST_INIT; devc->state = ST_INIT;
devc->num_samples = 0; devc->num_samples = 0;

View File

@ -165,9 +165,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->sw_limits); sr_sw_limits_acquisition_start(&devc->sw_limits);

View File

@ -484,9 +484,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
uint8_t buf[8]; uint8_t buf[8];
int bytes_to_write, bytes_written; int bytes_to_write, bytes_written;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (!devc->ftdic) { if (!devc->ftdic) {

View File

@ -123,9 +123,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);
std_session_send_df_header(sdi); std_session_send_df_header(sdi);

View File

@ -163,8 +163,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{ {
if (sdi->status != SR_ST_ACTIVE) (void)sdi;
return SR_ERR_DEV_CLOSED;
return SR_OK; return SR_OK;
} }

View File

@ -464,9 +464,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
GHashTableIter iter; GHashTableIter iter;
void *value; void *value;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
devc->sent_samples = 0; devc->sent_samples = 0;

View File

@ -1056,9 +1056,6 @@ SR_PRIV int dslogic_acquisition_start(const struct sr_dev_inst *sdi)
struct libusb_transfer *transfer; struct libusb_transfer *transfer;
int ret; int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
di = sdi->driver; di = sdi->driver;
drvc = di->context; drvc = di->context;
devc = sdi->priv; devc = sdi->priv;

View File

@ -221,9 +221,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -439,9 +439,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
devc = sdi->priv; devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (!devc->ftdic) if (!devc->ftdic)
return SR_ERR_BUG; return SR_ERR_BUG;

View File

@ -683,9 +683,6 @@ SR_PRIV int fx2lafw_start_acquisition(const struct sr_dev_inst *sdi)
int timeout, ret; int timeout, ret;
size_t size; size_t size;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
di = sdi->driver; di = sdi->driver;
drvc = di->context; drvc = di->context;
devc = sdi->priv; devc = sdi->priv;

View File

@ -427,9 +427,6 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
devc->settings_ok = FALSE; devc->settings_ok = FALSE;
devc->buflen = 0; devc->buflen = 0;
@ -450,9 +447,6 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
devc->settings_ok = FALSE; devc->settings_ok = FALSE;
devc->buflen = 0; devc->buflen = 0;

View File

@ -199,9 +199,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
scpi = sdi->conn; scpi = sdi->conn;
devc = sdi->priv; devc = sdi->priv;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc->state = START_ACQUISITION; devc->state = START_ACQUISITION;
devc->cur_acq_frame = 0; devc->cur_acq_frame = 0;

View File

@ -727,9 +727,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
int ret; int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
scpi = sdi->conn; scpi = sdi->conn;
devc = sdi->priv; devc = sdi->priv;

View File

@ -784,9 +784,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct sr_dev_driver *di = sdi->driver; struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->context; struct drv_context *drvc = di->context;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (configure_channels(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {

View File

@ -954,9 +954,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct sr_dev_driver *di = sdi->driver; struct sr_dev_driver *di = sdi->driver;
struct drv_context *drvc = di->context; struct drv_context *drvc = di->context;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (configure_channels(sdi) != SR_OK) { if (configure_channels(sdi) != SR_OK) {

View File

@ -367,9 +367,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
GArray *ch_list; GArray *ch_list;
GSList *channels; GSList *channels;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
scpi = sdi->conn; scpi = sdi->conn;
devc = sdi->priv; devc = sdi->priv;

View File

@ -664,9 +664,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
int ret; int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (devc->channel) { if (devc->channel) {
static const float res_array[] = {0.5, 1, 2, 5}; static const float res_array[] = {0.5, 1, 2, 5};
static const uint8_t relays[] = {100, 10, 10, 1}; static const uint8_t relays[] = {100, 10, 10, 1};

View File

@ -361,9 +361,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
unsigned int i, j; unsigned int i, j;
int ret; int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
drvc = di->context; drvc = di->context;

View File

@ -325,9 +325,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int ret; int ret;
struct dev_context *devc; struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (!devc->ftdic) if (!devc->ftdic)

View File

@ -380,9 +380,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int req_len, buf_len, len, ret; int req_len, buf_len, len, ret;
unsigned char buf[9]; unsigned char buf[9];
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
drvc = di->context; drvc = di->context;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;

View File

@ -152,9 +152,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
serial = sdi->conn; serial = sdi->conn;

View File

@ -344,9 +344,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -293,9 +293,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int ret; int ret;
unsigned char cmd[3], resp[4], *buf; unsigned char cmd[3], resp[4], *buf;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
drvc = di->context; drvc = di->context;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;

View File

@ -472,9 +472,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct drv_context *drvc; struct drv_context *drvc;
int ret; int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
drvc = sdi->driver->context; drvc = sdi->driver->context;
if ((ret = lls_start_acquisition(sdi)) < 0) if ((ret = lls_start_acquisition(sdi)) < 0)

View File

@ -553,9 +553,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int ret; int ret;
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
scpi = sdi->conn; scpi = sdi->conn;
/* Preset empty results. */ /* Preset empty results. */

View File

@ -330,9 +330,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
int ret = SR_ERR; int ret = SR_ERR;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (mso_configure_channels(sdi) != SR_OK) { if (mso_configure_channels(sdi) != SR_OK) {

View File

@ -353,9 +353,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -435,9 +435,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct sr_modbus_dev_inst *modbus; struct sr_modbus_dev_inst *modbus;
int ret; int ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
modbus = sdi->conn; modbus = sdi->conn;
devc = sdi->priv; devc = sdi->priv;

View File

@ -178,9 +178,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -764,9 +764,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
devc->acq_running = TRUE; devc->acq_running = TRUE;

View File

@ -203,9 +203,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -439,9 +439,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int num_ols_changrp; int num_ols_changrp;
int ret, i; int ret, i;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
serial = sdi->conn; serial = sdi->conn;

View File

@ -328,9 +328,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
devc->buffer_len = 0; devc->buffer_len = 0;
devc->memory_state = MEM_STATE_REQUEST_MEMORY_USAGE; devc->memory_state = MEM_STATE_REQUEST_MEMORY_USAGE;

View File

@ -523,9 +523,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int num_pols_changrp, samplespercount; int num_pols_changrp, samplespercount;
int ret, i; int ret, i;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
pols_channel_mask(sdi); pols_channel_mask(sdi);

View File

@ -997,9 +997,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
gboolean some_digital; gboolean some_digital;
GSList *l; GSList *l;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
scpi = sdi->conn; scpi = sdi->conn;
devc = sdi->priv; devc = sdi->priv;

View File

@ -265,8 +265,7 @@ static int config_list(uint32_t key, GVariant **data,
static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{ {
if (sdi->status != SR_ST_ACTIVE) (void)sdi;
return SR_ERR_DEV_CLOSED;
return SR_OK; return SR_OK;
} }

View File

@ -348,9 +348,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
uint8_t *buf; uint8_t *buf;
unsigned int i, ret; unsigned int i, ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
ret = saleae_logic_pro_init(sdi); ret = saleae_logic_pro_init(sdi);
if (ret != SR_OK) if (ret != SR_OK)
return ret; return ret;

View File

@ -674,9 +674,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
unsigned char *buf; unsigned char *buf;
size_t size, convsize; size_t size, convsize;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
drvc = di->context; drvc = di->context;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;

View File

@ -642,9 +642,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct pps_channel *pch; struct pps_channel *pch;
int cmd, ret; int cmd, ret;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
scpi = sdi->conn; scpi = sdi->conn;

View File

@ -179,9 +179,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -743,11 +743,6 @@ static int config_list(uint32_t key, GVariant **data,
*/ */
static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{ {
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
sr_info("Starting acquisition.");
return lwla_start_acquisition(sdi); return lwla_start_acquisition(sdi);
} }

View File

@ -163,9 +163,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct sr_serial_dev_inst *serial = sdi->conn; struct sr_serial_dev_inst *serial = sdi->conn;
struct dev_context *devc; struct dev_context *devc;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
sr_sw_limits_acquisition_start(&devc->sw_limits); sr_sw_limits_acquisition_start(&devc->sw_limits);

View File

@ -372,10 +372,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
unsigned char *buf; unsigned char *buf;
drvc = di->context; drvc = di->context;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;
devc->reply_size = 0; devc->reply_size = 0;

View File

@ -133,9 +133,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc = sdi->priv; struct dev_context *devc = sdi->priv;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
std_session_send_df_header(sdi); std_session_send_df_header(sdi);
sr_sw_limits_acquisition_start(&devc->limits); sr_sw_limits_acquisition_start(&devc->limits);

View File

@ -241,9 +241,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int len, ret; int len, ret;
unsigned char cmd[2]; unsigned char cmd[2];
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
drvc = di->context; drvc = di->context;
devc = sdi->priv; devc = sdi->priv;
usb = sdi->conn; usb = sdi->conn;

View File

@ -291,9 +291,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
int ret; int ret;
unsigned char *buf; unsigned char *buf;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
usb = sdi->conn; usb = sdi->conn;
std_session_send_df_header(sdi); std_session_send_df_header(sdi);

View File

@ -612,9 +612,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_scpi_dev_inst *scpi; struct sr_scpi_dev_inst *scpi;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
scpi = sdi->conn; scpi = sdi->conn;
devc = sdi->priv; devc = sdi->priv;
digital_added = FALSE; digital_added = FALSE;

View File

@ -490,9 +490,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
unsigned int discard; unsigned int discard;
int trigger_now; int trigger_now;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
devc = sdi->priv; devc = sdi->priv;
if (analyzer_add_triggers(sdi) != SR_OK) { if (analyzer_add_triggers(sdi) != SR_OK) {

View File

@ -592,6 +592,25 @@ SR_PRIV void sr_config_free(struct sr_config *src)
} }
/** @private */
SR_PRIV int sr_dev_acquisition_start(struct sr_dev_inst *sdi)
{
if (!sdi || !sdi->driver) {
sr_err("%s: Invalid arguments.", __func__);
return SR_ERR_ARG;
}
if (sdi->status != SR_ST_ACTIVE) {
sr_err("%s: Device instance not active, can't start.",
sdi->driver->name);
return SR_ERR_DEV_CLOSED;
}
sr_dbg("%s: Starting acquisition.", sdi->driver->name);
return sdi->driver->dev_acquisition_start(sdi);
}
/** @private */ /** @private */
SR_PRIV int sr_dev_acquisition_stop(struct sr_dev_inst *sdi) SR_PRIV int sr_dev_acquisition_stop(struct sr_dev_inst *sdi)
{ {

View File

@ -909,9 +909,6 @@ SR_PRIV int es51919_serial_acquisition_start(const struct sr_dev_inst *sdi)
struct dev_context *devc; struct dev_context *devc;
struct sr_serial_dev_inst *serial; struct sr_serial_dev_inst *serial;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
return SR_ERR_BUG; return SR_ERR_BUG;

View File

@ -834,6 +834,7 @@ SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *data);
SR_PRIV void sr_hw_cleanup_all(const struct sr_context *ctx); SR_PRIV void sr_hw_cleanup_all(const struct sr_context *ctx);
SR_PRIV struct sr_config *sr_config_new(uint32_t key, GVariant *data); SR_PRIV struct sr_config *sr_config_new(uint32_t key, GVariant *data);
SR_PRIV void sr_config_free(struct sr_config *src); SR_PRIV void sr_config_free(struct sr_config *src);
SR_PRIV int sr_dev_acquisition_start(struct sr_dev_inst *sdi);
SR_PRIV int sr_dev_acquisition_stop(struct sr_dev_inst *sdi); SR_PRIV int sr_dev_acquisition_stop(struct sr_dev_inst *sdi);
/*--- session.c -------------------------------------------------------------*/ /*--- session.c -------------------------------------------------------------*/

View File

@ -365,7 +365,7 @@ SR_API int sr_session_dev_add(struct sr_session *session,
sr_strerror(ret)); sr_strerror(ret));
return ret; return ret;
} }
if ((ret = sdi->driver->dev_acquisition_start(sdi)) != SR_OK) { if ((ret = sr_dev_acquisition_start(sdi)) != SR_OK) {
sr_err("Failed to start acquisition of device in " sr_err("Failed to start acquisition of device in "
"running session (%s)", sr_strerror(ret)); "running session (%s)", sr_strerror(ret));
return ret; return ret;
@ -816,7 +816,7 @@ SR_API int sr_session_start(struct sr_session *session)
ret = SR_ERR; ret = SR_ERR;
break; break;
} }
ret = sdi->driver->dev_acquisition_start(sdi); ret = sr_dev_acquisition_start(sdi);
if (ret != SR_OK) { if (ret != SR_OK) {
sr_err("Could not start %s device %s acquisition.", sr_err("Could not start %s device %s acquisition.",
sdi->driver->name, sdi->connection_id); sdi->driver->name, sdi->connection_id);

View File

@ -98,8 +98,6 @@ SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi)
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_header header; struct sr_datafeed_header header;
sr_dbg("%s: Starting acquisition.", prefix);
/* Send header packet to the session bus. */ /* Send header packet to the session bus. */
sr_dbg("%s: Sending SR_DF_HEADER packet.", prefix); sr_dbg("%s: Sending SR_DF_HEADER packet.", prefix);
packet.type = SR_DF_HEADER; packet.type = SR_DF_HEADER;