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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Sep 24 15:24:44 2014 +0200

demo/alchemy/cross-link: fix RTDM calls

---

 demo/alchemy/cobalt/Makefile.am  |    3 +++
 demo/alchemy/cobalt/Makefile.in  |   10 ++++++----
 demo/alchemy/cobalt/cross-link.c |   41 +++++++++++++++++++-------------------
 3 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/demo/alchemy/cobalt/Makefile.am b/demo/alchemy/cobalt/Makefile.am
index 0fbd30e..c9b79c0 100644
--- a/demo/alchemy/cobalt/Makefile.am
+++ b/demo/alchemy/cobalt/Makefile.am
@@ -1,5 +1,7 @@
 demodir = @XENO_DEMO_DIR@
 
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
 demo_PROGRAMS = cross-link
 
 cppflags =                     \
@@ -10,6 +12,7 @@ ldadd =                                               \
        ../../../lib/alchemy/libalchemy.la              \
        ../../../lib/copperplate/libcopperplate.la      \
        ../../../lib/cobalt/libcobalt.la                \
+       $(XENO_POSIX_WRAPPERS)                          \
         @XENO_USER_LDADD@                              \
        -lpthread -lrt
 
diff --git a/demo/alchemy/cobalt/Makefile.in b/demo/alchemy/cobalt/Makefile.in
index c476b29..1c8a158 100644
--- a/demo/alchemy/cobalt/Makefile.in
+++ b/demo/alchemy/cobalt/Makefile.in
@@ -101,10 +101,11 @@ am__installdirs = "$(DESTDIR)$(demodir)"
 PROGRAMS = $(demo_PROGRAMS)
 am_cross_link_OBJECTS = cross_link-cross-link.$(OBJEXT)
 cross_link_OBJECTS = $(am_cross_link_OBJECTS)
-am__DEPENDENCIES_1 = ../../../lib/alchemy/libalchemy.la \
+am__DEPENDENCIES_1 =
+am__DEPENDENCIES_2 = ../../../lib/alchemy/libalchemy.la \
        ../../../lib/copperplate/libcopperplate.la \
-       ../../../lib/cobalt/libcobalt.la
-cross_link_DEPENDENCIES = $(am__DEPENDENCIES_1)
+       ../../../lib/cobalt/libcobalt.la $(am__DEPENDENCIES_1)
+cross_link_DEPENDENCIES = $(am__DEPENDENCIES_2)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
@@ -135,7 +136,6 @@ AM_V_CC = $(am__v_CC_@AM_V@)
 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
 am__v_CC_0 = @echo "  CC      " $@;
 am__v_CC_1 = 
-CCLD = $(CC)
 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@
@@ -337,6 +337,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 demodir = @XENO_DEMO_DIR@
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
 cppflags = \
        $(XENO_USER_CFLAGS)     \
        -I$(top_srcdir)/include
@@ -345,6 +346,7 @@ ldadd = \
        ../../../lib/alchemy/libalchemy.la              \
        ../../../lib/copperplate/libcopperplate.la      \
        ../../../lib/cobalt/libcobalt.la                \
+       $(XENO_POSIX_WRAPPERS)                          \
         @XENO_USER_LDADD@                              \
        -lpthread -lrt
 
diff --git a/demo/alchemy/cobalt/cross-link.c b/demo/alchemy/cobalt/cross-link.c
index 0da2e98..8c0f53f 100644
--- a/demo/alchemy/cobalt/cross-link.c
+++ b/demo/alchemy/cobalt/cross-link.c
@@ -32,8 +32,8 @@
 #define WTASK_PREFIX  "write_task: "
 #define RTASK_PREFIX  "read_task: "
 
-#define WRITE_FILE    "rtser0"
-#define READ_FILE     "rtser1"
+#define WRITE_FILE    "/dev/rtdm/rtser0"
+#define READ_FILE     "/dev/rtdm/rtser1"
 
 int read_fd  = -1;
 int write_fd = -1;
