From: Soeren Apel Date: Fri, 8 Jan 2016 22:00:55 +0000 (+0100) Subject: Trace32 import module: Send trigger only once X-Git-Tag: libsigrok-0.4.0~26 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=a5be5d5bc008ebdab19b7ed2efe5e5a5b99bb349;ds=sidebyside Trace32 import module: Send trigger only once 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. --- diff --git a/src/input/trace32_ad.c b/src/input/trace32_ad.c index 06fc5214..81df295a 100644 --- a/src/input/trace32_ad.c +++ b/src/input/trace32_ad.c @@ -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? */