Working RTAI LXRT example
authorAndreas Stewering-Bone <ab@igh-essen.com>
Wed, 23 Mar 2011 08:06:58 +0100
changeset 2059 ab0b96ac18bb
parent 2058 543c4ce9e86e
child 2060 8b67602f5161
Working RTAI LXRT example
Add README's for RTDM examples
FEATURES
examples/rtai_rtdm/Makefile.am
examples/rtai_rtdm/README
examples/rtai_rtdm/main.c
examples/xenomai/Makefile.am
examples/xenomai/README
examples/xenomai_posix/Makefile.am
examples/xenomai_posix/README
--- a/FEATURES	Tue Mar 22 09:15:19 2011 +0100
+++ b/FEATURES	Wed Mar 23 08:06:58 2011 +0100
@@ -27,6 +27,7 @@
 
 * Supports any realtime environment through independent architecture.
   - RTAI, Xenomai, RT-Preempt, etc.
+  - RTDM Interface for userspace realtime enviroments
   - Operation possible without any realtime extension at all.
 
 * Common API for Realtime-Applications in kernel- and userspace.
--- a/examples/rtai_rtdm/Makefile.am	Tue Mar 22 09:15:19 2011 +0100
+++ b/examples/rtai_rtdm/Makefile.am	Wed Mar 23 08:06:58 2011 +0100
@@ -33,8 +33,8 @@
 noinst_PROGRAMS = ec_rtai_rtdm_example
 
 ec_rtai_rtdm_example_SOURCES = main.c
-ec_rtai_rtdm_example_CFLAGS = -I. -I/opt/etherlab/rtai/include -O2 -I/home/ab/Download/rtai/linux-2.6.32.11/include -Wall -Wstrict-prototypes -pipe -I$(top_srcdir)/include
-ec_rtai_rtdm_example_LDFLAGS = -L/opt/etherlab/rtai/lib -llxrt -lrtdm -lpthread -L$(top_builddir)/lib/.libs -lethercat 
+ec_rtai_rtdm_example_CFLAGS = -I. -I"$(RTAI_DIR)"/include -O2 -I"$(LINUX_SOURCE_DIR)"/include -Wall -Wstrict-prototypes -pipe -I$(top_srcdir)/include
+ec_rtai_rtdm_example_LDFLAGS = -L"$(RTAI_DIR)"/lib -llxrt -lrtdm -lpthread -L$(top_builddir)/lib/.libs -lethercat 
 
 
 #------------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/rtai_rtdm/README	Wed Mar 23 08:06:58 2011 +0100
@@ -0,0 +1,40 @@
+-------------------------------------------------------------------------------
+
+$Id$
+
+-------------------------------------------------------------------------------
+
+This is a minimal example application for the use of the EtherCAT
+master realtime RTDM interface with an RTAI-LXRT thread.
+
+The application expects an RTAI installation. Configure the master sources
+specifying --enable-rtdm --with-rtai-dir to have the right include paths.
+
+Most probably you'll have different EtherCAT slaves present. Try adjusting the
+section "process data" in main.c to your bus configuration.
+
+There are some features that can be disabled by commenting out the respective
+defines at the head of main.c.
+
+---
+
+To build the example, call:
+
+make 
+
+To run it, load the appropriate RTAI modules:
+insmod $(RTAI_DIR)/modules/rtai_hal.ko
+insmod $(RTAI_DIR)/modules/rtai_lxrt.ko
+insmod $(RTAI_DIR)/modules/rtai_sem.ko
+insmod $(RTAI_DIR)/modules/rtai_rtdm.ko
+
+Preload the EtherCAT RTDM module:
+modprobe ec_rtdm
+
+and call as root:
+
+./ec_rtai_rtdm_example
+
+...and watch the system logs for the outputs.
+
+-------------------------------------------------------------------------------
--- a/examples/rtai_rtdm/main.c	Tue Mar 22 09:15:19 2011 +0100
+++ b/examples/rtai_rtdm/main.c	Wed Mar 23 08:06:58 2011 +0100
@@ -447,16 +447,17 @@
 
 
 
