Factor out std_session_send_df_end() helper.
This makes the code shorter, simpler and more consistent, and also ensures that the (same) debug messages are always emitted and the packet.payload field is consistently set to NULL always, etc.
This commit is contained in:
parent
7fb90f94d6
commit
3be42bc22f
|
@ -835,7 +835,6 @@ static int download_capture(struct sr_dev_inst *sdi)
|
|||
struct sigma_dram_line *dram_line;
|
||||
int bufsz;
|
||||
uint32_t stoppos, triggerpos;
|
||||
struct sr_datafeed_packet packet;
|
||||
uint8_t modestatus;
|
||||
|
||||
uint32_t i;
|
||||
|
@ -907,9 +906,7 @@ static int download_capture(struct sr_dev_inst *sdi)
|
|||
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);
|
||||
|
||||
|
|
|
@ -133,7 +133,6 @@ SR_PRIV int atten_pps3xxx_receive_data(int fd, int revents, void *cb_data)
|
|||
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;
|
||||
|
@ -156,8 +155,7 @@ SR_PRIV int atten_pps3xxx_receive_data(int fd, int revents, void *cb_data)
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -401,7 +401,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
|
@ -417,9 +416,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, 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);
|
||||
|
|
|
@ -384,7 +384,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
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;
|
||||
|
||||
|
@ -399,9 +398,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, 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;
|
||||
}
|
||||
|
|
|
@ -101,10 +101,7 @@ SR_PRIV int beaglelogic_receive_data(int fd, int revents, void *cb_data)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -273,16 +273,12 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -584,17 +584,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -880,17 +880,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -491,8 +491,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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)
|
||||
|
@ -501,10 +499,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, 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;
|
||||
}
|
||||
|
|
|
@ -748,7 +748,6 @@ static int start_transfers(const struct sr_dev_inst *sdi)
|
|||
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;
|
||||
|
||||
|
@ -757,8 +756,7 @@ static void LIBUSB_CALL dslogic_trigger_receive(struct libusb_transfer *transfer
|
|||
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);
|
||||
|
@ -775,7 +773,6 @@ static void LIBUSB_CALL dslogic_trigger_receive(struct libusb_transfer *transfer
|
|||
}
|
||||
|
||||
libusb_free_transfer(transfer);
|
||||
|
||||
}
|
||||
|
||||
static int dslogic_trigger_request(const struct sr_dev_inst *sdi)
|
||||
|
|
|
@ -326,14 +326,11 @@ SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc)
|
|||
|
||||
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);
|
||||
|
|
|
@ -251,8 +251,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -769,13 +769,10 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -732,7 +732,6 @@ static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount)
|
|||
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;
|
||||
|
@ -761,9 +760,7 @@ static int handle_event(int fd, int revents, void *cb_data)
|
|||
*/
|
||||
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;
|
||||
|
||||
|
|
|
@ -883,8 +883,7 @@ static int handle_event(int fd, int revents, void *cb_data)
|
|||
*/
|
||||
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;
|
||||
|
||||
|
|
|
@ -724,14 +724,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
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;
|
||||
|
|
|
@ -28,15 +28,13 @@ static void stop_acquisition(struct sr_dev_inst *sdi)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
@ -45,15 +43,13 @@ static void abort_acquisition(struct sr_dev_inst *sdi)
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -390,17 +390,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -462,8 +462,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
|
|||
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;
|
||||
|
@ -54,8 +53,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);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -369,8 +369,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -477,7 +477,6 @@ 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 drv_context *drvc = di->context;
|
||||
struct sr_datafeed_packet packet;
|
||||
struct sr_dev_inst *sdi;
|
||||
struct timeval tv;
|
||||
|
||||
|
@ -488,9 +487,7 @@ SR_PRIV int lascar_el_usb_handle_events(int fd, int revents, void *cb_data)
|
|||
|
||||
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));
|
||||
|
|
|
@ -912,15 +912,13 @@ static void LIBUSB_CALL recv_intr_transfer(struct libusb_transfer *xfer)
|
|||
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;
|
||||
}
|
||||
|
@ -1091,8 +1089,7 @@ static void LIBUSB_CALL recv_bulk_transfer(struct libusb_transfer *xfer)
|
|||
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,
|
||||
|
|
|
@ -286,15 +286,12 @@ SR_PRIV int mso_toggle_led(struct sr_dev_inst *sdi, int state)
|
|||
|
||||
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)
|
||||
|
|
|
@ -484,16 +484,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
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);
|
||||
|
|
|
@ -315,15 +315,12 @@ SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi,
|
|||
|
||||
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)
|
||||
|
|
|
@ -702,7 +702,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
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;
|
||||
|
||||
|
@ -715,10 +714,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1050,7 +1050,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
{
|
||||
struct dev_context *devc;
|
||||
struct sr_scpi_dev_inst *scpi;
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
(void)cb_data;
|
||||
|
||||
|
@ -1061,9 +1060,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, 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;
|
||||
|
|
|
@ -757,14 +757,11 @@ SR_PRIV int logic16_init_device(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(devc->cb_data, &packet);
|
||||
std_session_send_df_end(sdi, LOG_PREFIX);
|
||||
|
||||
/* Remove fds from polling. */
|
||||
usb_source_remove(sdi->session, devc->ctx);
|
||||
|
|
|
@ -618,7 +618,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
|
||||
|
@ -637,8 +636,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -277,7 +277,6 @@ static int transfer_event(int fd, int revents, void *cb_data)
|
|||
struct dev_context *devc;
|
||||
struct drv_context *drvc;
|
||||
struct timeval tv;
|
||||
struct sr_datafeed_packet packet;
|
||||
int ret;
|
||||
|
||||
(void)fd;
|
||||
|
@ -317,10 +316,7 @@ static int transfer_event(int fd, int revents, void *cb_data)
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -413,7 +413,6 @@ static int handle_events(int fd, int revents, void *cb_data)
|
|||
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;
|
||||
|
@ -434,11 +433,8 @@ static int handle_events(int fd, int revents, void *cb_data)
|
|||
|
||||
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));
|
||||
|
|
|
@ -210,17 +210,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
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;
|
||||
|
|
|
@ -195,7 +195,6 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data)
|
|||
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;
|
||||
|
@ -219,8 +218,7 @@ SR_PRIV int uni_t_ut32x_handle_events(int fd, int revents, void *cb_data)
|
|||
|
||||
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;
|
||||
|
|
|
@ -327,7 +327,6 @@ static int handle_events(int fd, int revents, void *cb_data)
|
|||
{
|
||||
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;
|
||||
|
@ -349,11 +348,8 @@ static int handle_events(int fd, int revents, void *cb_data)
|
|||
|
||||
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));
|
||||
|
|
|
@ -676,13 +676,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, 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;
|
||||
|
||||
(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;
|
||||
|
|
|
@ -583,8 +583,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -692,8 +691,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
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;
|
||||
}
|
||||
|
@ -703,10 +701,8 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
{
|
||||
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__);
|
||||
|
|
|
@ -128,7 +128,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct context *inc;
|
||||
struct sr_datafeed_packet packet;
|
||||
int ret;
|
||||
|
||||
if (in->sdi_ready)
|
||||
|
@ -137,10 +136,8 @@ static int end(struct sr_input *in)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct context *inc;
|
||||
struct sr_datafeed_packet packet;
|
||||
int ret;
|
||||
|
||||
if (in->sdi_ready)
|
||||
|
@ -149,10 +148,8 @@ static int end(struct sr_input *in)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -738,7 +738,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct context *inc;
|
||||
struct sr_datafeed_packet packet;
|
||||
int ret;
|
||||
|
||||
if (in->sdi_ready)
|
||||
|
@ -747,11 +746,8 @@ static int end(struct sr_input *in)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -217,7 +217,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
|
||||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
struct context *inc;
|
||||
int ret;
|
||||
|
||||
|
@ -227,10 +226,8 @@ static int end(struct sr_input *in)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -731,7 +731,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct context *inc;
|
||||
struct sr_datafeed_packet packet;
|
||||
int ret;
|
||||
|
||||
inc = in->priv;
|
||||
|
@ -743,10 +742,8 @@ static int end(struct sr_input *in)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -582,7 +582,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
|
||||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
struct context *inc;
|
||||
int ret;
|
||||
|
||||
|
@ -596,10 +595,8 @@ static int end(struct sr_input *in)
|
|||
/* 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;
|
||||
}
|
||||
|
|
|
@ -341,7 +341,6 @@ static int receive(struct sr_input *in, GString *buf)
|
|||
|
||||
static int end(struct sr_input *in)
|
||||
{
|
||||
struct sr_datafeed_packet packet;
|
||||
struct context *inc;
|
||||
int ret;
|
||||
|
||||
|
@ -351,10 +350,8 @@ static int end(struct sr_input *in)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -857,6 +857,8 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,
|
|||
#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);
|
||||
|
|
|
@ -178,7 +178,6 @@ static int receive_data(int fd, int revents, void *cb_data)
|
|||
{
|
||||
struct sr_dev_inst *sdi;
|
||||
struct session_vdev *vdev;
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
(void)fd;
|
||||
(void)revents;
|
||||
|
@ -199,9 +198,8 @@ static int receive_data(int fd, int revents, void *cb_data)
|
|||
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;
|
||||
}
|
||||
|
|
42
src/std.c
42
src/std.c
|
@ -105,6 +105,38 @@ SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
|
|||
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
|
||||
|
||||
/**
|
||||
|
@ -183,7 +215,6 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,
|
|||
struct sr_serial_dev_inst *serial, const char *prefix)
|
||||
{
|
||||
int ret;
|
||||
struct sr_datafeed_packet packet;
|
||||
|
||||
if (!prefix) {
|
||||
sr_err("Invalid prefix.");
|
||||
|
@ -207,14 +238,7 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi,
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue