Use common usb_source_add and usb_source_remove functions.
This commit is contained in:
parent
ba1949f583
commit
6c60facc19
|
@ -243,3 +243,40 @@ SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout,
|
||||
sr_receive_data_callback_t cb, void *cb_data)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
sr_err("Operation not supported on Windows yet.");
|
||||
return SR_ERR;
|
||||
#else
|
||||
const struct libusb_pollfd **lupfd;
|
||||
unsigned int i;
|
||||
|
||||
lupfd = libusb_get_pollfds(ctx->libusb_ctx);
|
||||
for (i = 0; lupfd[i]; i++)
|
||||
sr_source_add(lupfd[i]->fd, lupfd[i]->events, timeout, cb, cb_data);
|
||||
free(lupfd);
|
||||
|
||||
return SR_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
SR_PRIV int usb_source_remove(struct sr_context *ctx)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
sr_err("Operation not supported on Windows yet.");
|
||||
return SR_ERR;
|
||||
#else
|
||||
const struct libusb_pollfd **lupfd;
|
||||
unsigned int i;
|
||||
|
||||
lupfd = libusb_get_pollfds(ctx->libusb_ctx);
|
||||
for (i = 0; lupfd[i]; i++)
|
||||
sr_source_remove(lupfd[i]->fd);
|
||||
free(lupfd);
|
||||
|
||||
return SR_OK;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -468,7 +468,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
struct drv_context *drvc;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
struct libusb_transfer *transfer;
|
||||
const struct libusb_pollfd **lupfd;
|
||||
unsigned int i, timeout, num_transfers;
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
@ -524,17 +523,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
devc->submitted_transfers++;
|
||||
}
|
||||
|
||||
lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; lupfd[i]; i++);
|
||||
if (!(devc->usbfd = g_try_malloc(sizeof(struct libusb_pollfd) * (i + 1))))
|
||||
return SR_ERR;
|
||||
for (i = 0; lupfd[i]; i++) {
|
||||
sr_source_add(lupfd[i]->fd, lupfd[i]->events,
|
||||
timeout, receive_data, NULL);
|
||||
devc->usbfd[i] = lupfd[i]->fd;
|
||||
}
|
||||
devc->usbfd[i] = -1;
|
||||
free(lupfd);
|
||||
devc->ctx = drvc->sr_ctx;
|
||||
|
||||
usb_source_add(devc->ctx, timeout, receive_data, NULL);
|
||||
|
||||
/* Send header packet to the session bus. */
|
||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
||||
|
|
|
@ -375,16 +375,13 @@ SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc)
|
|||
static void finish_acquisition(struct dev_context *devc)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
int i;
|
||||
|
||||
/* Terminate session. */
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(devc->cb_data, &packet);
|
||||
|
||||
/* Remove fds from polling. */
|
||||
for (i = 0; devc->usbfd[i] != -1; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
g_free(devc->usbfd);
|
||||
usb_source_remove(devc->ctx);
|
||||
|
||||
devc->num_transfers = 0;
|
||||
g_free(devc->transfers);
|
||||
|
|
|
@ -103,7 +103,7 @@ struct dev_context {
|
|||
void *cb_data;
|
||||
unsigned int num_transfers;
|
||||
struct libusb_transfer **transfers;
|
||||
int *usbfd;
|
||||
struct sr_context *ctx;
|
||||
};
|
||||
|
||||
SR_PRIV int fx2lafw_command_start_acquisition(libusb_device_handle *devhdl,
|
||||
|
|
|
@ -805,8 +805,7 @@ static int handle_event(int fd, int revents, void *cb_data)
|
|||
struct timeval tv;
|
||||
struct dev_context *devc;
|
||||
struct drv_context *drvc = di->priv;
|
||||
const struct libusb_pollfd **lupfd;
|
||||
int num_probes, i;
|
||||
int num_probes;
|
||||
uint32_t trigger_offset;
|
||||
uint8_t capturestate;
|
||||
|
||||
|
@ -822,10 +821,7 @@ static int handle_event(int fd, int revents, void *cb_data)
|
|||
* TODO: Doesn't really cancel pending transfers so they might
|
||||
* come in after SR_DF_END is sent.
|
||||
*/
|
||||
lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; lupfd[i]; i++)
|
||||
sr_source_remove(lupfd[i]->fd);
|
||||
free(lupfd);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(sdi, &packet);
|
||||
|
@ -915,10 +911,8 @@ static int handle_event(int fd, int revents, void *cb_data)
|
|||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||
{
|
||||
const struct libusb_pollfd **lupfd;
|
||||
struct dev_context *devc;
|
||||
struct drv_context *drvc = di->priv;
|
||||
int i;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
return SR_ERR_DEV_CLOSED;
|
||||
|
@ -938,11 +932,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
return SR_ERR;
|
||||
|
||||
devc->dev_state = CAPTURE;
|
||||
lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; lupfd[i]; i++)
|
||||
sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK,
|
||||
handle_event, (void *)sdi);
|
||||
free(lupfd);
|
||||
usb_source_add(drvc->sr_ctx, TICK, handle_event, (void *)sdi);
|
||||
|
||||
/* Send header packet to the session bus. */
|
||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
||||
|
|
|
@ -402,7 +402,6 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
|||
|
||||
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||
{
|
||||
const struct libusb_pollfd **pfd;
|
||||
struct drv_context *drvc;
|
||||
struct dev_context *devc;
|
||||
uint16_t trigger_bytes, tmp;
|
||||
|
@ -473,34 +472,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
tmp = GUINT16_TO_LE(devc->after_trigger_delay);
|
||||
memcpy(devc->xfer_data_out + 10, &tmp, sizeof(tmp));
|
||||
|
||||
if (!(pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx))) {
|
||||
sr_err("libusb_get_pollfds failed.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
/* Count the number of file descriptors. */
|
||||
for (devc->num_usbfd = 0; pfd[devc->num_usbfd]; devc->num_usbfd++);
|
||||
|
||||
if (!(devc->usbfd = g_try_malloc(devc->num_usbfd * sizeof(int)))) {
|
||||
sr_err("File descriptor array malloc failed.");
|
||||
free(pfd);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
if ((ret = libusb_submit_transfer(devc->xfer_out)) != 0) {
|
||||
sr_err("Submit transfer failed: %s.", libusb_error_name(ret));
|
||||
g_free(devc->usbfd);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
for (i = 0; i < devc->num_usbfd; i++) {
|
||||
sr_source_add(pfd[i]->fd, pfd[i]->events, 100,
|
||||
ikalogic_scanalogic2_receive_data, (void *)sdi);
|
||||
|
||||
devc->usbfd[i] = pfd[i]->fd;
|
||||
}
|
||||
|
||||
free(pfd);
|
||||
usb_source_add(drvc->sr_ctx, 100, ikalogic_scanalogic2_receive_data, (void *)sdi);
|
||||
|
||||
sr_dbg("Acquisition started successfully.");
|
||||
|
||||
|
|
|
@ -26,17 +26,14 @@ extern uint64_t sl2_samplerates[NUM_SAMPLERATES];
|
|||
|
||||
static void stop_acquisition(struct sr_dev_inst *sdi)
|
||||
{
|
||||
struct drv_context *drvc = sdi->driver->priv;
|
||||
struct dev_context *devc;
|
||||
struct sr_datafeed_packet packet;
|
||||
unsigned int i;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
/* Remove USB file descriptors from polling. */
|
||||
for (i = 0; i < devc->num_usbfd; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
|
||||
g_free(devc->usbfd);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(devc->cb_data, &packet);
|
||||
|
@ -46,17 +43,14 @@ static void stop_acquisition(struct sr_dev_inst *sdi)
|
|||
|
||||
static void abort_acquisition(struct sr_dev_inst *sdi)
|
||||
{
|
||||
struct drv_context *drvc = sdi->driver->priv;
|
||||
struct dev_context *devc;
|
||||
struct sr_datafeed_packet packet;
|
||||
unsigned int i;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
/* Remove USB file descriptors from polling. */
|
||||
for (i = 0; i < devc->num_usbfd; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
|
||||
g_free(devc->usbfd);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(devc->cb_data, &packet);
|
||||
|
|
|
@ -161,9 +161,6 @@ struct dev_context {
|
|||
/* Array to provide an index based access to all probes. */
|
||||
const struct sr_probe *probes[NUM_PROBES];
|
||||
|
||||
unsigned int num_usbfd;
|
||||
int *usbfd;
|
||||
|
||||
struct libusb_transfer *xfer_in, *xfer_out;
|
||||
|
||||
/*
|
||||
|
|
|
@ -432,9 +432,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
struct sr_config *src;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
GVariant *gvar, *rational[2];
|
||||
const struct libusb_pollfd **pfd;
|
||||
const uint64_t *si;
|
||||
int stored_mqflags, req_len, buf_len, len, ret, i;
|
||||
int stored_mqflags, req_len, buf_len, len, ret;
|
||||
unsigned char buf[9];
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
|
@ -494,15 +493,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
if (!(devc->xfer = libusb_alloc_transfer(0)))
|
||||
return SR_ERR;
|
||||
|
||||
pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; pfd[i]; i++) {
|
||||
/* Handle USB events every 10ms. */
|
||||
sr_source_add(pfd[i]->fd, pfd[i]->events, 10,
|
||||
kecheng_kc_330b_handle_events, (void *)sdi);
|
||||
/* We'll need to remove this fd later. */
|
||||
devc->usbfd[i] = pfd[i]->fd;
|
||||
}
|
||||
devc->usbfd[i] = -1;
|
||||
usb_source_add(drvc->sr_ctx, 10,
|
||||
kecheng_kc_330b_handle_events, (void *)sdi);
|
||||
|
||||
if (devc->data_source == DATA_SOURCE_LIVE) {
|
||||
buf[0] = CMD_GET_LIVE_SPL;
|
||||
|
|
|
@ -34,7 +34,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
|
|||
struct timeval tv;
|
||||
const uint64_t *intv_entry;
|
||||
gint64 now, interval;
|
||||
int offset, len, ret, i;
|
||||
int offset, len, ret;
|
||||
unsigned char buf[4];
|
||||
|
||||
(void)fd;
|
||||
|
@ -51,8 +51,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);
|
||||
for (i = 0; devc->usbfd[i] != -1; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(cb_data, &packet);
|
||||
sdi->status = SR_ST_ACTIVE;
|
||||
|
|
|
@ -89,7 +89,6 @@ struct dev_context {
|
|||
uint64_t num_samples;
|
||||
uint64_t stored_samples;
|
||||
void *cb_data;
|
||||
int usbfd[10];
|
||||
struct libusb_transfer *xfer;
|
||||
unsigned char buf[128];
|
||||
|
||||
|
|
|
@ -340,10 +340,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
struct drv_context *drvc;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
struct libusb_transfer *xfer_in, *xfer_out;
|
||||
const struct libusb_pollfd **pfd;
|
||||
struct timeval tv;
|
||||
uint64_t interval;
|
||||
int ret, i;
|
||||
int ret;
|
||||
unsigned char cmd[3], resp[4], *buf;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
|
@ -440,15 +439,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
devc->log_size = xfer_in->buffer[1] + (xfer_in->buffer[2] << 8);
|
||||
libusb_free_transfer(xfer_out);
|
||||
|
||||
pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; pfd[i]; i++) {
|
||||
/* Handle USB events every 100ms, for decent latency. */
|
||||
sr_source_add(pfd[i]->fd, pfd[i]->events, 100,
|
||||
lascar_el_usb_handle_events, (void *)sdi);
|
||||
/* We'll need to remove this fd later. */
|
||||
devc->usbfd[i] = pfd[i]->fd;
|
||||
}
|
||||
devc->usbfd[i] = -1;
|
||||
usb_source_add(drvc->sr_ctx, 100, lascar_el_usb_handle_events, (void *)sdi);
|
||||
|
||||
buf = g_try_malloc(4096);
|
||||
libusb_fill_bulk_transfer(xfer_in, usb->devhdl, LASCAR_EP_IN,
|
||||
|
|
|
@ -488,22 +488,18 @@ static void lascar_el_usb_dispatch(struct sr_dev_inst *sdi, unsigned char *buf,
|
|||
|
||||
SR_PRIV int lascar_el_usb_handle_events(int fd, int revents, void *cb_data)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
struct drv_context *drvc = di->priv;
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_dev_inst *sdi;
|
||||
struct timeval tv;
|
||||
int i;
|
||||
|
||||
(void)fd;
|
||||
(void)revents;
|
||||
|
||||
sdi = cb_data;
|
||||
devc = sdi->priv;
|
||||
|
||||
if (sdi->status == SR_ST_STOPPING) {
|
||||
for (i = 0; devc->usbfd[i] != -1; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(cb_data, &packet);
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
struct dev_context {
|
||||
void *cb_data;
|
||||
const struct elusb_profile *profile;
|
||||
int usbfd[10];
|
||||
/* Generic EL-USB */
|
||||
unsigned char config[MAX_CONFIGBLOCK_SIZE];
|
||||
unsigned int log_size;
|
||||
|
|
|
@ -691,7 +691,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
struct drv_context *drvc;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
struct libusb_transfer *transfer;
|
||||
const struct libusb_pollfd **lupfd;
|
||||
unsigned int i, timeout, num_transfers;
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
@ -721,7 +720,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
size = get_buffer_size(devc);
|
||||
convsize = (size / devc->num_channels + 2) * 16;
|
||||
devc->submitted_transfers = 0;
|
||||
devc->usbfd = NULL;
|
||||
|
||||
devc->convbuffer_size = convsize;
|
||||
if (!(devc->convbuffer = g_try_malloc(convsize))) {
|
||||
|
@ -771,21 +769,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
devc->submitted_transfers++;
|
||||
}
|
||||
|
||||
lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; lupfd[i]; i++);
|
||||
devc->usbfd = g_try_malloc(sizeof(struct libusb_pollfd) * (i + 1));
|
||||
if (!devc->usbfd) {
|
||||
abort_acquisition(devc);
|
||||
free(lupfd);
|
||||
return SR_ERR;
|
||||
}
|
||||
for (i = 0; lupfd[i]; i++) {
|
||||
sr_source_add(lupfd[i]->fd, lupfd[i]->events,
|
||||
timeout, receive_data, (void *)sdi);
|
||||
devc->usbfd[i] = lupfd[i]->fd;
|
||||
}
|
||||
devc->usbfd[i] = -1;
|
||||
free(lupfd);
|
||||
devc->ctx = drvc->sr_ctx;
|
||||
|
||||
usb_source_add(devc->ctx, timeout, receive_data, (void *)sdi);
|
||||
|
||||
/* Send header packet to the session bus. */
|
||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
||||
|
|
|
@ -579,18 +579,13 @@ SR_PRIV int logic16_init_device(const struct sr_dev_inst *sdi)
|
|||
static void finish_acquisition(struct dev_context *devc)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
int i;
|
||||
|
||||
/* Terminate session. */
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(devc->cb_data, &packet);
|
||||
|
||||
/* Remove fds from polling. */
|
||||
if (devc->usbfd != NULL) {
|
||||
for (i = 0; devc->usbfd[i] != -1; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
g_free(devc->usbfd);
|
||||
}
|
||||
usb_source_remove(devc->ctx);
|
||||
|
||||
devc->num_transfers = 0;
|
||||
g_free(devc->transfers);
|
||||
|
|
|
@ -82,7 +82,7 @@ struct dev_context {
|
|||
void *cb_data;
|
||||
unsigned int num_transfers;
|
||||
struct libusb_transfer **transfers;
|
||||
int *usbfd;
|
||||
struct sr_context *ctx;
|
||||
};
|
||||
|
||||
SR_PRIV int logic16_setup_acquisition(const struct sr_dev_inst *sdi,
|
||||
|
|
|
@ -297,8 +297,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
struct drv_context *drvc;
|
||||
struct dev_context *devc;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
const struct libusb_pollfd **pfd;
|
||||
int len, ret, i;
|
||||
int len, ret;
|
||||
unsigned char cmd[2];
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
|
@ -350,15 +349,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
return SR_ERR;
|
||||
}
|
||||
|
||||
pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; pfd[i]; i++) {
|
||||
/* Handle USB events every 10ms. */
|
||||
sr_source_add(pfd[i]->fd, pfd[i]->events, 10,
|
||||
uni_t_ut32x_handle_events, (void *)sdi);
|
||||
/* We'll need to remove this fd later. */
|
||||
devc->usbfd[i] = pfd[i]->fd;
|
||||
}
|
||||
devc->usbfd[i] = -1;
|
||||
usb_source_add(drvc->sr_ctx, 10, uni_t_ut32x_handle_events, (void *)sdi);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data)
|
|||
struct sr_datafeed_packet packet;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
struct timeval tv;
|
||||
int len, ret, i;
|
||||
int len, ret;
|
||||
unsigned char cmd[2];
|
||||
|
||||
(void)fd;
|
||||
|
@ -216,8 +216,7 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data)
|
|||
NULL);
|
||||
|
||||
if (sdi->status == SR_ST_STOPPING) {
|
||||
for (i = 0; devc->usbfd[i] != -1; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
packet.type = SR_DF_END;
|
||||
sr_session_send(cb_data, &packet);
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ struct dev_context {
|
|||
|
||||
/* Operational state */
|
||||
uint64_t num_samples;
|
||||
int usbfd[10];
|
||||
unsigned char buf[8];
|
||||
struct libusb_transfer *xfer;
|
||||
void *cb_data;
|
||||
|
|
|
@ -338,7 +338,6 @@ static int handle_events(int fd, int revents, void *cb_data)
|
|||
struct sr_dev_inst *sdi;
|
||||
struct timeval tv;
|
||||
gint64 now;
|
||||
int i;
|
||||
|
||||
(void)fd;
|
||||
(void)revents;
|
||||
|
@ -353,8 +352,7 @@ static int handle_events(int fd, int revents, void *cb_data)
|
|||
}
|
||||
|
||||
if (sdi->status == SR_ST_STOPPING) {
|
||||
for (i = 0; devc->usbfd[i] != -1; i++)
|
||||
sr_source_remove(devc->usbfd[i]);
|
||||
usb_source_remove(drvc->sr_ctx);
|
||||
|
||||
dev_close(sdi);
|
||||
|
||||
|
@ -373,10 +371,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
{
|
||||
struct dev_context *devc;
|
||||
struct drv_context *drvc = di->priv;
|
||||
const struct libusb_pollfd **pfd;
|
||||
struct sr_usb_dev_inst *usb;
|
||||
struct libusb_transfer *transfer;
|
||||
int ret, i;
|
||||
int ret;
|
||||
unsigned char *buf;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
|
@ -394,15 +391,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
/* Send header packet to the session bus. */
|
||||
std_session_send_df_header(cb_data, LOG_PREFIX);
|
||||
|
||||
pfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
|
||||
for (i = 0; pfd[i]; i++) {
|
||||
/* Handle USB events every 100ms, for decent latency. */
|
||||
sr_source_add(pfd[i]->fd, pfd[i]->events, 100,
|
||||
handle_events, (void *)sdi);
|
||||
/* We'll need to remove this fd later. */
|
||||
devc->usbfd[i] = pfd[i]->fd;
|
||||
}
|
||||
devc->usbfd[i] = -1;
|
||||
usb_source_add(drvc->sr_ctx, 100, handle_events, (void *)sdi);
|
||||
|
||||
buf = g_try_malloc(DMM_DATA_SIZE);
|
||||
transfer = libusb_alloc_transfer(0);
|
||||
|
|
|
@ -49,9 +49,6 @@ struct dev_context {
|
|||
/** The current number of already received samples. */
|
||||
uint64_t num_samples;
|
||||
gint64 end_time;
|
||||
|
||||
/* Only requires 3 really. */
|
||||
int usbfd[10];
|
||||
};
|
||||
|
||||
SR_PRIV int victor_dmm_receive_data(struct sr_dev_inst *sdi, unsigned char *buf);
|
||||
|
|
|
@ -268,6 +268,9 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
|
|||
#ifdef HAVE_LIBUSB_1_0
|
||||
SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn);
|
||||
SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb);
|
||||
SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout,
|
||||
sr_receive_data_callback_t cb, void *cb_data);
|
||||
SR_PRIV int usb_source_remove(struct sr_context *ctx);
|
||||
#endif
|
||||
|
||||
/*--- hardware/common/scpi.c ------------------------------------------------*/
|
||||
|
|
Loading…
Reference in New Issue