struct sigma_dram_line *dram_line;
int bufsz;
uint32_t stoppos, triggerpos;
- struct sr_datafeed_packet packet;
uint8_t modestatus;
uint32_t i;
dl_lines_done += dl_lines_curr;
}
- /* All done. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sdi->driver->dev_acquisition_stop(sdi, sdi);
struct dev_context *devc;
const struct sr_dev_inst *sdi;
struct sr_serial_dev_inst *serial;
- struct sr_datafeed_packet packet;
unsigned char c;
(void)fd;
send_config(sdi);
else {
serial_source_remove(sdi->session, serial);
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
}
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
struct dev_context *devc;
(void)cb_data;
g_io_channel_unref(devc->channel);
devc->channel = NULL;
- /* Send last packet. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
if (devc->samples_missed > 0)
sr_warn("%" PRIu64 " samples missed", devc->samples_missed);
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc = sdi->priv;
- struct sr_datafeed_packet pkt;
(void)cb_data;
/* Remove session source and send EOT packet */
sr_session_source_remove_pollfd(sdi->session, &devc->pollfd);
- pkt.type = SR_DF_END;
- pkt.payload = NULL;
- sr_session_send(sdi, &pkt);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
if (devc->bytes_read >= devc->limit_samples * logic.unitsize ||
packetsize == 0) {
/* Send EOA Packet, stop polling */
- packet.type = SR_DF_END;
- packet.payload = NULL;
- sr_session_send(devc->cb_data, &packet);
-
+ std_session_send_df_end(devc->cb_data, LOG_PREFIX);
sr_session_source_remove_pollfd(sdi->session, &devc->pollfd);
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
-
(void)cb_data;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- /* Send end packet to the session bus. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
sr_session_source_remove(sdi->session, -1);
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
-
(void)cb_data;
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
-
- /* Send end packet to the session bus. */
- sr_dbg("Sending SR_DF_END.");
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
-
(void)cb_data;
sr_dbg("Stopping acquisition.");
-
sr_session_source_remove(sdi->session, -1);
-
- /* Send last packet. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
-
(void)cb_data;
if (sdi->status != SR_ST_ACTIVE)
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
- /* Send end packet to the session bus. */
- sr_dbg("Sending SR_DF_END.");
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
static void LIBUSB_CALL dslogic_trigger_receive(struct libusb_transfer *transfer)
{
const struct sr_dev_inst *sdi;
- struct sr_datafeed_packet packet;
struct dslogic_trigger_pos *tpos;
struct dev_context *devc;
if (transfer->status == LIBUSB_TRANSFER_CANCELLED) {
sr_dbg("Trigger transfer canceled.");
/* Terminate session. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
usb_source_remove(sdi->session, devc->ctx);
devc->num_transfers = 0;
g_free(devc->transfers);
}
libusb_free_transfer(transfer);
-
}
static int dslogic_trigger_request(const struct sr_dev_inst *sdi)
static void finish_acquisition(struct sr_dev_inst *sdi)
{
- struct sr_datafeed_packet packet;
struct dev_context *devc;
devc = sdi->priv;
- /* Terminate session. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
/* Remove fds from polling. */
usb_source_remove(sdi->session, devc->ctx);
packet.type = SR_DF_FRAME_END;
sr_session_send(sdi, &packet);
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
devc->df_started = FALSE;
}
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
- struct sr_datafeed_packet packet;
(void)cb_data;
- packet.type = SR_DF_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
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;
*/
usb_source_remove(sdi->session, drvc->sr_ctx);
- packet.type = SR_DF_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
devc->dev_state = IDLE;
*/
usb_source_remove(sdi->session, drvc->sr_ctx);
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
devc->dev_state = IDLE;
SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi,
void *cb_data)
{
- struct sr_datafeed_packet packet = { .type = SR_DF_END };
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
sr_session_source_remove(sdi->session, -1);
-
hung_chang_dso_2100_move_to(sdi, 1);
return SR_OK;
{
struct drv_context *drvc = sdi->driver->context;
struct dev_context *devc;
- struct sr_datafeed_packet packet;
devc = sdi->priv;
/* Remove USB file descriptors from polling. */
usb_source_remove(sdi->session, drvc->sr_ctx);
- packet.type = SR_DF_END;
- sr_session_send(devc->cb_data, &packet);
+ std_session_send_df_end(devc->cb_data, LOG_PREFIX);
sdi->status = SR_ST_ACTIVE;
}
{
struct drv_context *drvc = sdi->driver->context;
struct dev_context *devc;
- struct sr_datafeed_packet packet;
devc = sdi->priv;
/* Remove USB file descriptors from polling. */
usb_source_remove(sdi->session, drvc->sr_ctx);
- packet.type = SR_DF_END;
- sr_session_send(devc->cb_data, &packet);
+ std_session_send_df_end(devc->cb_data, LOG_PREFIX);
sdi->driver->dev_close(sdi);
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
-
(void)cb_data;
sr_dbg("Stopping acquisition.");
sr_session_source_remove(sdi->session, -1);
-
- /* Send end packet to the session bus. */
- sr_dbg("Sending SR_DF_END.");
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
devc->stored_samples = (buf[7] << 8) | buf[8];
if (devc->stored_samples == 0) {
/* Notify frontend of empty log by sending start/end packets. */
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
return SR_OK;
}
struct sr_dev_driver *di;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct sr_usb_dev_inst *usb;
struct timeval tv;
if (sdi->status == SR_ST_STOPPING) {
libusb_free_transfer(devc->xfer);
usb_source_remove(sdi->session, drvc->sr_ctx);
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
sdi->status = SR_ST_ACTIVE;
return TRUE;
}
if (devc->logged_samples == 0) {
/* This ensures the frontend knows the session is done. */
- packet.type = SR_DF_END;
- sr_session_send(devc->cb_data, &packet);
+ std_session_send_df_end(devc->cb_data, LOG_PREFIX);
return SR_OK;
}
SR_PRIV int lascar_el_usb_handle_events(int fd, int revents, void *cb_data)
{
struct drv_context *drvc = di->context;
- struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct timeval tv;
if (sdi->status == SR_ST_STOPPING) {
usb_source_remove(sdi->session, drvc->sr_ctx);
-
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
}
memset(&tv, 0, sizeof(struct timeval));
const struct sr_dev_inst *sdi;
struct drv_context *drvc;
struct dev_context *devc;
- struct sr_datafeed_packet packet;
sdi = xfer->user_data;
drvc = sdi->driver->context;
devc = sdi->priv;
if (devc->abort_acquisition) {
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
usb_source_remove(sdi->session, drvc->sr_ctx);
return;
}
read_offset %= SAMPLE_BUF_SIZE;
}
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
static uint32_t transform_sample_count(struct dev_context *devc,
SR_PRIV void stop_acquisition(const struct sr_dev_inst *sdi)
{
- struct sr_datafeed_packet packet;
struct dev_context *devc;
devc = sdi->priv;
serial_source_remove(sdi->session, devc->serial);
- /* Terminate session */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
SR_PRIV int mso_clkrate_out(struct sr_serial_dev_inst *serial, uint16_t val)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct sr_modbus_dev_inst *modbus;
- struct sr_datafeed_packet packet;
(void)cb_data;
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- /* End of last frame. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
modbus = sdi->conn;
sr_modbus_source_remove(sdi->session, modbus);
SR_PRIV void abort_acquisition(const struct sr_dev_inst *sdi)
{
- struct sr_datafeed_packet packet;
struct sr_serial_dev_inst *serial;
serial = sdi->conn;
serial_source_remove(sdi->session, serial);
- /* Terminate session */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;
- struct sr_datafeed_packet packet;
devc = sdi->priv;
sr_session_source_remove(sdi->session, -1);
- /* Send end packet to the session bus. */
- sr_dbg("Sending SR_DF_END.");
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
return SR_OK;
}
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
- struct sr_datafeed_packet packet;
(void)cb_data;
return SR_ERR;
}
- /* End of last frame. */
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
g_slist_free(devc->enabled_channels);
devc->enabled_channels = NULL;
static void finish_acquisition(struct sr_dev_inst *sdi)
{
- struct sr_datafeed_packet packet;
struct dev_context *devc;
devc = sdi->priv;
- /* Terminate session. */
- packet.type = SR_DF_END;
- sr_session_send(devc->cb_data, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
/* Remove fds from polling. */
usb_source_remove(sdi->session, devc->ctx);
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
struct sr_scpi_dev_inst *scpi;
float f;
sr_scpi_get_float(scpi, NULL, &f);
sr_scpi_source_remove(sdi->session, scpi);
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return SR_OK;
}
struct dev_context *devc;
struct drv_context *drvc;
struct timeval tv;
- struct sr_datafeed_packet packet;
int ret;
(void)fd;
/* We are done, clean up and send end packet to session bus. */
clear_acquisition_state(sdi);
-
- packet.type = SR_DF_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
return G_SOURCE_REMOVE;
}
struct sr_dev_driver *di;
struct dev_context *devc;
struct drv_context *drvc;
- struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct timeval tv;
gint64 now;
if (sdi->status == SR_ST_STOPPING) {
usb_source_remove(sdi->session, drvc->sr_ctx);
-
dev_close(sdi);
-
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
memset(&tv, 0, sizeof(struct timeval));
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
- struct sr_datafeed_packet packet;
-
(void)cb_data;
sr_dbg("Stopping acquisition.");
-
- /* Send end packet to the session bus. */
- sr_dbg("Sending SR_DF_END.");
- packet.type = SR_DF_END;
- sr_session_send(sdi, &packet);
-
+ std_session_send_df_end(sdi, LOG_PREFIX);
sr_session_source_remove(sdi->session, -1);
return SR_OK;
struct dev_context *devc;
struct sr_dev_driver *di;
struct sr_dev_inst *sdi;
- struct sr_datafeed_packet packet;
struct sr_usb_dev_inst *usb;
struct timeval tv;
int len, ret;
if (sdi->status == SR_ST_STOPPING) {
usb_source_remove(sdi->session, drvc->sr_ctx);
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_header(cb_data, LOG_PREFIX);
/* Tell the device to stop sending USB packets. */
usb = sdi->conn;
{
struct dev_context *devc;
struct drv_context *drvc;
- struct sr_datafeed_packet packet;
struct sr_dev_inst *sdi;
struct sr_dev_driver *di;
struct timeval tv;
if (sdi->status == SR_ST_STOPPING) {
usb_source_remove(sdi->session, drvc->sr_ctx);
-
dev_close(sdi);
-
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
}
memset(&tv, 0, sizeof(struct timeval));
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
struct dev_context *devc;
- struct sr_datafeed_packet packet;
(void)cb_data;
- packet.type = SR_DF_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+ std_session_send_df_end(sdi, LOG_PREFIX);
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
/* Check for empty capture */
if ((status & STATUS_READY) && !stop_address) {
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
return SR_OK;
}
analyzer_read_stop(usb->devhdl);
g_free(buf);
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
return SR_OK;
}
{
struct dev_context *devc;
struct sr_usb_dev_inst *usb;
- struct sr_datafeed_packet packet;
- packet.type = SR_DF_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_end(cb_data, LOG_PREFIX);
if (!(devc = sdi->priv)) {
sr_err("%s: sdi->priv was NULL", __func__);
static int end(struct sr_input *in)
{
struct context *inc;
- struct sr_datafeed_packet packet;
int ret;
if (in->sdi_ready)
ret = SR_OK;
inc = in->priv;
- if (inc->started) {
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
static int end(struct sr_input *in)
{
struct context *inc;
- struct sr_datafeed_packet packet;
int ret;
if (in->sdi_ready)
ret = SR_OK;
inc = in->priv;
- if (inc->started) {
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
static int end(struct sr_input *in)
{
struct context *inc;
- struct sr_datafeed_packet packet;
int ret;
if (in->sdi_ready)
ret = SR_OK;
inc = in->priv;
- if (inc->started) {
- /* End of stream. */
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
static int end(struct sr_input *in)
{
- struct sr_datafeed_packet packet;
struct context *inc;
int ret;
ret = SR_OK;
inc = in->priv;
- if (inc->started) {
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
static int end(struct sr_input *in)
{
struct context *inc;
- struct sr_datafeed_packet packet;
int ret;
inc = in->priv;
flush_output_buffer(in);
- if (inc->meta_sent) {
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->meta_sent)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
static int end(struct sr_input *in)
{
- struct sr_datafeed_packet packet;
struct context *inc;
int ret;
/* Send any samples that haven't been sent yet. */
send_buffer(in);
- if (inc->started) {
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
static int end(struct sr_input *in)
{
- struct sr_datafeed_packet packet;
struct context *inc;
int ret;
ret = SR_OK;
inc = in->priv;
- if (inc->started) {
- packet.type = SR_DF_END;
- sr_session_send(in->sdi, &packet);
- }
+ if (inc->started)
+ std_session_send_df_end(in->sdi, LOG_PREFIX);
return ret;
}
#endif
SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
const char *prefix);
+SR_PRIV int std_session_send_df_end(const struct sr_dev_inst *sdi,
+ const char *prefix);
SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
std_dev_clear_callback clear_private);
SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi);
{
struct sr_dev_inst *sdi;
struct session_vdev *vdev;
- struct sr_datafeed_packet packet;
(void)fd;
(void)revents;
zip_discard(vdev->archive);
vdev->archive = NULL;
}
- packet.type = SR_DF_END;
- packet.payload = NULL;
- sr_session_send(sdi, &packet);
+
+ std_session_send_df_end(sdi, LOG_PREFIX);
return G_SOURCE_REMOVE;
}
return SR_OK;
}
+/**
+ * Standard API helper for sending an SR_DF_END packet.
+ *
+ * @param sdi The device instance to use. Must not be NULL.
+ * @param prefix A driver-specific prefix string used for log messages.
+ * Must not be NULL. An empty string is allowed.
+ *
+ * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
+ * SR_ERR upon other errors.
+ */
+SR_PRIV int std_session_send_df_end(const struct sr_dev_inst *sdi,
+ const char *prefix)
+{
+ int ret;
+ struct sr_datafeed_packet packet;
+
+ if (!sdi || !prefix)
+ return SR_ERR_ARG;
+
+ sr_dbg("%s: Sending SR_DF_END packet.", prefix);
+
+ packet.type = SR_DF_END;
+ packet.payload = NULL;
+
+ if ((ret = sr_session_send(sdi, &packet)) < 0) {
+ sr_err("%s: Failed to send SR_DF_END packet: %d.", prefix, ret);
+ return ret;
+ }
+
+ return SR_OK;
+}
+
#ifdef HAVE_LIBSERIALPORT
/**
struct sr_serial_dev_inst *serial, const char *prefix)
{
int ret;
- struct sr_datafeed_packet packet;
if (!prefix) {
sr_err("Invalid prefix.");
return ret;
}
- /* Send SR_DF_END packet to the session bus. */
- sr_dbg("%s: Sending SR_DF_END packet.", prefix);
- packet.type = SR_DF_END;
- packet.payload = NULL;
- if ((ret = sr_session_send(cb_data, &packet)) < 0) {
- sr_err("%s: Failed to send SR_DF_END packet: %d.", prefix, ret);
- return ret;
- }
+ std_session_send_df_end(cb_data, prefix);
return SR_OK;
}