From: Uwe Hermann Date: Wed, 8 Apr 2020 21:21:39 +0000 (+0200) Subject: Use std_session_send_df_trigger() where possible. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0fa71943e34fbd427928eef13742958ec7e30834;p=libsigrok.git Use std_session_send_df_trigger() where possible. --- diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 3c29aad9..d040b37c 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -907,10 +907,8 @@ static void sigma_decode_dram_cluster(struct sigma_dram_cluster *dram_cluster, } /* Only send trigger if explicitly enabled. */ - if (devc->use_triggers) { - packet.type = SR_DF_TRIGGER; - sr_session_send(sdi, &packet); - } + if (devc->use_triggers) + std_session_send_df_trigger(sdi); } /* diff --git a/src/hardware/chronovu-la/protocol.c b/src/hardware/chronovu-la/protocol.c index 3966b99e..da772f5b 100644 --- a/src/hardware/chronovu-la/protocol.c +++ b/src/hardware/chronovu-la/protocol.c @@ -494,9 +494,7 @@ SR_PRIV void cv_send_block_to_session_bus(const struct sr_dev_inst *sdi, int blo /* Send the SR_DF_TRIGGER packet to the session bus. */ sr_spew("Sending SR_DF_TRIGGER packet, sample = %d.", (block * BS) + trigger_point); - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); /* If at least one sample is located after the trigger... */ if (trigger_point < (BS - 1)) { diff --git a/src/hardware/dreamsourcelab-dslogic/protocol.c b/src/hardware/dreamsourcelab-dslogic/protocol.c index 584f3b1b..bb98d61a 100644 --- a/src/hardware/dreamsourcelab-dslogic/protocol.c +++ b/src/hardware/dreamsourcelab-dslogic/protocol.c @@ -776,7 +776,6 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) (DSLOGIC_ATOMIC_BYTES * channel_count); gboolean packet_has_error = FALSE; - struct sr_datafeed_packet packet; unsigned int num_samples; int trigger_offset; @@ -856,9 +855,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer) devc->sent_samples += trigger_offset; /* Trigger position. */ devc->trigger_pos = 0; - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); /* Post trigger samples. */ num_samples -= trigger_offset; send_data(sdi, devc->deinterleave_buffer diff --git a/src/hardware/hantek-4032l/protocol.c b/src/hardware/hantek-4032l/protocol.c index f3167931..a5b90ac5 100644 --- a/src/hardware/hantek-4032l/protocol.c +++ b/src/hardware/hantek-4032l/protocol.c @@ -114,10 +114,6 @@ static void send_data(struct sr_dev_inst *sdi, .type = SR_DF_LOGIC, .payload = &logic }; - const struct sr_datafeed_packet trig = { - .type = SR_DF_TRIGGER, - .payload = NULL - }; size_t trigger_offset; if (devc->trigger_pos >= devc->sent_samples && @@ -129,7 +125,7 @@ static void send_data(struct sr_dev_inst *sdi, sr_session_send(sdi, &packet); /* Send trigger position. */ - sr_session_send(sdi, &trig); + std_session_send_df_trigger(sdi); /* Send rest of data. */ logic.length = (sample_count - trigger_offset) * sizeof(uint32_t); diff --git a/src/hardware/hung-chang-dso-2100/protocol.c b/src/hardware/hung-chang-dso-2100/protocol.c index 69efb14d..3df5b3f2 100644 --- a/src/hardware/hung-chang-dso-2100/protocol.c +++ b/src/hardware/hung-chang-dso-2100/protocol.c @@ -396,12 +396,8 @@ static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf) if (interleave) num *= 2; if (!devc->step) { - struct sr_datafeed_packet packet = { - .type = SR_DF_TRIGGER - }; - push_samples(sdi, buf, 6); - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); buf += 6; num -= 6; } diff --git a/src/hardware/ikalogic-scanalogic2/protocol.c b/src/hardware/ikalogic-scanalogic2/protocol.c index b1a85b03..f4ceb67a 100644 --- a/src/hardware/ikalogic-scanalogic2/protocol.c +++ b/src/hardware/ikalogic-scanalogic2/protocol.c @@ -122,10 +122,8 @@ static void process_sample_data(const struct sr_dev_inst *sdi) * through the capture ratio. */ if (devc->trigger_type != TRIGGER_TYPE_NONE && - devc->pre_trigger_samples == 0) { - packet.type = SR_DF_TRIGGER; - sr_session_send(sdi, &packet); - } + devc->pre_trigger_samples == 0) + std_session_send_df_trigger(sdi); } for (; k >= 0; k--) { @@ -164,8 +162,7 @@ static void process_sample_data(const struct sr_dev_inst *sdi) logic.data = buffer; sr_session_send(sdi, &packet); - packet.type = SR_DF_TRIGGER; - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); n = 0; } diff --git a/src/hardware/ipdbg-la/protocol.c b/src/hardware/ipdbg-la/protocol.c index df61b6ac..b125f1ef 100644 --- a/src/hardware/ipdbg-la/protocol.c +++ b/src/hardware/ipdbg-la/protocol.c @@ -338,8 +338,7 @@ SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data) } /* Send the trigger. */ - packet.type = SR_DF_TRIGGER; - sr_session_send(cb_data, &packet); + std_session_send_df_trigger(cb_data); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; diff --git a/src/hardware/lecroy-logicstudio/protocol.c b/src/hardware/lecroy-logicstudio/protocol.c index 7b3a41a6..b7bf8b59 100644 --- a/src/hardware/lecroy-logicstudio/protocol.c +++ b/src/hardware/lecroy-logicstudio/protocol.c @@ -1003,7 +1003,6 @@ static void LIBUSB_CALL recv_bulk_transfer(struct libusb_transfer *xfer) const struct sr_dev_inst *sdi; struct dev_context *devc; struct drv_context *drvc; - struct sr_datafeed_packet packet; uint32_t bytes_left, length; uint16_t read_offset, trigger_offset; @@ -1069,10 +1068,7 @@ static void LIBUSB_CALL recv_bulk_transfer(struct libusb_transfer *xfer) } /* Here comes the trigger. */ - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); /* Send post-trigger samples. */ while (bytes_left > 0) { diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index e6adae0a..7be70b3d 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -515,8 +515,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) } /* Send the trigger. */ - packet.type = SR_DF_TRIGGER; - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 62515050..f0ef6805 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -636,8 +636,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) } /* Send the trigger. */ - packet.type = SR_DF_TRIGGER; - sr_session_send(sdi, &packet); + std_session_send_df_trigger(sdi); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index 36aef795..9d15fe6c 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -583,12 +583,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) buf_offset += logic.length; } - if (samples_read == trigger_offset) { - /* Send out trigger */ - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(sdi, &packet); - } + if (samples_read == trigger_offset) + std_session_send_df_trigger(sdi); /* Send out data (or data after trigger) */ packet.type = SR_DF_LOGIC; diff --git a/src/input/trace32_ad.c b/src/input/trace32_ad.c index c55568ed..46a15ca6 100644 --- a/src/input/trace32_ad.c +++ b/src/input/trace32_ad.c @@ -447,7 +447,6 @@ static void flush_output_buffer(struct sr_input *in) static void process_record_pi(struct sr_input *in, gsize start) { - struct sr_datafeed_packet packet; struct context *inc; uint64_t timestamp, next_timestamp; uint32_t pod_data; @@ -580,10 +579,7 @@ static void process_record_pi(struct sr_input *in, gsize start) if (timestamp == inc->trigger_timestamp && !inc->trigger_sent) { sr_dbg("Trigger @%lf s, record #%d.", timestamp * TIMESTAMP_RESOLUTION, inc->cur_record); - - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(in->sdi, &packet); + std_session_send_df_trigger(in->sdi); inc->trigger_sent = TRUE; } @@ -610,7 +606,6 @@ static void process_record_pi(struct sr_input *in, gsize start) static void process_record_iprobe(struct sr_input *in, gsize start) { - struct sr_datafeed_packet packet; struct context *inc; uint64_t timestamp, next_timestamp; char single_payload[3]; @@ -633,10 +628,7 @@ static void process_record_iprobe(struct sr_input *in, gsize start) if (timestamp == inc->trigger_timestamp && !inc->trigger_sent) { sr_dbg("Trigger @%lf s, record #%d.", timestamp * TIMESTAMP_RESOLUTION, inc->cur_record); - - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(in->sdi, &packet); + std_session_send_df_trigger(in->sdi); inc->trigger_sent = TRUE; } diff --git a/src/soft-trigger.c b/src/soft-trigger.c index 0c5bb466..1f81fae5 100644 --- a/src/soft-trigger.c +++ b/src/soft-trigger.c @@ -175,7 +175,6 @@ static gboolean logic_check_match(struct soft_trigger_logic *stl, SR_PRIV int soft_trigger_logic_check(struct soft_trigger_logic *stl, uint8_t *buf, int len, int *pre_trigger_samples) { - struct sr_datafeed_packet packet; struct sr_trigger_stage *stage; struct sr_trigger_match *match; GSList *l, *l_stage; @@ -216,9 +215,7 @@ SR_PRIV int soft_trigger_logic_check(struct soft_trigger_logic *stl, /* Fire trigger. */ offset = i / stl->unitsize; - packet.type = SR_DF_TRIGGER; - packet.payload = NULL; - sr_session_send(stl->sdi, &packet); + std_session_send_df_trigger(stl->sdi); break; } } else if (stl->cur_stage > 0) {