@@ -77,7 +77,7 @@ static int close_file( int fd, char *name)
 
        do {
                i++;
-               err = rt_dev_close(fd);
+               err = close(fd);
                switch (err) {
                case -EAGAIN:
                        printf(MAIN_PREFIX "%s -> EAGAIN (%d times)\n",
@@ -155,9 +155,9 @@ static void write_task_proc(void *arg)
 
                write_time = rt_timer_read();
 
-               written = rt_dev_write(write_fd, &write_time, sz);
+               written = write(write_fd, &write_time, sz);
                if (written < 0 ) {
-                       printf(WTASK_PREFIX "error on rt_dev_write, %s\n",
+                       printf(WTASK_PREFIX "error on write, %s\n",
                               strerror(-err));
                        break;
                } else if (written != sz) {
@@ -183,7 +183,7 @@ static void read_task_proc(void *arg)
        RTIME write_time = 0;
        RTIME irq_time   = 0;
        ssize_t sz = sizeof(RTIME);
-       int read = 0;
+       int rd = 0;
        struct rtser_event rx_event;
 
        printf(" Nr |   write->irq    |    irq->read    |   write->read   |\n");
@@ -197,7 +197,7 @@ static void read_task_proc(void *arg)
 
        while (1) {
                /* waiting for event */
-               err = rt_dev_ioctl(read_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event);
+               err = ioctl(read_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event);
                if (err) {
                        printf(RTASK_PREFIX
                               "error on RTSER_RTIOC_WAIT_EVENT, %s\n",
@@ -208,21 +208,21 @@ static void read_task_proc(void *arg)
                }
 
                irq_time = rx_event.rxpend_timestamp;
-               read = rt_dev_read(read_fd, &write_time, sz);
-               if (read == sz) {
+               rd = read(read_fd, &write_time, sz);
+               if (rd == sz) {
                        read_time = rt_timer_read();
                        printf("%3d |%16llu |%16llu |%16llu\n", nr,
                               irq_time  - write_time,
                               read_time - irq_time,
                               read_time - write_time);
                        nr++;
-               } else if (read < 0 ) {
-                       printf(RTASK_PREFIX "error on rt_dev_read, code %s\n",
+               } else if (rd < 0 ) {
+                       printf(RTASK_PREFIX "error on read, code %s\n",
                               strerror(-err));
                        break;
                } else {
                        printf(RTASK_PREFIX "only %d / %zd byte received \n",
-                              read, sz);
+                              rd, sz);
                        break;
                }
        }
@@ -241,11 +241,8 @@ int main(int argc, char* argv[])
        signal(SIGTERM, catch_signal);
        signal(SIGINT, catch_signal);
 
-       /* no memory-swapping for this programm */
-       mlockall(MCL_CURRENT | MCL_FUTURE);
-
        /* open rtser0 */
-       write_fd = rt_dev_open( WRITE_FILE, 0);
+       write_fd = open( WRITE_FILE, 0);
        if (write_fd < 0) {
                printf(MAIN_PREFIX "can't open %s (write), %s\n", WRITE_FILE,
                       strerror(-write_fd));
@@ -255,7 +252,7 @@ int main(int argc, char* argv[])
        printf(MAIN_PREFIX "write-file opened\n");
 
        /* writing write-config */
-       err = rt_dev_ioctl(write_fd, RTSER_RTIOC_SET_CONFIG, &write_config);
+       err = ioctl(write_fd, RTSER_RTIOC_SET_CONFIG, &write_config);
        if (err) {
                printf(MAIN_PREFIX "error while RTSER_RTIOC_SET_CONFIG, %s\n",
                       strerror(-err));
@@ -264,7 +261,7 @@ int main(int argc, char* argv[])
        printf(MAIN_PREFIX "write-config written\n");
 
        /* open rtser1 */
-       read_fd = rt_dev_open( READ_FILE, 0 );
+       read_fd = open( READ_FILE, 0 );
        if (read_fd < 0) {
                printf(MAIN_PREFIX "can't open %s (read), %s\n", READ_FILE,
                       strerror(-read_fd));
@@ -274,9 +271,9 @@ int main(int argc, char* argv[])
        printf(MAIN_PREFIX "read-file opened\n");
 
        /* writing read-config */
-       err = rt_dev_ioctl(read_fd, RTSER_RTIOC_SET_CONFIG, &read_config);
+       err = ioctl(read_fd, RTSER_RTIOC_SET_CONFIG, &read_config);
        if (err) {
-               printf(MAIN_PREFIX "error while rt_dev_ioctl, %s\n",
+               printf(MAIN_PREFIX "error while ioctl, %s\n",
                       strerror(-err));
                goto error;
        }
@@ -320,7 +317,9 @@ int main(int argc, char* argv[])
                goto error;
        }
 
-       pause();
+       for (;;)
+               pause();
+
        return 0;
 
  error:


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to