struct sr_trigger *trigger = sr_session_trigger_get(sdi->session);
struct h4032l_cmd_pkt *cmd_pkt = &devc->cmd_pkt;
+ devc->acq_aborted = FALSE;
+
/* Calculate packet ratio. */
cmd_pkt->pre_trigger_size = (cmd_pkt->sample_size * devc->capture_ratio) / 100;
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- (void)sdi;
+ struct dev_context *devc = sdi->priv;
+
+ devc->acq_aborted = TRUE;
+ if (devc->usb_transfer)
+ libusb_cancel_transfer(devc->usb_transfer);
- /* TODO: stop acquisition. */
+ devc->status = H4032L_STATUS_IDLE;
return SR_OK;
}
uint32_t status;
};
+static void finish_acquisition(struct sr_dev_inst *sdi)
+{
+ struct drv_context *drvc = sdi->driver->context;
+
+ std_session_send_df_end(sdi);
+ usb_source_remove(sdi->session, drvc->sr_ctx);
+}
+
+static void free_transfer(struct libusb_transfer *transfer)
+{
+ struct sr_dev_inst *sdi = transfer->user_data;
+ struct dev_context *devc = sdi->priv;
+
+ transfer->buffer = NULL;
+ libusb_free_transfer(transfer);
+ devc->usb_transfer = NULL;
+
+ finish_acquisition(sdi);
+}
+
SR_PRIV int h4032l_receive_data(int fd, int revents, void *cb_data)
{
struct timeval tv;
uint32_t number_samples;
int ret;
+ /*
+ * If acquisition has already ended, just free any queued up
+ * transfers that come in.
+ */
+ if (devc->acq_aborted) {
+ free_transfer(transfer);
+ return;
+ }
+
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
sr_dbg("%s error: %d.", __func__, transfer->status);
}
if (devc->status == H4032L_STATUS_IDLE)
- libusb_free_transfer(transfer);
+ free_transfer(transfer);
}
uint16_t h4032l_voltage2pwm(double voltage)