]> sigrok.org Git - libsigrok.git/commitdiff
Trace32 import module: Send trigger only once
authorSoeren Apel <redacted>
Fri, 8 Jan 2016 22:00:55 +0000 (23:00 +0100)
committerUwe Hermann <redacted>
Thu, 28 Jan 2016 18:03:52 +0000 (19:03 +0100)
As we're downsampling, several record time stamps can match the specified
trigger time. For this reason, it's possible that several trigger packets
are sent when a file is loaded. This prevents the issue and sends a
trigger packet only on the first matching record.

src/input/trace32_ad.c

index 06fc52146fd376c86f4b556d816791e91085011e..81df295a238ebf79b188720e787976f4fe41248a 100644 (file)
@@ -85,7 +85,7 @@ enum {
 
 struct context {
        gboolean meta_sent;
-       gboolean header_read, records_read;
+       gboolean header_read, records_read, trigger_sent;
        char format, device, record_mode, compression;
        char pod_status[MAX_POD_COUNT];
        struct sr_channel *channels[MAX_POD_COUNT][17]; /* 16 + CLK */
@@ -467,13 +467,14 @@ static void process_record_pi(struct sr_input *in, gsize start)
                return;
        }
 
-       if (timestamp == inc->trigger_timestamp) {
+       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);
+               inc->trigger_sent = TRUE;
        }
 
        /* Is this the last record in the file? */
@@ -519,13 +520,14 @@ static void process_record_iprobe(struct sr_input *in, gsize start)
        single_payload[2] = R8(in->buf->str + start + 10) & 1;
        payload_len = 3;
 
-       if (timestamp == inc->trigger_timestamp) {
+       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);
+               inc->trigger_sent = TRUE;
        }
 
        /* Is this the last record in the file? */