Module: xenomai-abe
Branch: analogy
Commit: 33f8d9db31c73db1e942066a3f6a1daf539896c2
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=33f8d9db31c73db1e942066a3f6a1daf539896c2

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Wed Apr 21 00:28:01 2010 +0200

analogy: add triggering in cmd_bits

---

 src/utils/analogy/cmd_bits.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/utils/analogy/cmd_bits.c b/src/utils/analogy/cmd_bits.c
index 0afb69f..aa0e082 100644
--- a/src/utils/analogy/cmd_bits.c
+++ b/src/utils/analogy/cmd_bits.c
@@ -56,6 +56,12 @@ a4l_cmd_t cmd = {
        .chan_descs = chans,
 };
 
+a4l_insn_t insn = {
+       .type = A4L_INSN_INTTRIG,
+       .idx_subd = -1,
+       .data_size = 0,
+};
+
 struct option cmd_bits_opts[] = {
        {"verbose", no_argument, NULL, 'v'},
        {"device", required_argument, NULL, 'd'},
@@ -83,6 +89,9 @@ int main(int argc, char *argv[])
        int scan_size, idx_subd = -1;
        int value, mask = 0;
 
+       /* Trigger status, written data..., before triggering */
+       int triggered = 0, total = 0, trigger_threshold = 128;
+
        /* Compute arguments */
        while ((err = getopt_long(argc,
                                  argv,
@@ -185,7 +194,7 @@ int main(int argc, char *argv[])
                goto out_cmd_bits;
        }
 
-       cmd.idx_subd = idx_subd;
+       cmd.idx_subd = insn.idx_subd = idx_subd;
 
        if ((sbinfo->flags & A4L_SUBD_TYPES) != A4L_SUBD_DIO &&
            (sbinfo->flags & A4L_SUBD_TYPES) != A4L_SUBD_DO) {
@@ -240,6 +249,18 @@ int main(int argc, char *argv[])
                                "cmd_bits: a4l_write failed (err=%d)\n", err);
                        goto out_cmd_bits;
                }
+               
+               total += err;
+
+               if (!triggered && total > trigger_threshold) {
+                       err = a4l_snd_insn(&dsc, &insn);
+                       if (err < 0) {
+                               fprintf(stderr, 
+                                       "cmd_bits: triggering failed 
(err=%d)\n",
+                                       err);
+                               goto out_cmd_bits;
+                       }
+               }
 
        } while (err > 0);              
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to