+ drvc = di->priv;
+ devc = sdi->priv;
+ usb = sdi->conn;
+
+ devc->cb_data = cb_data;
+ devc->num_samples = 0;
+
+ /* Send header packet to the session bus. */
+ std_session_send_df_header(cb_data, LOG_PREFIX);
+
+ 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,
+ 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;
+
+ /* Length of payload to follow. */
+ cmd[0] = 0x01;
+ if (devc->data_source == DATA_SOURCE_LIVE)
+ cmd[1] = CMD_GET_LIVE;
+ else
+ cmd[1] = CMD_GET_STORED;
+
+ ret = libusb_bulk_transfer(usb->devhdl, EP_OUT, cmd, 2, &len, 5);
+ if (ret != 0 || len != 2) {
+ sr_dbg("Failed to start acquisition: %s", libusb_error_name(ret));
+ libusb_free_transfer(devc->xfer);
+ return SR_ERR;
+ }
+
+ libusb_fill_bulk_transfer(devc->xfer, usb->devhdl, EP_IN, devc->buf,
+ 128, uni_t_ut32x_receive_transfer, (void *)sdi, 15);
+ if (libusb_submit_transfer(devc->xfer) != 0) {
+ libusb_free_transfer(devc->xfer);
+ return SR_ERR;
+ }