-void rt_sync()
+void rt_sync(void)
 {
 
-  uint64_t now_ns;
-  now_ns =  rt_get_real_time_ns();
-
+  RTIME now_ns;
+  uint64_t now;
+  now_ns = rt_get_cpu_time_ns();
+  now = (uint64_t)now_ns;
 
   if (rt_fd>=0)
   {
-      ecrt_rtdm_master_application_time(rt_fd, &now_ns);
+      ecrt_rtdm_master_application_time(rt_fd, &now);
   }
 
   if (sync_ref_counter) {
@@ -503,6 +504,8 @@
     period = (int) nano2count((RTIME)cycle*1000);
     start_rt_timer(period);
     rt_make_hard_real_time();
+    rt_task_make_periodic(task, rt_get_time() + 10*period, period);
+
 
 
     while(1) {
@@ -517,6 +520,7 @@
 
         if(run ==  0) {
             rt_make_soft_real_time();
+            stop_rt_timer();
             return;
         }
 
--- a/examples/xenomai/Makefile.am	Tue Mar 22 09:15:19 2011 +0100
+++ b/examples/xenomai/Makefile.am	Wed Mar 23 08:06:58 2011 +0100
@@ -33,7 +33,7 @@
 noinst_PROGRAMS = ec_xenomai_example
 
 ec_xenomai_example_SOURCES = main.c
-ec_xenomai_example_CFLAGS = -I/opt/etherlab/xenomai/include -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -I$(top_srcdir)/include
-ec_xenomai_example_LDFLAGS = -lrtdm -L$(top_builddir)/lib/.libs -lethercat -lnative -L/opt/etherlab/xenomai/lib -lrtdk -lxenomai -lpthread
+ec_xenomai_example_CFLAGS = -I"$(XENOMAI_DIR)"/include -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -I$(top_srcdir)/include
+ec_xenomai_example_LDFLAGS = -lrtdm -L$(top_builddir)/lib/.libs -lethercat -lnative -L"$(XENOMAI_DIR)"/lib -lrtdk -lxenomai -lpthread
 
 #------------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/xenomai/README	Wed Mar 23 08:06:58 2011 +0100
@@ -0,0 +1,35 @@
+-------------------------------------------------------------------------------
+
+$Id$
+
+-------------------------------------------------------------------------------
+
+This is a minimal example application for the use of the EtherCAT
+master realtime RTDM interface with an XENOMAI NATIVE thread.
+
+The application expects an XENOMAI installation. Configure the master sources
+specifying --enable-rtdm --with-xenomai-dir to have the right include paths.
+
+Most probably you'll have different EtherCAT slaves present. Try adjusting the
+section "process data" in main.c to your bus configuration.
+
+There are some features that can be disabled by commenting out the respective
+defines at the head of main.c.
+
+---
+
+To build the example, call:
+
+make 
+
+To run it, preload the EtherCAT RTDM module:
+
+modprobe ec_rtdm
+
+and call as root:
+
+./ec_xenomai_example
+
+...and watch the system logs for the outputs.
+
+-------------------------------------------------------------------------------
--- a/examples/xenomai_posix/Makefile.am	Tue Mar 22 09:15:19 2011 +0100
+++ b/examples/xenomai_posix/Makefile.am	Wed Mar 23 08:06:58 2011 +0100
@@ -33,8 +33,8 @@
 noinst_PROGRAMS = ec_xenomai_posix_example
 
 ec_xenomai_posix_example_SOURCES = main.c
-ec_xenomai_posix_example_CFLAGS = -I/opt/etherlab/xenomai/include -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -I/opt/etherlab/xenomai/include/posix -I$(top_srcdir)/include
-ec_xenomai_posix_example_LDFLAGS = -Wl,@/opt/etherlab/xenomai/lib/posix.wrappers -L/opt/etherlab/xenomai/lib -lpthread_rt -lrtdm -L$(top_builddir)/lib/.libs -lethercat -L/opt/etherlab/xenomai/lib -lrtdk -lxenomai -lpthread
+ec_xenomai_posix_example_CFLAGS = -I"$(XENOMAI_DIR)"/include -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -I"$(XENOMAI_DIR)"/include/posix -I$(top_srcdir)/include
+ec_xenomai_posix_example_LDFLAGS = -Wl,@"$(XENOMAI_DIR)"/lib/posix.wrappers -L"$(XENOMAI_DIR)"/lib -lpthread_rt -lrtdm -L$(top_builddir)/lib/.libs -lethercat -lrtdk -lxenomai -lpthread
 
 
 #------------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/xenomai_posix/README	Wed Mar 23 08:06:58 2011 +0100
@@ -0,0 +1,35 @@
+-------------------------------------------------------------------------------
+
+$Id$
+
+-------------------------------------------------------------------------------
+
+This is a minimal example application for the use of the EtherCAT
+master realtime RTDM interface with an XENOMAI POSIX thread.
+
+The application expects an XENOMAI installation. Configure the master sources
+specifying --enable-rtdm --with-xenomai-dir to have the right include paths.
+
+Most probably you'll have different EtherCAT slaves present. Try adjusting the
+section "process data" in main.c to your bus configuration.
+
+There are some features that can be disabled by commenting out the respective
+defines at the head of main.c.
+
+---
+
+To build the example, call:
+
+make 
+
+To run it, preload the EtherCAT RTDM module:
+
+modprobe ec_rtdm
+
+and call as root:
+
+./ec_xenomai_posix_example
+
+...and watch the system logs for the outputs.
+
+-------------------------------------------------------------------------------