Module: xenomai-2.5
Branch: master
Commit: c9b9fd94ff03ff33afa2c12c3ce0a19d3a44030c
URL:    
http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=c9b9fd94ff03ff33afa2c12c3ce0a19d3a44030c

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Sat Feb  6 23:06:29 2010 +0100

analogy: adapt cmd_read after having fixed read and poll syscalls

---

 src/utils/analogy/cmd_read.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c
index 77ef4f8..1562a21 100644
--- a/src/utils/analogy/cmd_read.c
+++ b/src/utils/analogy/cmd_read.c
@@ -389,7 +389,7 @@ int main(int argc, char *argv[])
        if (use_mmap == 0) {
 
                /* Fetch data */
-               while (cnt < cmd.stop_arg * scan_size) {
+               do {
 
                        /* Perform the read operation */
                        ret = a4l_sys_read(dsc.fd, buf, BUF_SIZE);
@@ -401,7 +401,7 @@ int main(int argc, char *argv[])
                        }
 
                        /* Display the results */
-                       if(dump_function(&dsc, &cmd, buf, ret) < 0) {
+                       if (dump_function(&dsc, &cmd, buf, ret) < 0) {
                                ret = -EIO;
                                goto out_main;
                        }
@@ -418,19 +418,21 @@ int main(int argc, char *argv[])
                                        goto out_main;
                                }
                        }
-               }
+               } while (ret > 0);
 
        } else {
                unsigned long front = 0;
 
                /* Fetch data without any memcpy */
-               while (cnt < cmd.stop_arg * scan_size) {
+               do {
 
                        /* Retrieve and update the buffer's state
                           (In input case, we recover how many bytes are 
available
                           to read) */
                        ret = a4l_mark_bufrw(&dsc, cmd.idx_subd, front, &front);
-                       if (ret < 0) {
+                       if (ret == -ENOENT)
+                               break;
+                       else if (ret < 0) {
                                fprintf(stderr,
                                        "cmd_read: a4l_mark_bufrw() failed 
(ret=%d)\n",
                                        ret);
@@ -443,7 +445,9 @@ int main(int argc, char *argv[])
                           the data read counter) */
                        if (front == 0) {
                                ret = a4l_poll(&dsc, cmd.idx_subd, 
A4L_INFINITE);
-                               if (ret < 0) {
+                               if (ret == 0)
+                                       break;
+                               else if (ret < 0) {
                                        fprintf(stderr,
                                                "cmd_read: a4l_poll() failed 
(ret=%d)\n",
                                                ret);
@@ -472,7 +476,8 @@ int main(int argc, char *argv[])
 
                        /* Update the counter */
                        cnt += front;
-               }
+
+               } while (1);
        }
 
        if (verbose != 0)


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

Reply via email to