static void finish_acquisition(struct dev_context *devc) { struct sr_datafeed_packet packet; /* Terminate session. */ packet.type = SR_DF_END; sr_session_send(devc->cb_data, &packet); /* Remove fds from polling. */ usb_source_remove(devc->ctx); devc->num_transfers = 0; g_free(devc->transfers); }
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; devc = sdi->priv; /* Remove USB file descriptors from polling. */ usb_source_remove(drvc->sr_ctx); packet.type = SR_DF_END; sr_session_send(devc->cb_data, &packet); sdi->driver->dev_close(sdi); }
SR_PRIV int lwla_start_acquisition(const struct sr_dev_inst *sdi) { struct drv_context *drvc; struct dev_context *devc; int ret; const int poll_interval_ms = 100; drvc = sdi->driver->context; devc = sdi->priv; if (devc->state != STATE_IDLE) { sr_err("Not in idle state, cannot start acquisition."); return SR_ERR; } devc->cancel_requested = FALSE; devc->transfer_error = FALSE; ret = init_acquisition_state(sdi); if (ret != SR_OK) return ret; ret = (*devc->model->setup_acquisition)(sdi); if (ret != SR_OK) { sr_err("Failed to set up device for acquisition."); clear_acquisition_state(sdi); return ret; } /* Register event source for asynchronous USB I/O. */ ret = usb_source_add(sdi->session, drvc->sr_ctx, poll_interval_ms, &transfer_event, (struct sr_dev_inst *)sdi); if (ret != SR_OK) { clear_acquisition_state(sdi); return ret; } ret = submit_request(sdi, STATE_START_CAPTURE); if (ret == SR_OK) ret = std_session_send_df_header(sdi, LOG_PREFIX); if (ret != SR_OK) { usb_source_remove(sdi->session, drvc->sr_ctx); clear_acquisition_state(sdi); } return ret; }
static int handle_event(int fd, int revents, void *cb_data) { const struct sr_dev_inst *sdi; struct sr_datafeed_packet packet; struct timeval tv; struct sr_dev_driver *di; struct dev_context *devc; struct drv_context *drvc; (void)fd; (void)revents; sdi = cb_data; di = sdi->driver; drvc = di->context; devc = sdi->priv; /* Always handle pending libusb events. */ tv.tv_sec = tv.tv_usec = 0; libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); if (devc->dev_state == STOPPING) { /* We've been told to wind up the acquisition. */ sr_dbg("Stopping acquisition."); hantek_6xxx_stop_data_collecting(sdi); /* * TODO: Doesn't really cancel pending transfers so they might * come in after SR_DF_END is sent. */ usb_source_remove(sdi->session, drvc->sr_ctx); packet.type = SR_DF_END; packet.payload = NULL; sr_session_send(sdi, &packet); devc->dev_state = IDLE; return TRUE; } return TRUE; }
static void finish_acquisition(struct sr_dev_inst *sdi) { struct dev_context *devc; devc = sdi->priv; std_session_send_df_end(sdi); usb_source_remove(sdi->session, devc->ctx); devc->num_transfers = 0; g_free(devc->transfers); /* Free the deinterlace buffers if we had them. */ if (g_slist_length(devc->enabled_analog_channels) > 0) { g_free(devc->logic_buffer); g_free(devc->analog_buffer); } if (devc->stl) { soft_trigger_logic_free(devc->stl); devc->stl = NULL; } }
static int scpi_usbtmc_libusb_source_remove(void *priv) { struct scpi_usbtmc_libusb *uscpi = priv; return usb_source_remove(uscpi->ctx); }
static int handle_event(int fd, int revents, void *cb_data) { const struct sr_dev_inst *sdi; struct sr_datafeed_packet packet; struct timeval tv; struct dev_context *devc; struct drv_context *drvc = di->priv; int num_probes; uint32_t trigger_offset; uint8_t capturestate; (void)fd; (void)revents; sdi = cb_data; devc = sdi->priv; if (devc->dev_state == STOPPING) { /* We've been told to wind up the acquisition. */ sr_dbg("Stopping acquisition."); /* * TODO: Doesn't really cancel pending transfers so they might * come in after SR_DF_END is sent. */ usb_source_remove(drvc->sr_ctx); packet.type = SR_DF_END; sr_session_send(sdi, &packet); devc->dev_state = IDLE; return TRUE; } /* Always handle pending libusb events. */ tv.tv_sec = tv.tv_usec = 0; libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); /* TODO: ugh */ if (devc->dev_state == NEW_CAPTURE) { if (dso_capture_start(sdi) != SR_OK) return TRUE; if (dso_enable_trigger(sdi) != SR_OK) return TRUE; // if (dso_force_trigger(sdi) != SR_OK) // return TRUE; sr_dbg("Successfully requested next chunk."); devc->dev_state = CAPTURE; return TRUE; } if (devc->dev_state != CAPTURE) return TRUE; if ((dso_get_capturestate(sdi, &capturestate, &trigger_offset)) != SR_OK) return TRUE; sr_dbg("Capturestate %d.", capturestate); sr_dbg("Trigger offset 0x%.6x.", trigger_offset); switch (capturestate) { case CAPTURE_EMPTY: if (++devc->capture_empty_count >= MAX_CAPTURE_EMPTY) { devc->capture_empty_count = 0; if (dso_capture_start(sdi) != SR_OK) break; if (dso_enable_trigger(sdi) != SR_OK) break; // if (dso_force_trigger(sdi) != SR_OK) // break; sr_dbg("Successfully requested next chunk."); } break; case CAPTURE_FILLING: /* No data yet. */ break; case CAPTURE_READY_8BIT: /* Remember where in the captured frame the trigger is. */ devc->trigger_offset = trigger_offset; num_probes = (devc->ch1_enabled && devc->ch2_enabled) ? 2 : 1; /* TODO: Check malloc return value. */ devc->framebuf = g_try_malloc(devc->framesize * num_probes * 2); devc->samp_buffered = devc->samp_received = 0; /* Tell the scope to send us the first frame. */ if (dso_get_channeldata(sdi, receive_transfer) != SR_OK) break; /* * Don't hit the state machine again until we're done fetching * the data we just told the scope to send. */ devc->dev_state = FETCH_DATA; /* Tell the frontend a new frame is on the way. */ packet.type = SR_DF_FRAME_BEGIN; sr_session_send(sdi, &packet); break; case CAPTURE_READY_9BIT: /* TODO */ sr_err("Not yet supported."); break; case CAPTURE_TIMEOUT: /* Doesn't matter, we'll try again next time. */ break; default: sr_dbg("Unknown capture state: %d.", capturestate); break; } return TRUE; }
static int scpi_usbtmc_libusb_source_remove(struct sr_session *session, void *priv) { struct scpi_usbtmc_libusb *uscpi = priv; return usb_source_remove(session, uscpi->ctx); }