Multistage triggers currently do no work, because there is a return statement
in the middle of the trigger detector which will be hit as soon as the first
stage in a multistage trigger matches. This patch removes the return statement
so that the trigger detector can continue to try to match the next stage. In
order for this to work we also make sure that the trigger stage is only reset
if the current sample does not match.

Signed-off-by: Lars-Peter Clausen <[email protected]>
---
 libsigrok/hardware/fx2lafw/fx2lafw.c |   19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/libsigrok/hardware/fx2lafw/fx2lafw.c 
b/libsigrok/hardware/fx2lafw/fx2lafw.c
index aa8331f..5d8b49b 100644
--- a/libsigrok/hardware/fx2lafw/fx2lafw.c
+++ b/libsigrok/hardware/fx2lafw/fx2lafw.c
@@ -772,17 +772,14 @@ static void receive_transfer(struct libusb_transfer 
*transfer)
                                        ctx->trigger_stage = TRIGGER_FIRED;
                                        break;
                                }
-                               return;
-                       }
-
-                       /*
-                        * We had a match before, but not in the next sample. 
However, we may
-                        * have a match on this stage in the next bit -- 
trigger on 0001 will
-                        * fail on seeing 00001, so we need to go back to stage 
0 -- but at
-                        * the next sample from the one that matched 
originally, which the
-                        * counter increment at the end of the loop takes care 
of.
-                        */
-                       if (ctx->trigger_stage > 0) {
+                       } else if (ctx->trigger_stage > 0) {
+                               /*
+                                * We had a match before, but not in the next 
sample. However, we may
+                                * have a match on this stage in the next bit 
-- trigger on 0001 will
+                                * fail on seeing 00001, so we need to go back 
to stage 0 -- but at
+                                * the next sample from the one that matched 
originally, which the
+                                * counter increment at the end of the loop 
takes care of.
+                                */
                                i -= ctx->trigger_stage;
                                if (i < -1)
                                        i = -1; /* Oops, went back past this 
buffer. */
-- 
1.7.10


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to