[Xenomai-git] Philippe Gerum : cobalt/posix: expose compat helpers to RTDM drivers

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7fb98485d05bb5dc0210b9fdb723baafa2bac0eb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7fb98485d05bb5dc0210b9fdb723baafa2bac0eb

Author: Philippe Gerum 
Date:   Mon Oct 27 17:27:35 2014 +0100

cobalt/posix: expose compat helpers to RTDM drivers

---

 include/cobalt/kernel/rtdm/cobalt.h |1 +
 include/cobalt/kernel/rtdm/compat.h |3 +
 kernel/cobalt/posix/Makefile|2 +-
 kernel/cobalt/posix/compat.c|  381 +++
 kernel/cobalt/posix/compat.h|  155 ++
 kernel/cobalt/posix/syscall32.c |  342 ---
 kernel/cobalt/posix/syscall32.h |   74 +--
 kernel/cobalt/posix/thread.h|4 +-
 8 files changed, 545 insertions(+), 417 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/cobalt.h 
b/include/cobalt/kernel/rtdm/cobalt.h
index 2c38053..fc75430 100644
--- a/include/cobalt/kernel/rtdm/cobalt.h
+++ b/include/cobalt/kernel/rtdm/cobalt.h
@@ -29,5 +29,6 @@
 #include 
 #include 
 #include 
+#include 
 
 #endif /* !_COBALT_RTDM_COBALT_H */
diff --git a/include/cobalt/kernel/rtdm/compat.h 
b/include/cobalt/kernel/rtdm/compat.h
index fdf493f..44b6884 100644
--- a/include/cobalt/kernel/rtdm/compat.h
+++ b/include/cobalt/kernel/rtdm/compat.h
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 
 struct compat_rtdm_getsockopt_args {
int level;
@@ -70,4 +71,6 @@ struct compat_rtdm_setsockaddr_args {
 
 #endif /* !CONFIG_COMPAT */
 
+#define COMPAT_CASE(__op)  case __op __COMPAT_CASE(__op  ## _COMPAT)
+
 #endif /* !_COBALT_RTDM_COMPAT_H */
diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index 22d5f2b..2ac92ff 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -20,6 +20,6 @@ xenomai-y :=  \
timer.o \
timerfd.o
 
-xenomai-$(CONFIG_XENO_ARCH_SYS3264) += syscall32.o
+xenomai-$(CONFIG_XENO_ARCH_SYS3264) += compat.o syscall32.o
 
 ccflags-y := -Iarch/$(SRCARCH)/xenomai/include -Iinclude/xenomai -Ikernel
diff --git a/kernel/cobalt/posix/compat.c b/kernel/cobalt/posix/compat.c
new file mode 100644
index 000..de2143a
--- /dev/null
+++ b/kernel/cobalt/posix/compat.c
@@ -0,0 +1,381 @@
+/*
+ * Copyright (C) 2014 Philippe Gerum 
+ *
+ * Xenomai is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include 
+#include 
+#include "compat.h"
+
+int sys32_get_timespec(struct timespec *ts,
+  const struct compat_timespec __user *cts)
+{
+   return (cts == NULL ||
+   !access_rok(cts, sizeof(*cts)) ||
+   __xn_get_user(ts->tv_sec, &cts->tv_sec) ||
+   __xn_get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+}
+EXPORT_SYMBOL_GPL(sys32_get_timespec);
+
+int sys32_put_timespec(struct compat_timespec __user *cts,
+  const struct timespec *ts)
+{
+   return (cts == NULL ||
+   !access_wok(cts, sizeof(*cts)) ||
+   __xn_put_user(ts->tv_sec, &cts->tv_sec) ||
+   __xn_put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
+}
+EXPORT_SYMBOL_GPL(sys32_put_timespec);
+
+int sys32_get_itimerspec(struct itimerspec *its,
+const struct compat_itimerspec __user *cits)
+{
+   int ret = sys32_get_timespec(&its->it_value, &cits->it_value);
+
+   return ret ?: sys32_get_timespec(&its->it_interval, &cits->it_interval);
+}
+EXPORT_SYMBOL_GPL(sys32_get_itimerspec);
+
+int sys32_put_itimerspec(struct compat_itimerspec __user *cits,
+const struct itimerspec *its)
+{
+   int ret = sys32_put_timespec(&cits->it_value, &its->it_value);
+
+   return ret ?: sys32_put_timespec(&cits->it_interval, &its->it_interval);
+}
+EXPORT_SYMBOL_GPL(sys32_put_itimerspec);
+
+int sys32_get_timeval(struct timeval *tv,
+ const struct compat_timeval __user *ctv)
+{
+   return (ctv == NULL ||
+   !access_rok(ctv, sizeof(*ctv)) ||
+   __xn_get_user(tv->tv_sec, &ctv->tv_sec) ||
+   __xn_get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
+}
+EXPORT_SYMBOL_GPL(sys32_get_timeval);
+
+int sys32_put_timeval(struct compat_timeval __user *ctv,
+ const struct timeval *tv)
+{
+   return (ctv == NULL ||
+   !acc

[Xenomai-git] Philippe Gerum : smokey/sched-quota: force affinity on the test CPU

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a0d78580975974b94795e3a29b0a1704d7b7f785
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a0d78580975974b94795e3a29b0a1704d7b7f785

Author: Philippe Gerum 
Date:   Mon Oct 27 08:58:15 2014 +0100

smokey/sched-quota: force affinity on the test CPU

---

 testsuite/smokey/sched-quota/sched-quota.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/testsuite/smokey/sched-quota/sched-quota.c 
b/testsuite/smokey/sched-quota/sched-quota.c
index e8f4347..da1c471 100644
--- a/testsuite/smokey/sched-quota/sched-quota.c
+++ b/testsuite/smokey/sched-quota/sched-quota.c
@@ -270,8 +270,15 @@ static int run_sched_quota(struct smokey_test *t, int 
argc, char *const argv[])
pthread_t me = pthread_self();
struct sched_param param;
int ret, quota = 0;
+   cpu_set_t affinity;
double effective;
 
+   CPU_ZERO(&affinity);
+   CPU_SET(0, &affinity);
+   ret = sched_setaffinity(0, sizeof(affinity), &affinity);
+   if (ret)
+   error(1, errno, "sched_setaffinity");
+
smokey_parse_args(t, argc, argv);
pthread_mutex_init(&lock, NULL);
pthread_cond_init(&barrier, NULL);


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


[Xenomai-git] Jorge Ramirez-Ortiz : rtdm/uapi: define PACK_FLAGS using previous definition of PACK

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 8ec0c54431ac402be811a5501c2a01658e4fdad2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8ec0c54431ac402be811a5501c2a01658e4fdad2

Author: Jorge Ramirez-Ortiz 
Date:   Thu Sep 11 18:03:07 2014 -0400

rtdm/uapi: define PACK_FLAGS using previous definition of PACK

---

 include/rtdm/uapi/analogy.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 458d5f7..9806c82 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -248,7 +248,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 /**
  * Channel + range + reference + flags definition macro
  */
-#define PACK_FLAGS(a, b, c, d) (CHAN(a) | RNG(b) | AREF(c) | FLAGS(d))
+#define PACK_FLAGS(a, b, c, d) (PACK(a, b, c) | FLAGS(d))
 
 /**
  * Analog reference is analog ground


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: fix warning

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c386253f4c5869abf88d5d7b1271da501f8d0f6b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c386253f4c5869abf88d5d7b1271da501f8d0f6b

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 26 13:51:08 2014 -0400

drivers/analogy: fix warning

---

 kernel/drivers/analogy/instruction.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/analogy/instruction.c 
b/kernel/drivers/analogy/instruction.c
index 7e7704f..1cbdb14 100644
--- a/kernel/drivers/analogy/instruction.c
+++ b/kernel/drivers/analogy/instruction.c
@@ -205,7 +205,7 @@ int a4l_do_special_insn(struct a4l_device_context * cxt, 
struct a4l_kernel_instr
 
 int a4l_do_insn(struct a4l_device_context * cxt, struct a4l_kernel_instruction 
* dsc)
 {
-   int ret;
+   int ret = 0;
struct a4l_subdevice *subd;
struct a4l_device *dev = a4l_get_dev(cxt);
int (*hdlr) (struct a4l_subdevice *, struct a4l_kernel_instruction *) = 
NULL;


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


[Xenomai-git] Jorge Ramirez-Ortiz : lib/analogy: calibration - a4l_rawtodcal & a4l_dcaltoraw

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 029424c470f6697dca77b9e693a8669d66474d54
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=029424c470f6697dca77b9e693a8669d66474d54

Author: Jorge Ramirez-Ortiz 
Date:   Fri Oct 24 08:59:31 2014 -0400

lib/analogy: calibration - a4l_rawtodcal & a4l_dcaltoraw

---

 include/rtdm/analogy.h  |9 ++
 include/rtdm/uapi/analogy.h |6 ++
 lib/analogy/calibration.c   |  237 ++-
 lib/analogy/math.c  |8 +-
 utils/analogy/Makefile.am   |2 +-
 5 files changed, 252 insertions(+), 10 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index a87ce54..066d05a 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -232,6 +232,15 @@ int a4l_dtoraw(a4l_chinfo_t *chan,
 
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
 
+int a4l_get_softcal_converter(struct a4l_polynomial *converter,
+ int subd, int chan, int range,
+ struct a4l_calibration_data *data );
+
+int a4l_rawtodcal(a4l_chinfo_t *chan, double *dst, void *src,
+ int cnt, struct a4l_polynomial *converter);
+int a4l_dcaltoraw(a4l_chinfo_t * chan, void *dst, double *src, int cnt,
+ struct a4l_polynomial *converter);
+
 int a4l_math_polyfit(unsigned order, double *r,double orig,
 const unsigned dim, double *x, double *y);
 
diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index a0a1e59..2d53168 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -732,6 +732,12 @@ struct a4l_calibration_data {
struct a4l_calibration_subdev_data *ao;
 };
 
+struct a4l_polynomial {
+   int expansion;
+   int order;
+   int nb_coeff;
+   double *coeff;
+};
 
 
 #endif /* _RTDM_UAPI_ANALOGY_H */
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index dcec16d..9fd944c 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -28,8 +29,39 @@
 #include "boilerplate/list.h"
 #include "calibration.h"
 
+
 #define ARRAY_LEN(a)  (sizeof(a) / sizeof((a)[0]))
 
+static lsampl_t data32_get(void *src)
+{
+   return (lsampl_t) * ((lsampl_t *) (src));
+}
+
+static lsampl_t data16_get(void *src)
+{
+   return (lsampl_t) * ((sampl_t *) (src));
+}
+
+static lsampl_t data8_get(void *src)
+{
+   return (lsampl_t) * ((unsigned char *)(src));
+}
+
+static void data32_set(void *dst, lsampl_t val)
+{
+   *((lsampl_t *) (dst)) = val;
+}
+
+static void data16_set(void *dst, lsampl_t val)
+{
+   *((sampl_t *) (dst)) = (sampl_t) (0x & val);
+}
+
+static void data8_set(void *dst, lsampl_t val)
+{
+   *((unsigned char *)(dst)) = (unsigned char)(0xff & val);
+}
+
 static inline int read_dbl(double *d, struct _dictionary_ *f,const char *subd,
   int subd_idx, char *type, int type_idx)
 {
@@ -73,7 +105,7 @@ static inline int read_int(int *val, struct _dictionary_ *f, 
const char *subd,
 }
 
 static inline int read_str(char **val, struct _dictionary_ *f, const char 
*subd,
-  const char *type)
+  const char *type)
 {
char *str;
int ret;
@@ -105,7 +137,7 @@ static inline void write_calibration(FILE *file, char *fmt, 
...)
 
 void
 write_calibration_file(FILE *dst, struct list *l,
-  struct a4l_calibration_subdev *subd, a4l_desc_t *desc)
+  struct a4l_calibration_subdev *subd, a4l_desc_t *desc)
 {
struct subdevice_calibration_node *e, *t;
int i, j = 0;
@@ -205,7 +237,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
if (strncmp(subdevice[k], AI_SUBD_STR,
strlen(AI_SUBD_STR)) == 0) {
data->ai = malloc(nb_elements *
-  sizeof(struct a4l_calibration_subdev_data));
+ sizeof(struct 
a4l_calibration_subdev_data));
data->nb_ai = nb_elements;
p  = data->ai;
}
@@ -213,7 +245,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
if (strncmp(subdevice[k], AO_SUBD_STR,
strlen(AO_SUBD_STR)) == 0) {
data->ao = malloc(nb_elements *
-  sizeof(struct a4l_calibration_subdev_data));
+ sizeof(struct 
a4l_calibration_subdev_data));
data->nb_ao = nb_elements;
p = data->ao;
}
@@ -232,7 +264,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
 
 

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: NI-M software calibration [Part I]

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 047c0fe54a2a751bd5bf3e3c7f857684845656b8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=047c0fe54a2a751bd5bf3e3c7f857684845656b8

Author: Jorge Ramirez-Ortiz 
Date:   Wed Aug 13 12:24:16 2014 -0400

utils/analogy: NI-M software calibration [Part I]

Generates a calibration file as per the comedi implementation.

---

 utils/analogy/Makefile.am |   24 +-
 utils/analogy/analogy_calibrate.c |  157 +
 utils/analogy/analogy_calibrate.h |  182 +
 utils/analogy/calibration_ni_m.c  | 1406 +
 utils/analogy/calibration_ni_m.h  |  280 
 5 files changed, 2048 insertions(+), 1 deletion(-)

diff --git a/utils/analogy/Makefile.am b/utils/analogy/Makefile.am
index c731b7a..fe2f317 100644
--- a/utils/analogy/Makefile.am
+++ b/utils/analogy/Makefile.am
@@ -1,4 +1,4 @@
-sbin_PROGRAMS = analogy_config
+sbin_PROGRAMS = analogy_config analogy_calibrate
 
 bin_PROGRAMS = \
cmd_read \
@@ -29,6 +29,24 @@ analogy_config_LDADD = \
@XENO_USER_LDADD@   \
-lpthread -lrt
 
+analogy_calibrate_SOURCES = analogy_calibrate.c calibration_ni_m.c
+analogy_calibrate.c: git-stamp.h calibration_ni_m.h
+git-stamp.h: git-stamp
+   @set -x; if test -r $(top_srcdir)/.git; then
\
+ stamp=`git --git-dir=$(top_srcdir)/.git rev-list --abbrev-commit -1 
HEAD`;\
+ if test \! -s $@ || grep -wvq $$stamp $@; then
\
+   date=`git --git-dir=$(top_srcdir)/.git log -1 $$stamp 
--pretty=format:%ci`; \
+   echo "#define GIT_STAMP \"#$$stamp ($$date)\"" > $@;
\
+ fi;   
\
+   elif test \! -r $@ -o -s $@; then   
\
+   rm -f $@ && touch $@;   
\
+   fi; true
+analogy_calibrate_LDADD = \
+   ../../lib/analogy/libanalogy.la \
+   ../../lib/cobalt/libcobalt.la   \
+   @XENO_USER_LDADD@   \
+   -lpthread -lrt -lgsl -lgslcblas -lm
+
 cmd_read_SOURCES = cmd_read.c
 cmd_read_LDADD = \
../../lib/analogy/libanalogy.la \
@@ -77,3 +95,7 @@ insn_bits_LDADD = \
 
 wf_generate_SOURCES = wf_generate.c
 wf_generate_LDADD = ./libwaveform.la -lm
+
+
+.PHONY: git-stamp
+
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
new file mode 100644
index 000..586a38a
--- /dev/null
+++ b/utils/analogy/analogy_calibrate.c
@@ -0,0 +1,157 @@
+/**
+ * @file
+ * Analogy for Linux, calibration program
+ *
+ * @note Copyright (C) 2014 Jorge A. Ramirez-Ortiz 
+ *
+ * from original code from the Comedi project
+ *
+ * Xenomai is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Xenomai; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "analogy_calibrate.h"
+#include "calibration_ni_m.h"
+
+
+struct timespec calibration_start_time;
+static const char *revision = "0.0.1";
+a4l_desc_t descriptor;
+FILE *cal = NULL;
+
+static const struct option options[] = {
+   {
+#define help_opt   0
+   .name = "help",
+   .has_arg = 0,
+   .flag = NULL,
+   },
+   {
+#define device_opt 1
+   .name = "device",
+   .has_arg = 1,
+   .flag = NULL,
+   },
+   {
+#define output_opt 2
+   .name = "output",
+   .has_arg = 1,
+   .flag = NULL,
+   },
+   {
+   .name = NULL,
+   }
+};
+
+static void print_usage(void)
+{
+   fprintf(stderr, "Usage: analogy_calibrate \n"
+  "  --help: this menu \n"
+  "  --device /dev/analogyX: analogy device to calibrate 
\n"
+  "  --output filename : calibration results \n"
+ );
+}
+
+static void __attribute__ ((constructor)) __analogy_calibrate_init(void)
+{
+   clock_gettime(CLOCK_MONOTONIC, &calibration_start_time);
+}
+
+int main(int argc, char *argv[])
+{
+   struct sched_param param = {.sched_priority = 99};
+   char *device = NULL, *file = NULL;
+  

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - use analogy lib to read /write the calibration file

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: fb962115628721bc52ae05923b67185c4005ee37
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fb962115628721bc52ae05923b67185c4005ee37

Author: Jorge Ramirez-Ortiz 
Date:   Sat Oct 11 14:25:26 2014 -0400

utils/analogy: calibration - use analogy lib to read/write the calibration file

---

 include/rtdm/analogy.h|   11 +
 include/rtdm/uapi/analogy.h   |   28 +++
 lib/analogy/Makefile.am   |   11 +-
 lib/analogy/calibration.c |  211 +++
 lib/analogy/calibration.h |   44 
 utils/analogy/Makefile.am |5 +-
 utils/analogy/analogy_calibrate.c |   73 +--
 utils/analogy/analogy_calibrate.h |  131 +---
 utils/analogy/calibration_ni_m.c  |  422 -
 utils/analogy/calibration_ni_m.h  |   36 +---
 10 files changed, 456 insertions(+), 516 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index 57f2ec0..fd26f58 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -21,9 +21,12 @@
 #ifndef _RTDM_ANALOGY_H
 #define _RTDM_ANALOGY_H
 
+#include 
 #include 
 #include 
 
+#include "boilerplate/list.h"
+
 /*!
   @addtogroup analogy_lib_descriptor
   @{
@@ -227,6 +230,14 @@ int a4l_ftoraw(a4l_chinfo_t *chan,
 int a4l_dtoraw(a4l_chinfo_t *chan,
   a4l_rnginfo_t *rng, void *dst, double *src, int cnt);
 
+void a4l_write_calibration_file(FILE *dst, struct list *l,
+   struct a4l_calibration_subdev *subd,
+   a4l_desc_t *desc);
+
+int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
+
+
+
 #endif /* !DOXYGEN_CPP */
 
 #ifdef __cplusplus
diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 9806c82..669ded7 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -706,4 +706,32 @@ typedef struct a4l_instruction_list a4l_insnlst_t;
 
 /*! @} analogy_lib_sync1 */
 
+struct a4l_calibration_subdev {
+   a4l_sbinfo_t *info;
+   int slen;
+   int idx;
+   char *name;
+};
+
+struct a4l_calibration_subdev_data {
+   int index;
+   int channel;
+   int range;
+   int expansion;
+   int nb_coeff;
+   double *coeff;
+
+};
+
+struct a4l_calibration_data {
+   char *driver_name;
+   char *board_name;
+   int nb_ai;
+   struct a4l_calibration_subdev_data *ai;
+   int nb_ao;
+   struct a4l_calibration_subdev_data *ao;
+};
+
+
+
 #endif /* _RTDM_UAPI_ANALOGY_H */
diff --git a/lib/analogy/Makefile.am b/lib/analogy/Makefile.am
index 4d242ff..500453d 100644
--- a/lib/analogy/Makefile.am
+++ b/lib/analogy/Makefile.am
@@ -7,11 +7,16 @@ libanalogy_la_SOURCES =   \
descriptor.c\
info.c  \
internal.h  \
+   calibration.c   \
range.c \
root_leaf.h \
sync.c  \
sys.c
 
-libanalogy_la_CPPFLAGS =   \
-   @XENO_USER_CFLAGS@  \
-   -I$(top_srcdir)/include
+libanalogy_la_CPPFLAGS =   \
+   @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/lib/boilerplate 
+
+libanalogy_la_LIBADD = \
+   ../boilerplate/libboilerplate.la
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
new file mode 100644
index 000..74b2789
--- /dev/null
+++ b/lib/analogy/calibration.c
@@ -0,0 +1,211 @@
+#include 
+#include 
+#include 
+#include 
+#include "iniparser/iniparser.h"
+#include "boilerplate/list.h"
+#include "calibration.h"
+
+#define ARRAY_LEN(a)  (sizeof(a) / sizeof((a)[0]))
+
+static inline int read_dbl(double *d, struct _dictionary_ *f,const char *subd,
+  int subd_idx, char *type, int type_idx)
+{
+   char *str;
+   int ret;
+
+   /* if only contains doubles as coefficients */
+   if (strncmp(type, COEFF_STR, strlen(COEFF_STR) != 0))
+   return -ENOENT;
+
+   ret = asprintf(&str, COEFF_FMT, subd, subd_idx, type, type_idx);
+   if (ret < 0)
+   return ret;
+
+   *d = iniparser_getdouble(f, str, -255.0);
+   if (*d == -255.0)
+   ret = -ENOENT;
+   free(str);
+
+   return ret;
+}
+
+static inline int read_int(int *val, struct _dictionary_ *f, const char *subd,
+  int subd_idx, char *type)
+{
+   char *str;
+   int ret;
+
+   ret = (subd_idx >= 0) ?
+ asprintf(&str, ELEMENT_FIELD_FMT, subd, subd_idx, type):
+ asprintf(&str, ELEMENT_FMT, subd, type);
+   if (ret < 0)
+   return ret;
+
+   *val = iniparser_getint(f, str, 0x);
+   if (*val == 0x)
+   ret = -ENOENT;
+   free(str);
+
+   return ret;
+}
+
+static inline int read_str(char **val, struct _dictionary_ *f, const char 
*subd,
+  const char *type)
+{
+   char *str;
+   int ret;
+
+   ret 

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: NI M - cmd test update (from comedi )

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7988c4132872f09611db5a219c425769b687
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7988c4132872f09611db5a219c425769b687

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 26 13:45:23 2014 -0400

drivers/analogy: NI M - cmd test update (from comedi)

In order to mimic the comedi behaviour, the simulation comand shall update
command fields specifics to the driver.

To that end, the a4l_cmd_t structure defines a driver specific bitfield to
indidate which states are allowed by the driver to not be reported as errors.

---

 include/rtdm/uapi/analogy.h|   33 +--
 .../analogy/national_instruments/mio_common.c  |  256 +---
 2 files changed, 190 insertions(+), 99 deletions(-)

diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 98c6154..458d5f7 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -236,7 +236,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 /**
  * Reference definition macro
  */
-#define AREF(a) (((a) & 0xf) << 24)
+#define AREF(a) (((a) & 0x03) << 24)
 /**
  * Flags definition macro
  */
@@ -244,7 +244,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 /**
  * Channel + range + reference definition macro
  */
-#define PACK(a, b, c) (CHAN(a) | RNG(b) | AREF(c))
+#define PACK(a, b, c) (a | RNG(b) | AREF(c))
 /**
  * Channel + range + reference + flags definition macro
  */
@@ -276,8 +276,8 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 #define CR_DITHER CR_ALT_FILTER
 #define CR_DEGLITCH CR_ALT_FILTER
 #define CR_ALT_SOURCE (1<<27)
-#define CR_EDGE(1<<28)
-#define CR_INVERT (1<<29)
+#define CR_EDGE(1<<30)
+#define CR_INVERT (1<<31)
 
 #endif /* !DOXYGEN_CPP */
 
@@ -288,43 +288,46 @@ typedef struct a4l_dev_info a4l_dvinfo_t;
 
 struct a4l_cmd_desc {
unsigned char idx_subd;
-   /**< Subdevice to which the command will be 
applied. */
+  /**< Subdevice to which the command will be 
applied. */
 
unsigned long flags;
-/**< Command flags */
+  /**< Command flags */
 
/* Command trigger characteristics */
unsigned int start_src;
-   /**< Start trigger type */
+  /**< Start trigger type */
unsigned int start_arg;
-   /**< Start trigger argument */
+  /**< Start trigger argument */
unsigned int scan_begin_src;
-/**< Scan begin trigger type */
+  /**< Scan begin trigger type */
unsigned int scan_begin_arg;
-/**< Scan begin trigger argument */
+  /**< Scan begin trigger argument */
unsigned int convert_src;
- /**< Convert trigger type */
+  /**< Convert trigger type */
unsigned int convert_arg;
- /**< Convert trigger argument */
+  /**< Convert trigger argument */
unsigned int scan_end_src;
   /**< Scan end trigger type */
unsigned int scan_end_arg;
   /**< Scan end trigger argument */
unsigned int stop_src;
-  /**< Stop trigger type */
+  /**< Stop trigger type */
unsigned int stop_arg;
   /**< Stop trigger argument */
 
unsigned char nb_chan;
   /**< Count of channels related with the command */
unsigned int *chan_descs;
- /**< Tab containing channels descriptors */
+   /**< Tab containing channels descriptors */
 
/* Driver specific fields */
+   unsigned int valid_simul_stages;
+  /** < cmd simulation valid stages (driver dependent) 
*/
+
unsigned int data_len;
   /**< Driver specific buffer size */
sampl_t *data;
-  /**< Driver specific buffer pointer */
+  /**< Driver specific buffer pointer */
 };
 typedef struct a4l_cmd_desc a4l_cmd_t;
 
diff --git a/kernel/drivers/analogy/national_instruments/mio_common.c 
b/kernel/drivers/analogy/national_instruments/mio_common.c
index e5ccf7a..6c5bba0 100644
--- a/kernel/drivers/analogy/national_instruments/mio_common.c
+++ b/kernel/drivers/analogy/national_instruments/mio_common.c
@@ -2029,52 +2029,145 @@ int ni_ai_inttrig(struct a4l_subdevice *subd, lsampl_t 
trignum)
return 1;
 }
 
-static int ni_ai_cmdtest(struct a4l_subdevice *subd, struct a4l_cmd_desc * cmd)
+#define cfc_check_trigger_arg_is(a,b) __cfc_check_trigger_arg_is(a,b, dev, 
__LINE__)
+static inline int __cfc_check_trigger_arg_is(unsigned int *arg,
+

[Xenomai-git] Philippe Gerum : cobalt/heap: add xnstrdup()

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e7585233e24a089b204230d6f3cc9d4b3a4f3ea1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e7585233e24a089b204230d6f3cc9d4b3a4f3ea1

Author: Philippe Gerum 
Date:   Mon Oct 27 11:14:11 2014 +0100

cobalt/heap: add xnstrdup()

---

 include/cobalt/kernel/heap.h |   12 
 1 file changed, 12 insertions(+)

diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h
index d29778f..916ac8f 100644
--- a/include/cobalt/kernel/heap.h
+++ b/include/cobalt/kernel/heap.h
@@ -19,6 +19,7 @@
 #ifndef _COBALT_KERNEL_HEAP_H
 #define _COBALT_KERNEL_HEAP_H
 
+#include 
 #include 
 #include 
 #include 
@@ -142,6 +143,17 @@ void xnheap_free(struct xnheap *heap, void *block);
 
 int xnheap_check_block(struct xnheap *heap, void *block);
 
+static inline char *xnstrdup(const char *s)
+{
+   char *p;
+
+   p = xnmalloc(strlen(s) + 1);
+   if (p == NULL)
+   return NULL;
+
+   return strcpy(p, s);
+}
+
 /** @} */
 
 #endif /* !_COBALT_KERNEL_HEAP_H */


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


[Xenomai-git] Philippe Gerum : bootstrap

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0e1dc8cdfeb877812f8570974990bde37261367b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0e1dc8cdfeb877812f8570974990bde37261367b

Author: Philippe Gerum 
Date:   Mon Oct 27 14:11:04 2014 +0100

bootstrap

---

 include/cobalt/kernel/rtdm/Makefile.in |1 +
 lib/analogy/Makefile.in|   30 --
 lib/boilerplate/Makefile.in|   53 ++--
 utils/analogy/Makefile.in  |   46 ---
 4 files changed, 107 insertions(+), 23 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/Makefile.in 
b/include/cobalt/kernel/rtdm/Makefile.in
index 1cc5915..81d84d1 100644
--- a/include/cobalt/kernel/rtdm/Makefile.in
+++ b/include/cobalt/kernel/rtdm/Makefile.in
@@ -350,6 +350,7 @@ noinst_HEADERS = \
autotune.h  \
can.h   \
cobalt.h\
+   compat.h\
driver.h\
fd.h\
ipc.h   \
diff --git a/lib/analogy/Makefile.in b/lib/analogy/Makefile.in
index 832f43d..f42dbde 100644
--- a/lib/analogy/Makefile.in
+++ b/lib/analogy/Makefile.in
@@ -125,9 +125,10 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(libdir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
-libanalogy_la_LIBADD =
+libanalogy_la_DEPENDENCIES = ../boilerplate/libboilerplate.la
 am_libanalogy_la_OBJECTS = libanalogy_la-async.lo \
libanalogy_la-descriptor.lo libanalogy_la-info.lo \
+   libanalogy_la-math.lo libanalogy_la-calibration.lo \
libanalogy_la-range.lo libanalogy_la-sync.lo \
libanalogy_la-sys.lo
 libanalogy_la_OBJECTS = $(am_libanalogy_la_OBJECTS)
@@ -374,14 +375,21 @@ libanalogy_la_SOURCES = \
descriptor.c\
info.c  \
internal.h  \
+   math.c  \
+   calibration.c   \
range.c \
root_leaf.h \
sync.c  \
sys.c
 
 libanalogy_la_CPPFLAGS = \
-   @XENO_USER_CFLAGS@  \
-   -I$(top_srcdir)/include
+   @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/lib/boilerplate 
+
+libanalogy_la_LIBADD = \
+   ../boilerplate/libboilerplate.la\
+   -lm
 
 all: all-am
 
@@ -463,8 +471,10 @@ distclean-compile:
-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-async.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-calibration.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-descriptor.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-info.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-math.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-range.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-sync.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/libanalogy_la-sys.Plo@am__quote@
@@ -511,6 +521,20 @@ libanalogy_la-info.lo: info.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@  DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC 
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) 
$(DEFAULT_INCLUDES) $(INCLUDES) $(libanalogy_la_CPPFLAGS) $(CPPFLAGS) 
$(AM_CFLAGS) $(CFLAGS) -c -o libanalogy_la-info.lo `test -f 'info.c' || echo 
'$(srcdir)/'`info.c
 
+libanalogy_la-math.lo: math.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC 
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) 
$(DEFAULT_INCLUDES) $(INCLUDES) $(libanalogy_la_CPPFLAGS) $(CPPFLAGS) 
$(AM_CFLAGS) $(CFLAGS) -MT libanalogy_la-math.lo -MD -MP -MF 
$(DEPDIR)/libanalogy_la-math.Tpo -c -o libanalogy_la-math.lo `test -f 'math.c' 
|| echo '$(srcdir)/'`math.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libanalogy_la-math.Tpo 
$(DEPDIR)/libanalogy_la-math.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@  $(AM_V_CC)source='math.c' 
object='libanalogy_la-math.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@  DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC 
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) 
$(DEFAULT_INCLUDES) $(INCLUDES) $(libanalogy_la_CPPFLAGS) $(CPPFLAGS) 
$(AM_CFLAGS) $(CFLAGS) -c -o libanalogy_la-math.lo `test -f 'math.c' || echo 
'$(srcdir)/'`math.c
+
+libanalogy_la-calibration.lo: calibration.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC 
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) 
$(DEFAULT_INCLUDES) $(INCLUDES) $(libanalogy_la_CPPFLAGS) $(CPPFLAGS) 
$(AM_CFLAGS) $(CFLAGS) -MT libanalogy_la-calibration.lo -MD -MP -MF 
$(DEPDIR)/libanalogy_la-calibration.Tpo -c -o libanalogy_la-calibration.lo 
`test -f 'calibration.c' |

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: disable chanlist check on calibration instructions

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c39b74040ab085a03ec9078baffecab7bed758d1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c39b74040ab085a03ec9078baffecab7bed758d1

Author: Jorge Ramirez-Ortiz 
Date:   Wed Aug 20 15:58:07 2014 -0400

drivers/analogy: disable chanlist check on calibration instructions

---

 kernel/drivers/analogy/instruction.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/analogy/instruction.c 
b/kernel/drivers/analogy/instruction.c
index 95c4419..7e7704f 100644
--- a/kernel/drivers/analogy/instruction.c
+++ b/kernel/drivers/analogy/instruction.c
@@ -228,10 +228,12 @@ int a4l_do_insn(struct a4l_device_context * cxt, struct 
a4l_kernel_instruction *
}
 
/* Checks the channel descriptor */
-   ret = a4l_check_chanlist(dev->transfer.subds[dsc->idx_subd],
-1, &dsc->chan_desc);
-   if (ret < 0)
-   return ret;
+   if ((subd->flags & A4L_SUBD_TYPES) != A4L_SUBD_CALIB) {
+   ret = a4l_check_chanlist(dev->transfer.subds[dsc->idx_subd],
+1, &dsc->chan_desc);
+   if (ret < 0)
+   return ret;
+   }
 
/* Choose the proper handler, we can check the pointer because
   the subdevice was memset to 0 at allocation time */


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: let A4L_CMD_SIMUL calls return driver specific values

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ca84782351a929ed78baee05fffd3accfce31db0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ca84782351a929ed78baee05fffd3accfce31db0

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 19 14:02:23 2014 -0400

drivers/analogy: let A4L_CMD_SIMUL calls return driver specific values

---

 kernel/drivers/analogy/command.c |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/kernel/drivers/analogy/command.c b/kernel/drivers/analogy/command.c
index 1c544bf..213591d 100644
--- a/kernel/drivers/analogy/command.c
+++ b/kernel/drivers/analogy/command.c
@@ -26,7 +26,6 @@
 #include 
 
 /* --- Command descriptor management functions --- */
-
 int a4l_fill_cmddesc(struct a4l_device_context * cxt, struct a4l_cmd_desc * 
desc, void *arg)
 {
int ret = 0;
@@ -284,11 +283,11 @@ int a4l_check_specific_cmdcnt(struct a4l_device_context * 
cxt, struct a4l_cmd_de
 
 /* --- IOCTL / FOPS function --- */
 
-int a4l_ioctl_cmd(struct a4l_device_context * cxt, void *arg)
+int a4l_ioctl_cmd(struct a4l_device_context * ctx, void *arg)
 {
int ret = 0, simul_flag = 0;
struct a4l_cmd_desc *cmd_desc = NULL;
-   struct a4l_device *dev = a4l_get_dev(cxt);
+   struct a4l_device *dev = a4l_get_dev(ctx);
struct a4l_subdevice *subd;
 
/* The command launching cannot be done in real-time because
@@ -310,12 +309,12 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
memset(cmd_desc, 0, sizeof(struct a4l_cmd_desc));
 
/* Gets the command */
-   ret = a4l_fill_cmddesc(cxt, cmd_desc, arg);
+   ret = a4l_fill_cmddesc(ctx, cmd_desc, arg);
if (ret != 0)
goto out_ioctl_cmd;
 
/* Checks the command */
-   ret = a4l_check_cmddesc(cxt, cmd_desc);
+   ret = a4l_check_cmddesc(ctx, cmd_desc);
if (ret != 0)
goto out_ioctl_cmd;
 
@@ -323,7 +322,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
if (ret != 0)
goto out_ioctl_cmd;
 
-   ret = a4l_check_specific_cmdcnt(cxt, cmd_desc);
+   ret = a4l_check_specific_cmdcnt(ctx, cmd_desc);
if (ret != 0)
goto out_ioctl_cmd;
 
@@ -347,7 +346,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
}
 
/* Gets the transfer system ready */
-   ret = a4l_setup_buffer(cxt, cmd_desc);
+   ret = a4l_setup_buffer(ctx, cmd_desc);
if (ret < 0)
goto out_ioctl_cmd;
 
@@ -355,12 +354,14 @@ int a4l_ioctl_cmd(struct a4l_device_context * cxt, void 
*arg)
ret = subd->do_cmd(subd, cmd_desc);
 
if (ret != 0) {
-   a4l_cancel_buffer(cxt);
+   a4l_cancel_buffer(ctx);
goto out_ioctl_cmd;
}
 
 out_ioctl_cmd:
if (ret != 0 || simul_flag == 1) {
+   rtdm_safe_copy_to_user(rtdm_private_to_fd(ctx), arg, cmd_desc,
+   sizeof(struct a4l_cmd_desc));
a4l_free_cmddesc(cmd_desc);
rtdm_free(cmd_desc);
}


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


[Xenomai-git] Philippe Gerum : cobalt/sched: clarify schedlist header

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 994d9828a036a04b9c54362620b01ee0b97f8641
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=994d9828a036a04b9c54362620b01ee0b97f8641

Author: Philippe Gerum 
Date:   Sun Oct 26 18:00:14 2014 +0100

cobalt/sched: clarify schedlist header

---

 kernel/cobalt/sched.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 6fdae55..7cc5770 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -1000,7 +1000,7 @@ static int vfile_schedlist_show(struct 
xnvfile_snapshot_iterator *it,
if (p == NULL)
xnvfile_printf(it,
   "%-3s  %-6s %-5s  %-8s  %-5s %-8s  %-10s %s\n",
-  "CPU", "PID", "CLASS", "PERS", "PRI", "TIMEOUT",
+  "CPU", "PID", "CLASS", "TYPE", "PRI", "TIMEOUT",
   "STAT", "NAME");
else {
ksformat(pbuf, sizeof(pbuf), "%3d", p->cprio);


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: remove unnecessary lock

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b82b83556b147741c31187595412ba203de1fcf3
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b82b83556b147741c31187595412ba203de1fcf3

Author: Jorge Ramirez-Ortiz 
Date:   Thu Aug 14 13:41:50 2014 -0400

drivers/analogy: remove unnecessary lock

---

 kernel/drivers/analogy/transfer.c |   13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/kernel/drivers/analogy/transfer.c 
b/kernel/drivers/analogy/transfer.c
index 2594f00..bf19c8c 100644
--- a/kernel/drivers/analogy/transfer.c
+++ b/kernel/drivers/analogy/transfer.c
@@ -154,26 +154,17 @@ int a4l_request_irq(struct a4l_device * dev,
unsigned long flags, void *cookie)
 {
int ret;
-   unsigned long __flags;
 
if (dev->transfer.irq_desc.irq != A4L_IRQ_UNUSED)
return -EBUSY;
 
-   /* A spinlock is used so as to prevent race conditions
-  on the field "irq" of the IRQ descriptor
-  (even if such a case is bound not to happen) */
-   rtdm_lock_get_irqsave(&dev->lock, __flags);
-
-   ret = __a4l_request_irq(&dev->transfer.irq_desc,
-   irq, handler, flags, cookie);
-
+   ret = __a4l_request_irq(&dev->transfer.irq_desc, irq, handler, flags,
+   cookie);
if (ret != 0) {
__a4l_err("a4l_request_irq: IRQ registration failed\n");
dev->transfer.irq_desc.irq = A4L_IRQ_UNUSED;
}
 
-   rtdm_lock_put_irqrestore(&dev->lock, __flags);
-
return ret;
 }
 


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


[Xenomai-git] Jorge Ramirez-Ortiz : lib/analogy: use stddev to calculate stddev_of_mean

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 50aa0a9aae828ecedaf1d5ff6f875755fe32a9b5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50aa0a9aae828ecedaf1d5ff6f875755fe32a9b5

Author: Jorge Ramirez-Ortiz 
Date:   Sun Oct 26 10:47:45 2014 -0400

lib/analogy: use stddev to calculate stddev_of_mean

---

 lib/analogy/math.c |   12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/lib/analogy/math.c b/lib/analogy/math.c
index c0e2f60..1679ecd 100644
--- a/lib/analogy/math.c
+++ b/lib/analogy/math.c
@@ -449,16 +449,8 @@ void a4l_math_stddev(double *pstddev, double mean, double 
*val, unsigned nr)
  */
 void a4l_math_stddev_of_mean(double *pstddevm, double mean, double *val, 
unsigned nr)
 {
-   double sum, sum_sq;
-   int i;
-
-   for (sum = 0, sum_sq = 0, i = 0; i < nr; i++) {
-   double x = val[i] - mean;
-   sum_sq += x * x;
-   sum += x;
-   }
-
-   *pstddevm = sqrt(((sum_sq - (sum * sum) / nr) / (nr - 1)) / nr);
+   a4l_math_stddev(pstddevm, mean, val, nr);
+   *pstddevm = *pstddevm / sqrt(nr); 
 }
 
 


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - implement calibrated insn_read

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 54b8e8c46a1feb0b07cacbc255f63955868cd006
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=54b8e8c46a1feb0b07cacbc255f63955868cd006

Author: Jorge Ramirez-Ortiz 
Date:   Fri Oct 24 09:01:09 2014 -0400

utils/analogy: calibration - implement calibrated insn_read

---

 utils/analogy/insn_read.c |   85 +++--
 1 file changed, 82 insertions(+), 3 deletions(-)

diff --git a/utils/analogy/insn_read.c b/utils/analogy/insn_read.c
index 842bddb..3592aac 100644
--- a/utils/analogy/insn_read.c
+++ b/utils/analogy/insn_read.c
@@ -39,6 +39,7 @@ static int idx_subd = -1;
 static int idx_chan;
 static int idx_rng = -1;
 static unsigned int scan_size = SCAN_CNT;
+static char *calibration_file = NULL;
 
 struct option insn_read_opts[] = {
{"verbose", no_argument, NULL, 'v'},
@@ -47,6 +48,7 @@ struct option insn_read_opts[] = {
{"scan-count", required_argument, NULL, 'S'},
{"channel", required_argument, NULL, 'c'},
{"range", required_argument, NULL, 'R'},
+   {"cal", required_argument, NULL, 'y'},
{"raw", no_argument, NULL, 'w'},
{"help", no_argument, NULL, 'h'},
{0},
@@ -63,6 +65,7 @@ static void do_print_usage(void)
fprintf(stdout, "\t\t -c, --channel: channel to use\n");
fprintf(stdout, "\t\t -R, --range: range to use\n");
fprintf(stdout, "\t\t -w, --raw: dump data in raw format\n");
+   fprintf(stdout, "\t\t -y, --cal: /path/to/calibration.bin \n");
fprintf(stdout, "\t\t -h, --help: print this help\n");
 }
 
@@ -118,9 +121,8 @@ static int dump_text(a4l_desc_t *dsc, unsigned char *buf, 
int size)
if (err < 0)
goto out;
 
-   for (i = 0; i < tmp_cnt; i++) {
+   for (i = 0; i < tmp_cnt; i++)
fprintf(stdout, fmt, values[i]);
-   }
 
tmp_size += tmp_cnt * width;
}
@@ -162,6 +164,7 @@ static int dump_converted(a4l_desc_t *dsc, unsigned char 
*buf, int size)
goto out;
}
 
+   fprintf(stdout, "Non Calibrated values: \n");
while (size - tmp_size > 0) {
double values[64];
int i, tmp_cnt = ((size - tmp_size) / width > 64) ?
@@ -182,6 +185,78 @@ out:
return err;
 }
 
+static int dump_calibrated(a4l_desc_t *dsc, unsigned char *buf, int size)
+{
+   struct a4l_calibration_data cal_info;
+   struct a4l_polynomial converter;
+   int err = 0, width, tmp_size = 0;
+   a4l_chinfo_t *chan;
+   a4l_rnginfo_t *rng;
+
+
+   /* Retrieve the channel info */
+   err = a4l_get_chinfo(dsc, idx_subd, idx_chan, &chan);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: info for channel %d "
+   "on subdevice %d not available (err=%d)\n",
+   idx_chan, idx_subd, err);
+   goto out;
+   }
+
+   /* Retrieve the range info */
+   err = a4l_get_rnginfo(dsc, idx_subd, idx_chan, idx_rng, &rng);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: failed to recover range descriptor\n");
+   goto out;
+   }
+
+   width = a4l_sizeof_chan(chan);
+   if (width < 0) {
+   fprintf(stderr,
+   "insn_read: incoherent info for channel %d\n",
+   idx_chan);
+   err = width;
+   goto out;
+   }
+
+   err = a4l_read_calibration_file(calibration_file, &cal_info);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: failed to read /tmp/calibration.txt \n");
+   goto out;
+   }
+
+   err = a4l_get_softcal_converter(&converter, idx_subd, idx_chan, idx_rng,
+   &cal_info);
+   if (err < 0) {
+   fprintf(stderr,
+   "insn_read: failed to get the softcal converter  \n");
+   goto out;
+   }
+
+   fprintf(stdout, "Calibrated values: \n");
+   while (size - tmp_size > 0) {
+   double values[64];
+   int i, tmp_cnt = ((size - tmp_size) / width > 64) ?
+   64 : ((size - tmp_size) / width);
+
+   err = a4l_rawtodcal(chan, values, buf + tmp_size, tmp_cnt,
+   &converter);
+   if (err < 0)
+   goto out;
+
+   for (i = 0; i < tmp_cnt; i++)
+   fprintf(stdout, "%F\n", values[i]);
+
+   tmp_size += tmp_cnt * width;
+   }
+
+out:
+   return err;
+}
+
 int main(int argc, char *argv[])
 {
int err = 0;
@@ -196,7 +271,7 @@ int main(int argc, char *argv[])
/* Compute arguments */
while ((err = getopt_long(argc,
  argv,
- "vrd:s:S:c:R:w

[Xenomai-git] Jorge Ramirez-Ortiz : lib/analogy: fix a4l_sync_read wait call

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 465302d146d293149f7646b409e6bee28e1af464
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=465302d146d293149f7646b409e6bee28e1af464

Author: Jorge Ramirez-Ortiz 
Date:   Thu Aug 21 15:22:05 2014 -0400

lib/analogy: fix a4l_sync_read wait call

---

 lib/analogy/sync.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/analogy/sync.c b/lib/analogy/sync.c
index 6dd49f9..fee5fc9 100644
--- a/lib/analogy/sync.c
+++ b/lib/analogy/sync.c
@@ -211,13 +211,13 @@ int a4l_sync_read(a4l_desc_t * dsc,
.type = A4L_INSN_READ,
.idx_subd = idx_subd,
.chan_desc = chan_desc,
-   .data_size = 0,
+   .data_size = nbyte,
.data = buf},
{
.type = A4L_INSN_WAIT,
.idx_subd = idx_subd,
.chan_desc = chan_desc,
-   .data_size = 1,
+   .data_size = sizeof(unsigned int),
.data = NULL}
};
 


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


[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: modify the cmd test behaviour

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1c00aab42aec168634b0380cfc1735296e164db0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1c00aab42aec168634b0380cfc1735296e164db0

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 26 13:50:41 2014 -0400

drivers/analogy: modify the cmd test behaviour

---

 kernel/drivers/analogy/command.c |   66 +-
 1 file changed, 44 insertions(+), 22 deletions(-)

diff --git a/kernel/drivers/analogy/command.c b/kernel/drivers/analogy/command.c
index 213591d..7420bc5 100644
--- a/kernel/drivers/analogy/command.c
+++ b/kernel/drivers/analogy/command.c
@@ -26,16 +26,18 @@
 #include 
 
 /* --- Command descriptor management functions --- */
-int a4l_fill_cmddesc(struct a4l_device_context * cxt, struct a4l_cmd_desc * 
desc, void *arg)
+int a4l_fill_cmddesc(struct a4l_device_context *cxt, struct a4l_cmd_desc *desc,
+unsigned int **chan_descs, void *arg)
 {
-   int ret = 0;
unsigned int *tmpchans = NULL;
+   int ret = 0;
 
ret = rtdm_safe_copy_from_user(rtdm_private_to_fd(cxt),
   desc, arg, sizeof(struct a4l_cmd_desc));
if (ret != 0)
goto out_cmddesc;
 
+
if (desc->nb_chan == 0) {
ret = -EINVAL;
goto out_cmddesc;
@@ -50,13 +52,16 @@ int a4l_fill_cmddesc(struct a4l_device_context * cxt, 
struct a4l_cmd_desc * desc
ret = rtdm_safe_copy_from_user(rtdm_private_to_fd(cxt),
   tmpchans,
   desc->chan_descs,
-  desc->nb_chan * sizeof(unsigned long));
-   if (ret != 0)
+  desc->nb_chan * sizeof(unsigned int));
+   if (ret != 0) {
+   __a4l_err("%s invalid arguments \n", __FUNCTION__);
goto out_cmddesc;
+   }
 
+   *chan_descs = desc->chan_descs;
desc->chan_descs = tmpchans;
 
-   __a4l_dbg(1, core_dbg, "desc dump\n");
+   __a4l_dbg(1, core_dbg, "desc dump: \n");
__a4l_dbg(1, core_dbg, "\t->idx_subd=%u\n", desc->idx_subd);
__a4l_dbg(1, core_dbg, "\t->flags=%lu\n", desc->flags);
__a4l_dbg(1, core_dbg, "\t->nb_chan=%u\n", desc->nb_chan);
@@ -64,9 +69,10 @@ int a4l_fill_cmddesc(struct a4l_device_context * cxt, struct 
a4l_cmd_desc * desc
__a4l_dbg(1, core_dbg, "\t->data_len=%u\n", desc->data_len);
__a4l_dbg(1, core_dbg, "\t->pdata=0x%p\n", desc->data);
 
-  out_cmddesc:
+   out_cmddesc:
 
if (ret != 0) {
+   __a4l_err("a4l_fill_cmddesc: %d \n", ret);
if (tmpchans != NULL)
rtdm_free(tmpchans);
desc->chan_descs = NULL;
@@ -113,7 +119,7 @@ int a4l_check_cmddesc(struct a4l_device_context * cxt, 
struct a4l_cmd_desc * des
}
 
return a4l_check_chanlist(dev->transfer.subds[desc->idx_subd],
-desc->nb_chan, desc->chan_descs);
+ desc->nb_chan, desc->chan_descs);
 }
 
 /* --- Command checking functions --- */
@@ -124,7 +130,7 @@ int a4l_check_generic_cmdcnt(struct a4l_cmd_desc * desc)
 
/* Makes sure trigger sources are trivially valid */
tmp1 =
-   desc->start_src & ~(TRIG_NOW | TRIG_INT | TRIG_EXT | TRIG_FOLLOW);
+   desc->start_src & ~(TRIG_NOW | TRIG_INT | TRIG_EXT | TRIG_FOLLOW);
tmp2 = desc->start_src & (TRIG_NOW | TRIG_INT | TRIG_EXT | TRIG_FOLLOW);
if (tmp1 != 0 || tmp2 == 0) {
__a4l_err("a4l_check_cmddesc: start_src, weird trigger\n");
@@ -288,6 +294,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * ctx, void 
*arg)
int ret = 0, simul_flag = 0;
struct a4l_cmd_desc *cmd_desc = NULL;
struct a4l_device *dev = a4l_get_dev(ctx);
+   unsigned int *chan_descs, *tmp;
struct a4l_subdevice *subd;
 
/* The command launching cannot be done in real-time because
@@ -309,7 +316,7 @@ int a4l_ioctl_cmd(struct a4l_device_context * ctx, void 
*arg)
memset(cmd_desc, 0, sizeof(struct a4l_cmd_desc));
 
/* Gets the command */
-   ret = a4l_fill_cmddesc(ctx, cmd_desc, arg);
+   ret = a4l_fill_cmddesc(ctx, cmd_desc, &chan_descs, arg);
if (ret != 0)
goto out_ioctl_cmd;
 
@@ -327,24 +334,28 @@ int a4l_ioctl_cmd(struct a4l_device_context * ctx, void 
*arg)
goto out_ioctl_cmd;
 
__a4l_dbg(1, core_dbg,"1st cmd checks passed\n");
-
subd = dev->transfer.subds[cmd_desc->idx_subd];
 
/* Tests the command with the cmdtest function */
-   if (subd->do_cmdtest != NULL)
-   ret = subd->do_cmdtest(subd, cmd_desc);
-   if (ret != 0) {
-   __a4l_err("a4l_ioctl_cmd: driver's cmd_test failed\n");
-   goto out_ioctl_cmd;
-   }
-
-   __a4l_dbg(1, core_dbg, "driver's cmd checks passed\n");
-
if (cmd_des

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: NI_M - retrieve the sampling period via A4L_CMD_SIMUL

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9d5eda59702de396d6bb20158357e4ed2162fefe
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9d5eda59702de396d6bb20158357e4ed2162fefe

Author: Jorge Ramirez-Ortiz 
Date:   Tue Aug 19 14:13:08 2014 -0400

drivers/analogy: NI_M - retrieve the sampling period via A4L_CMD_SIMUL

---

 kernel/drivers/analogy/national_instruments/mio_common.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/analogy/national_instruments/mio_common.c 
b/kernel/drivers/analogy/national_instruments/mio_common.c
index f0f2abf..e5ccf7a 100644
--- a/kernel/drivers/analogy/national_instruments/mio_common.c
+++ b/kernel/drivers/analogy/national_instruments/mio_common.c
@@ -2067,12 +2067,14 @@ static int ni_ai_cmdtest(struct a4l_subdevice *subd, 
struct a4l_cmd_desc * cmd)
   
cmd->nb_chan)) {
cmd->scan_begin_arg =
ni_min_ai_scan_period_ns(dev, cmd->nb_chan);
-   return -EINVAL;
-   }
-   if (cmd->scan_begin_arg > devpriv->clock_ns * 0xff) {
+
+   if (cmd->scan_begin_arg > devpriv->clock_ns * 0xff)
cmd->scan_begin_arg = devpriv->clock_ns * 0xff;
-   return -EINVAL;
+
+   /* required for calibration */
+   return 0;
}
+
} else if (cmd->scan_begin_src == TRIG_EXT) {
/* external trigger */
unsigned int tmp = CR_CHAN(cmd->scan_begin_arg);


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - parse the calibration file

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 07b4608034dc1deff8231a3f51ec211609739764
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=07b4608034dc1deff8231a3f51ec211609739764

Author: Jorge Ramirez-Ortiz 
Date:   Wed Sep 17 09:30:13 2014 -0700

utils/analogy: calibration - parse the calibration file

---

 lib/boilerplate/iniparser/iniparser.c |6 +-
 utils/analogy/analogy_calibrate.c |   42 ++--
 utils/analogy/analogy_calibrate.h |  123 +++---
 utils/analogy/calibration_ni_m.c  |  184 -
 utils/analogy/calibration_ni_m.h  |9 +-
 5 files changed, 241 insertions(+), 123 deletions(-)

diff --git a/lib/boilerplate/iniparser/iniparser.c 
b/lib/boilerplate/iniparser/iniparser.c
index 0e1621d..5b2094a 100644
--- a/lib/boilerplate/iniparser/iniparser.c
+++ b/lib/boilerplate/iniparser/iniparser.c
@@ -619,11 +619,13 @@ dictionary * iniparser_load(const char * ininame)
 
case LINE_ERROR:
 #if 0
-warning(anon_scope, "iniparser: syntax error in %s (%d):\n",
+printf("iniparser: syntax error in %s (%d):\n",
 ininame,
 lineno);
-warning(anon_scope, "-> %s\n", line);
+printf( "-> %s\n", line);
+
 #endif
+
ret = EINVAL;
 errs++ ;
 break;
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
index b2ac286..8404811 100644
--- a/utils/analogy/analogy_calibrate.c
+++ b/utils/analogy/analogy_calibrate.c
@@ -87,22 +87,22 @@ apply_calibration_set_globals(char *info)
params.name = strtok(info, ":");
p = strtok(NULL, ",");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter subd \n");
params.subd = strtol(p, NULL, 0);
 
p = strtok(NULL, ",");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter channel \n");
params.channel = strtol(p, NULL, 0);
 
p = strtok(NULL, ",");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter range \n");
params.range = strtol(p, NULL, 0);
 
p = strtok(NULL, "");
if (!p)
-   error(EXIT, 0, "missing --apply parameter \n");
+   error(EXIT, 0, "missing --apply parameter aref \n");
params.aref = strtol(p, NULL, 0);
 
return 0;
@@ -114,10 +114,8 @@ static void __attribute__ ((constructor)) 
__analogy_calibrate_init(void)
 }
 int main(int argc, char *argv[])
 {
-   struct sched_param param = {.sched_priority = 99};
char *device = NULL, *file = NULL, *apply_info = NULL;
int v, i, fd, err = 0;
-   struct rlimit rl;
 
__debug("version: git commit %s, revision %s \n", GIT_STAMP, revision);
 
@@ -152,26 +150,6 @@ int main(int argc, char *argv[])
if (apply_info)
apply_calibration_set_globals(apply_info);
 
-   err = getrlimit(RLIMIT_STACK, &rl);
-   if (!err) {
-   if (rl.rlim_cur < rl.rlim_max) {
-   rl.rlim_cur = rl.rlim_max;
-   err = setrlimit(RLIMIT_STACK, &rl);
-   if (err)
-   __debug("setrlimit errno (%d) \n", errno);
-   else
-   __debug("Program Stack Size: %ld MB \n\n", 
rl.rlim_cur/(1024*1024));
-   }
-   }
-
-   err = mlockall(MCL_CURRENT | MCL_FUTURE);
-   if (err < 0)
-   error(EXIT, errno, "mlockall error");
-
-   err = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);
-   if (err)
-   error(EXIT, 0, "pthread_setschedparam failed (0x%x)", err);
-
fd = a4l_open(&descriptor, device);
if (fd < 0)
error(EXIT, 0, "open %s failed (%d)", device, fd);
@@ -184,17 +162,19 @@ int main(int argc, char *argv[])
/*
 * TODO: modify the meaning of board/driver in the proc
 */
-   push_to_cal_file("[platform] \n");
-   push_to_cal_file("driver_name: %s \n", descriptor.board_name);
-   push_to_cal_file("board_name: %s \n", descriptor.driver_name);
+   push_to_cal_file("[%s] \n",PLATFORM_STR);
+   push_to_cal_file(DRIVER_STR" = %s;\n", descriptor.board_name);
+   push_to_cal_file(BOARD_STR" = %s;\n", descriptor.driver_name);
 
err = ni_m_software_calibrate();
if (err)
error(CONT, 0, "software calibration failed (%d)", err);
 
+   err = ni_m_apply_calibration();
+   if (err)
+   error(CONT, 0, "applying calibration failed (%d)", err);
+
a4l_close(&descriptor);
-   if (cal)
-   fclose(cal);
 
return err;
 }
diff --git a/utils/analogy/analogy_calibrate.h 
b/utils/analogy/analogy_calibrate.h
index

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - use iniparser

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 68033dcc5bf6c732eba6a43390aca34c9f490e98
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=68033dcc5bf6c732eba6a43390aca34c9f490e98

Author: Jorge Ramirez-Ortiz 
Date:   Fri Sep 12 11:55:40 2014 -0400

utils/analogy: calibration - use iniparser

---

 utils/analogy/Makefile.am |4 ++-
 utils/analogy/analogy_calibrate.c |   57 -
 utils/analogy/analogy_calibrate.h |   11 ++-
 utils/analogy/calibration_ni_m.c  |   40 ++
 4 files changed, 103 insertions(+), 9 deletions(-)

diff --git a/utils/analogy/Makefile.am b/utils/analogy/Makefile.am
index fe2f317..40c09f3 100644
--- a/utils/analogy/Makefile.am
+++ b/utils/analogy/Makefile.am
@@ -12,7 +12,9 @@ bin_PROGRAMS = \
 CPPFLAGS = \
@XENO_USER_CFLAGS@  \
-ggdb   \
-   -I$(top_srcdir)/include
+   -I$(top_srcdir)/include \
+   -I$(top_srcdir)/lib/boilerplate 
+
 
 LDFLAGS =
 
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
index 586a38a..b2ac286 100644
--- a/utils/analogy/analogy_calibrate.c
+++ b/utils/analogy/analogy_calibrate.c
@@ -31,7 +31,7 @@
 #include "analogy_calibrate.h"
 #include "calibration_ni_m.h"
 
-
+struct apply_calibration_params params = {.name = NULL,} ;
 struct timespec calibration_start_time;
 static const char *revision = "0.0.1";
 a4l_desc_t descriptor;
@@ -57,28 +57,65 @@ static const struct option options[] = {
.flag = NULL,
},
{
+#define apply_opt  3
+   .name = "apply",
+   .has_arg = 1,
+   .flag = NULL,
+   },
+   {
.name = NULL,
}
 };
 
-static void print_usage(void)
+static void
+print_usage(void)
 {
fprintf(stderr, "Usage: analogy_calibrate \n"
-  "  --help: this menu \n"
-  "  --device /dev/analogyX: analogy device to calibrate 
\n"
-  "  --output filename : calibration results \n"
+  "  --help: this menu \n"
+  "  --device /dev/analogyX: analogy 
device to calibrate \n"
+  "  --output filename : calibration 
results \n"
+  "  --apply filename:subd,channel,range,aref  : apply the 
calibration file \n"
+  "  ex: /home/foo/calib.rc:0,1,255,255 - use 255 for dont 
care \n"
  );
 }
 
+static int
+apply_calibration_set_globals(char *info)
+{
+   char *p;
+
+   params.name = strtok(info, ":");
+   p = strtok(NULL, ",");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.subd = strtol(p, NULL, 0);
+
+   p = strtok(NULL, ",");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.channel = strtol(p, NULL, 0);
+
+   p = strtok(NULL, ",");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.range = strtol(p, NULL, 0);
+
+   p = strtok(NULL, "");
+   if (!p)
+   error(EXIT, 0, "missing --apply parameter \n");
+   params.aref = strtol(p, NULL, 0);
+
+   return 0;
+}
+
 static void __attribute__ ((constructor)) __analogy_calibrate_init(void)
 {
clock_gettime(CLOCK_MONOTONIC, &calibration_start_time);
 }
-
 int main(int argc, char *argv[])
 {
struct sched_param param = {.sched_priority = 99};
-   char *device = NULL, *file = NULL;
+   char *device = NULL, *file = NULL, *apply_info = NULL;
int v, i, fd, err = 0;
struct rlimit rl;
 
@@ -103,12 +140,18 @@ int main(int argc, char *argv[])
error(EXIT, errno, "calibration file");
__debug("calibration output: %s \n", file);
break;
+   case apply_opt:
+   apply_info = optarg;
+   break;
default:
print_usage();
exit(EXIT_FAILURE);
}
}
 
+   if (apply_info)
+   apply_calibration_set_globals(apply_info);
+
err = getrlimit(RLIMIT_STACK, &rl);
if (!err) {
if (rl.rlim_cur < rl.rlim_max) {
diff --git a/utils/analogy/analogy_calibrate.h 
b/utils/analogy/analogy_calibrate.h
index 1fb548e..c2b539a 100644
--- a/utils/analogy/analogy_calibrate.h
+++ b/utils/analogy/analogy_calibrate.h
@@ -38,8 +38,17 @@ extern struct timespec calibration_start_time;
 extern a4l_desc_t descriptor;
 extern FILE *cal;
 
-#define ARRAY_LEN(a)  (sizeof(a) / sizeof((a)[0]))
+struct apply_calibration_params {
+   int channel;
+   char *name;
+   int range;
+   int subd;
+

[Xenomai-git] Jorge Ramirez-Ortiz : lib/boilerplate: add iniparser to boilerplate

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 67803dce543ee6f680f42e8dcd2c77b2fc383ad6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=67803dce543ee6f680f42e8dcd2c77b2fc383ad6

Author: Jorge Ramirez-Ortiz 
Date:   Fri Sep 12 10:01:45 2014 -0400

lib/boilerplate: add iniparser to boilerplate

---

 lib/boilerplate/Makefile.am|   21 +-
 lib/boilerplate/iniparser/LICENSE  |   21 +
 lib/boilerplate/iniparser/README   |1 +
 lib/boilerplate/iniparser/dictionary.c |  405 +++
 lib/boilerplate/iniparser/dictionary.h |  174 +
 lib/boilerplate/iniparser/iniparser.c  |  667 
 lib/boilerplate/iniparser/iniparser.h  |  281 ++
 7 files changed, 1567 insertions(+), 3 deletions(-)

diff --git a/lib/boilerplate/Makefile.am b/lib/boilerplate/Makefile.am
index 0a14d18..e2275c1 100644
--- a/lib/boilerplate/Makefile.am
+++ b/lib/boilerplate/Makefile.am
@@ -31,10 +31,25 @@ libboilerplate_la_CPPFLAGS =
\
-I$(top_srcdir) \
-I$(top_srcdir)/include
 
+libboilerplate_la_LIBADD = libiniparser.la
+noinst_LTLIBRARIES += libiniparser.la
+
+libiniparser_la_SOURCES=   \
+   iniparser/dictionary.c  \
+   iniparser/dictionary.h  \
+   iniparser/iniparser.h   \
+   iniparser/iniparser.c
+
+libiniparser_la_CPPFLAGS   =   \
+   -Iiniparser @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir)/include
+
+EXTRA_DIST = iniparser/README iniparser/LICENSE
+
 # We always build the tlsf/malloc support. In the pshared case, it
 # will provide for private memory allocation.
 if XENO_TLSF
-libboilerplate_la_LIBADD = libtlsf.la
+libboilerplate_la_LIBADD +=libtlsf.la
 noinst_LTLIBRARIES += libtlsf.la
 endif
 
@@ -48,11 +63,11 @@ libtlsf_la_CPPFLAGS =   
\
-I$(top_srcdir)/include \
-DTLSF_USE_LOCKS=1 -DUSE_MMAP=1 -DTLSF_STATISTIC=1
 
-EXTRA_DIST = tlsf/README
+EXTRA_DIST += tlsf/README
 
 SPARSE = sparse
 
 sparse:
-   @for i in $(libboilerplate_la_SOURCES) $(libtlsf_la_SOURCES); do \
+   @for i in $(libboilerplate_la_SOURCES) $(libtlsf_la_SOURCES) 
$(libiniparser_la_SOURCES; do \
$(SPARSE) $(CHECKFLAGS) $(srcdir)/$$i; \
done
diff --git a/lib/boilerplate/iniparser/LICENSE 
b/lib/boilerplate/iniparser/LICENSE
new file mode 100644
index 000..dbfa45d
--- /dev/null
+++ b/lib/boilerplate/iniparser/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2000-2007 by Nicolas Devillard.
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
diff --git a/lib/boilerplate/iniparser/README b/lib/boilerplate/iniparser/README
new file mode 100644
index 000..dfa43c8
--- /dev/null
+++ b/lib/boilerplate/iniparser/README
@@ -0,0 +1 @@
+See http://ndevilla.free.fr/iniparser/
diff --git a/lib/boilerplate/iniparser/dictionary.c 
b/lib/boilerplate/iniparser/dictionary.c
new file mode 100644
index 000..5299b77
--- /dev/null
+++ b/lib/boilerplate/iniparser/dictionary.c
@@ -0,0 +1,405 @@
+/*-*/
+/**
+   @file   dictionary.c
+   @author N. Devillard
+   @date   Sep 2007
+   @version$Revision: 1.27 $
+   @brief  Implements a dictionary for string variables.
+
+   This module implements a simple dictionary object, i.e. a list
+   of string/string associations. This object is useful to store e.g.
+   informations retrieved from a configuration file (ini files).
+*/
+/*--*/
+
+/*
+   $Id: dictionary.c,v 1.27 2007-11-23 21:39:18 ndevilla Exp $
+   $Revision: 1.27 $
+*/
+/*---
+   Includes
+ ---*/
+#include

[Xenomai-git] Jorge Ramirez-Ortiz : drivers/analogy: NI M - 622x ranges changed to bipolar

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6f3465ff217435c22aebaf3cf9cba4dc78f9c9fe
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6f3465ff217435c22aebaf3cf9cba4dc78f9c9fe

Author: Jorge Ramirez-Ortiz 
Date:   Thu Sep  4 10:35:26 2014 -0400

drivers/analogy: NI M - 622x ranges changed to bipolar

---

 kernel/drivers/analogy/national_instruments/pcimio.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/drivers/analogy/national_instruments/pcimio.c 
b/kernel/drivers/analogy/national_instruments/pcimio.c
index e7a2ab3..8a3 100644
--- a/kernel/drivers/analogy/national_instruments/pcimio.c
+++ b/kernel/drivers/analogy/national_instruments/pcimio.c
@@ -801,7 +801,7 @@ static ni_board ni_boards[]={
n_aochan:   2,
aobits: 16,
ao_fifo_depth:  8191,
-   .ao_range_table = &range_ni_M_622x_ao,
+   .ao_range_table = &a4l_range_bipolar10,
reg_type:   ni_reg_622x,
ao_unipolar:0,
ao_speed:   1200,
@@ -819,7 +819,7 @@ static ni_board ni_boards[]={
n_aochan:   2,
aobits: 16,
ao_fifo_depth:  8191,
-   .ao_range_table = &range_ni_M_622x_ao,
+   .ao_range_table = &a4l_range_bipolar10,
reg_type:   ni_reg_622x,
ao_unipolar:0,
ao_speed:   1200,


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


[Xenomai-git] Philippe Gerum : cobalt/sched/tp: fix double unlink on thread fallback to FIFO

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4cfacb30c140b9534d2e40ace5c4e4d4baa10874
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4cfacb30c140b9534d2e40ace5c4e4d4baa10874

Author: Philippe Gerum 
Date:   Sun Oct 26 16:14:19 2014 +0100

cobalt/sched/tp: fix double unlink on thread fallback to FIFO

---

 kernel/cobalt/sched-tp.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/cobalt/sched-tp.c b/kernel/cobalt/sched-tp.c
index 484e339..d3e7f5f 100644
--- a/kernel/cobalt/sched-tp.c
+++ b/kernel/cobalt/sched-tp.c
@@ -253,7 +253,6 @@ xnsched_tp_set_schedule(struct xnsched *sched,
goto done;
 
list_for_each_entry_safe(thread, tmp, &tp->threads, tp_link) {
-   list_del(&thread->tp_link);
param.rt.prio = thread->cprio;
xnsched_set_policy(thread, &xnsched_class_rt, ¶m);
}


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - use the analogy' s math utils

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a66aefdeb317df5772f84eeba1468343a9e450c1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a66aefdeb317df5772f84eeba1468343a9e450c1

Author: Jorge Ramirez-Ortiz 
Date:   Tue Oct 14 21:03:05 2014 -0400

utils/analogy: calibration - use the analogy's math utils

---

 include/rtdm/analogy.h|   12 ++
 include/rtdm/uapi/analogy.h   |2 +-
 lib/analogy/Makefile.am   |5 +-
 lib/analogy/calibration.c |   22 ++
 lib/analogy/calibration.h |   21 ++
 lib/analogy/math.c|  418 +
 utils/analogy/Makefile.am |2 +-
 utils/analogy/analogy_calibrate.c |6 +-
 utils/analogy/calibration_ni_m.c  |  106 +++---
 utils/analogy/calibration_ni_m.h  |6 +-
 10 files changed, 515 insertions(+), 85 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index fd26f58..c03d2b1 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -236,6 +236,18 @@ void a4l_write_calibration_file(FILE *dst, struct list *l,
 
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
 
+int a4l_math_polyfit(unsigned order, double *r,double orig,
+const unsigned dim, double *x, double *y);
+
+void a4l_math_mean(double *pmean, double *val, unsigned nr);
+
+void a4l_math_stddev(double *pstddev,
+double mean, double *val, unsigned nr);
+
+void a4l_math_stddev_of_mean(double *pstddevm,
+double mean, double *val, unsigned nr);
+
+
 
 
 #endif /* !DOXYGEN_CPP */
diff --git a/include/rtdm/uapi/analogy.h b/include/rtdm/uapi/analogy.h
index 669ded7..a0a1e59 100644
--- a/include/rtdm/uapi/analogy.h
+++ b/include/rtdm/uapi/analogy.h
@@ -708,9 +708,9 @@ typedef struct a4l_instruction_list a4l_insnlst_t;
 
 struct a4l_calibration_subdev {
a4l_sbinfo_t *info;
+   char *name;
int slen;
int idx;
-   char *name;
 };
 
 struct a4l_calibration_subdev_data {
diff --git a/lib/analogy/Makefile.am b/lib/analogy/Makefile.am
index 500453d..b79d4cb 100644
--- a/lib/analogy/Makefile.am
+++ b/lib/analogy/Makefile.am
@@ -7,6 +7,7 @@ libanalogy_la_SOURCES = \
descriptor.c\
info.c  \
internal.h  \
+   math.c  \
calibration.c   \
range.c \
root_leaf.h \
@@ -19,4 +20,6 @@ libanalogy_la_CPPFLAGS =  \
-I$(top_srcdir)/lib/boilerplate 
 
 libanalogy_la_LIBADD = \
-   ../boilerplate/libboilerplate.la
+   ../boilerplate/libboilerplate.la\
+   -lm
+
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index 74b2789..85860d1 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -1,3 +1,25 @@
+/**
+ * @file
+ * Analogy for Linux, device, subdevice, etc. related features
+ *
+ * @note Copyright (C) 1997-2000 David A. Schleef 
+ * @note Copyright (C) 2014 Jorge A. Ramirez-Ortiz 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
 #include 
 #include 
 #include 
diff --git a/lib/analogy/calibration.h b/lib/analogy/calibration.h
index 04a7e72..4080c60 100644
--- a/lib/analogy/calibration.h
+++ b/lib/analogy/calibration.h
@@ -1,3 +1,24 @@
+/**
+ * @file
+ * Analogy for Linux, internal calibration declarations
+ *
+ * @note Copyright (C) 2014 Jorge A Ramirez-Ortiz 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+
 #ifndef __ANALOGY_CALIBRATION_H__
 #define __ANALOGY_CALIBRATION_H__
 
diff --git a/lib/analogy/math.c b/lib/analogy/math.c
new 

[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 92b6dab81dcf6d5be10642010830c359410055a7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=92b6dab81dcf6d5be10642010830c359410055a7

Author: Philippe Gerum 
Date:   Wed Oct 22 15:20:21 2014 +0200

drivers/rtipc: fixup for 32bit emulation

---

 kernel/drivers/ipc/bufp.c |  115 ++---
 kernel/drivers/ipc/iddp.c |  123 +++---
 kernel/drivers/ipc/internal.h |   41 -
 kernel/drivers/ipc/rtipc.c|  365 -
 kernel/drivers/ipc/xddp.c |  113 ++---
 5 files changed, 520 insertions(+), 237 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 1e5ecf3..5ae166a 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Copy I/O vector in */
-   if (rtipc_get_arg(fd, iov, msg->msg_iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
+   ret = rtipc_get_iovec(fd, iov, msg);
+   if (ret)
+   return ret;
 
ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr);
if (ret <= 0)
return ret;
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_arg(fd, msg->msg_iov, iov,
- sizeof(iov[0]) * msg->msg_iovlen))
+   if (rtipc_put_iovec(fd, iov, msg))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Fetch the destination address to send to. */
-   if (rtipc_get_arg(fd, &daddr,
- msg->msg_name, sizeof(daddr)))
+   if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr)))
return -EFAULT;
 
if (daddr.sipc_port < 0 ||
@@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EINVAL;
 
/* Copy I/O vector in */
-   if (rtipc_get_arg(fd, iov, msg->msg_iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
+   ret = rtipc_get_iovec(fd, iov, msg);
+   if (ret)
+   return ret;
 
ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr);
if (ret <= 0)
return ret;
 
/* Copy updated I/O vector back */
-   if (rtipc_put_arg(fd, msg->msg_iov, iov,
- sizeof(iov[0]) * msg->msg_iovlen))
-   return -EFAULT;
-
-   return ret;
+   return rtipc_put_iovec(fd, iov, msg) ?: ret;
 }
 
 static ssize_t bufp_write(struct rtdm_fd *fd,
@@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
struct rtipc_port_label plabel;
struct timeval tv;
rtdm_lockctx_t s;
-   int ret = 0;
size_t len;
+   int ret;
 
-   if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt)))
-   return -EFAULT;
+   ret = rtipc_get_sockoptin(fd, &sopt, arg);
+   if (ret)
+   return ret;
 
if (sopt.level == SOL_SOCKET) {
switch (sopt.optname) {
 
case SO_RCVTIMEO:
-   if (sopt.optlen != sizeof(tv))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &tv,
- sopt.optval, sizeof(tv)))
-   return -EFAULT;
+   ret = rtipc_get_timeval(fd, &tv, sopt.optval, 
sopt.optlen);
+   if (ret)
+   return ret;
sk->rx_timeout = rtipc_timeval_to_ns(&tv);
break;
 
case SO_SNDTIMEO:
-   if (sopt.optlen != sizeof(tv))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &tv,
- sopt.optval, sizeof(tv)))
-   return -EFAULT;
+   ret = rtipc_get_timeval(fd, &tv, sopt.optval, 
sopt.optlen);
+   if (ret)
+   return ret;
sk->tx_timeout = rtipc_timeval_to_ns(&tv);
break;
 
@@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk,
switch (sopt.optname) {
 
case BUFP_BUFSZ:
-   if (sopt.optlen != sizeof(len))
-   return -EINVAL;
-   if (rtipc_get_arg(fd, &len,
- sopt.optval, sizeof(len)))
-   return -EFAULT;
+   ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen);
+   if (ret)
+   return ret;
if (len == 0)
   

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - cleanup

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a4ec3dfe961e91e26abf61b78036481eda213e60
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a4ec3dfe961e91e26abf61b78036481eda213e60

Author: Jorge Ramirez-Ortiz 
Date:   Sat Oct 25 12:37:33 2014 -0400

utils/analogy: calibration - cleanup

---

 lib/analogy/calibration.c |   35 ---
 utils/analogy/Makefile.am |   12 +---
 utils/analogy/analogy_calibrate.c |3 ---
 utils/analogy/analogy_calibrate.h |3 ---
 utils/analogy/calibration_ni_m.c  |6 --
 5 files changed, 9 insertions(+), 50 deletions(-)

diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index 9fd944c..331dcac 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -19,12 +19,13 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include "iniparser/iniparser.h"
 #include "boilerplate/list.h"
 #include "calibration.h"
@@ -196,36 +197,16 @@ write_calibration_file(FILE *dst, struct list *l,
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data)
 {
const char *subdevice[2] = { AI_SUBD_STR, AO_SUBD_STR };
-   struct a4l_calibration_subdev_data *p = NULL;
int i, j, k, index = -1, nb_elements = -1;
+   struct a4l_calibration_subdev_data *p = NULL;
struct _dictionary_ *d;
-   const char *filename;
-   wordexp_t exp;
-   int ret = 0;
-
-   ret = wordexp(name, &exp, WRDE_NOCMD|WRDE_UNDEF);
-   if (ret) {
-   /* can't apply calibration */
-   ret = ret == WRDE_NOSPACE ? -ENOMEM : -EINVAL;
-   return ret;
-   }
 
-   if (exp.we_wordc != 1) {
-   /* "weird expansion of %s as rc file \n", params.name */
+   if (access(name, R_OK))
return -1;
-   }
 
-   filename = exp.we_wordv[0];
-   if (access(filename, R_OK)) {
-   /* "cant access %s for reading \n", params.name */
+   d = iniparser_load(name);
+   if (d == NULL)
return -1;
-   }
-
-   d = iniparser_load(filename);
-   if (d == NULL) {
-   /* "loading error for %s (%d)\n", params.name, errno */
-   return -1;
-   }
 
read_str(&data->driver_name, d, PLATFORM_STR, DRIVER_STR);
read_str(&data->board_name, d, PLATFORM_STR, BOARD_STR);
@@ -271,7 +252,7 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
p++;
}
}
-   wordfree(&exp);
+
 
return 0;
 }
diff --git a/utils/analogy/Makefile.am b/utils/analogy/Makefile.am
index eed1265..57ff7a8 100644
--- a/utils/analogy/Makefile.am
+++ b/utils/analogy/Makefile.am
@@ -31,17 +31,7 @@ analogy_config_LDADD = \
-lrt -lpthread
 
 analogy_calibrate_SOURCES = analogy_calibrate.c calibration_ni_m.c
-analogy_calibrate.c: git-stamp.h calibration_ni_m.h
-git-stamp.h: git-stamp
-   @set -x; if test -r $(top_srcdir)/.git; then
\
- stamp=`git --git-dir=$(top_srcdir)/.git rev-list --abbrev-commit -1 
HEAD`;\
- if test \! -s $@ || grep -wvq $$stamp $@; then
\
-   date=`git --git-dir=$(top_srcdir)/.git log -1 $$stamp 
--pretty=format:%ci`; \
-   echo "#define GIT_STAMP \"#$$stamp ($$date)\"" > $@;
\
- fi;   
\
-   elif test \! -r $@ -o -s $@; then   
\
-   rm -f $@ && touch $@;   
\
-   fi; true
+analogy_calibrate.c: calibration_ni_m.h
 analogy_calibrate_LDADD = \
../../lib/analogy/libanalogy.la \
../../lib/cobalt/libcobalt.la   \
diff --git a/utils/analogy/analogy_calibrate.c 
b/utils/analogy/analogy_calibrate.c
index 1b87e39..ca33ab7 100644
--- a/utils/analogy/analogy_calibrate.c
+++ b/utils/analogy/analogy_calibrate.c
@@ -32,7 +32,6 @@
 #include "calibration_ni_m.h"
 
 struct timespec calibration_start_time;
-static const char *revision = "1.0.0";
 a4l_desc_t descriptor;
 
 static const struct option options[] = {
@@ -86,8 +85,6 @@ int main(int argc, char *argv[])
int v, i, fd, err = 0;
FILE *p = NULL;
 
-   __debug("version: git commit %s, revision %s \n", GIT_STAMP, revision);
-
for (;;) {
i = -1;
v = getopt_long_only(argc, argv, "", options, &i);
diff --git a/utils/analogy/analogy_calibrate.h 
b/utils/analogy/analogy_calibrate.h
index 09812ae..b2a1c6e 100644
--- a/utils/analogy/analogy_calibrate.h
+++ b/utils/analogy/analogy_calibrate.h

[Xenomai-git] Philippe Gerum : cobalt/sched/tp: detect assignment to unconfigured CPU

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 5278d83ea3a108bbf3bc579e7b7f9e2048bf33f0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5278d83ea3a108bbf3bc579e7b7f9e2048bf33f0

Author: Philippe Gerum 
Date:   Sun Oct 26 17:58:43 2014 +0100

cobalt/sched/tp: detect assignment to unconfigured CPU

---

 kernel/cobalt/sched-tp.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/sched-tp.c b/kernel/cobalt/sched-tp.c
index d3e7f5f..7ce04c1 100644
--- a/kernel/cobalt/sched-tp.c
+++ b/kernel/cobalt/sched-tp.c
@@ -158,8 +158,10 @@ static int xnsched_tp_declare(struct xnthread *thread,
  const union xnsched_policy_param *p)
 {
struct xnsched *sched = thread->sched;
+   struct xnsched_tp *tp = &sched->tp;
 
-   if (p->tp.prio < XNSCHED_TP_MIN_PRIO ||
+   if (tp->gps == NULL ||
+   p->tp.prio < XNSCHED_TP_MIN_PRIO ||
p->tp.prio > XNSCHED_TP_MAX_PRIO)
return -EINVAL;
 


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


[Xenomai-git] Philippe Gerum : cobalt/posix/thread: propagate error upon failed setschedparam

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: cdde256f6857d991e49b100e5fc8a9760eba9c84
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cdde256f6857d991e49b100e5fc8a9760eba9c84

Author: Philippe Gerum 
Date:   Sun Oct 26 17:57:46 2014 +0100

cobalt/posix/thread: propagate error upon failed setschedparam

---

 kernel/cobalt/posix/thread.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index defea50..27c824b 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -246,7 +246,7 @@ pthread_setschedparam_ex(struct cobalt_thread *thread,
struct xnsched_class *sched_class;
union xnsched_policy_param param;
xnticks_t tslice;
-   int ret = 0;
+   int ret;
spl_t s;
 
xnlock_get_irqsave(&nklock, s);
@@ -269,7 +269,8 @@ pthread_setschedparam_ex(struct cobalt_thread *thread,
if (cobalt_call_extension(thread_setsched, &thread->extref, ret,
  sched_class, ¶m) && ret)
goto out;
-   xnthread_set_schedparam(&thread->threadbase, sched_class, ¶m);
+   ret = xnthread_set_schedparam(&thread->threadbase,
+ sched_class, ¶m);
xnsched_run();
 out:
xnlock_put_irqrestore(&nklock, s);


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


[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: calibration - generating the calibration file is not a user API

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e3c818fee687fcf07c448c462cbba5ce29100e0b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e3c818fee687fcf07c448c462cbba5ce29100e0b

Author: Jorge Ramirez-Ortiz 
Date:   Tue Oct 14 21:53:25 2014 -0400

utils/analogy: calibration - generating the calibration file is not a user API

---

 include/rtdm/analogy.h|4 --
 lib/analogy/calibration.c |  103 +
 lib/analogy/calibration.h |3 ++
 lib/analogy/math.c|   51 +-
 utils/analogy/analogy_calibrate.c |6 +++
 utils/analogy/calibration_ni_m.c  |   15 +++---
 6 files changed, 125 insertions(+), 57 deletions(-)

diff --git a/include/rtdm/analogy.h b/include/rtdm/analogy.h
index c03d2b1..a87ce54 100644
--- a/include/rtdm/analogy.h
+++ b/include/rtdm/analogy.h
@@ -230,10 +230,6 @@ int a4l_ftoraw(a4l_chinfo_t *chan,
 int a4l_dtoraw(a4l_chinfo_t *chan,
   a4l_rnginfo_t *rng, void *dst, double *src, int cnt);
 
-void a4l_write_calibration_file(FILE *dst, struct list *l,
-   struct a4l_calibration_subdev *subd,
-   a4l_desc_t *desc);
-
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
 
 int a4l_math_polyfit(unsigned order, double *r,double orig,
diff --git a/lib/analogy/calibration.c b/lib/analogy/calibration.c
index 85860d1..dcec16d 100644
--- a/lib/analogy/calibration.c
+++ b/lib/analogy/calibration.c
@@ -103,6 +103,64 @@ static inline void write_calibration(FILE *file, char 
*fmt, ...)
va_end(ap);
 }
 
+void
+write_calibration_file(FILE *dst, struct list *l,
+  struct a4l_calibration_subdev *subd, a4l_desc_t *desc)
+{
+   struct subdevice_calibration_node *e, *t;
+   int i, j = 0;
+
+   if (list_empty(l))
+   return;
+
+   /* TODO: modify the meaning of board/driver in the proc */
+   if (desc) {
+   write_calibration(dst, "[%s] \n",PLATFORM_STR);
+   write_calibration(dst, DRIVER_STR" = %s;\n", desc->board_name);
+   write_calibration(dst, BOARD_STR" = %s;\n", desc->driver_name);
+   }
+
+   write_calibration(dst, "\n[%s] \n", subd->name);
+   write_calibration(dst, INDEX_STR" = %d;\n", subd->idx);
+   list_for_each_entry_safe(e, t, l, node) {
+   j++;
+   }
+   write_calibration(dst, ELEMENTS_STR" = %d;\n", j);
+
+   j = 0;
+   list_for_each_entry_safe(e, t, l, node) {
+   write_calibration(dst, "[%s_%d] \n", subd->name, j);
+   write_calibration(dst, CHANNEL_STR" = %d;\n", e->channel);
+   write_calibration(dst, RANGE_STR" = %d;\n", e->range);
+   write_calibration(dst, EXPANSION_STR" = %g;\n",
+ e->polynomial->expansion_origin);
+   write_calibration(dst, NBCOEFF_STR"= %d;\n",
+ e->polynomial->nb_coefficients);
+
+   for (i = 0; i < e->polynomial->nb_coefficients; i++)
+   write_calibration(dst, COEFF_STR"_%d = %g;\n",
+ i,
+ e->polynomial->coefficients[i]);
+   j++;
+   }
+
+   return;
+}
+
+/*!
+ * @ingroup analogy_lib_level2
+ * @defgroup analogy_lib_calibration Software calibration API
+ * @{
+ */
+
+/**
+ * @brief Read the analogy generated calibration file
+ *
+ * @param[in] name Name of the calibration file
+ * @param[out] data Pointer to the calibration file contents
+ *
+ */
+
 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data)
 {
const char *subdevice[2] = { AI_SUBD_STR, AO_SUBD_STR };
@@ -186,48 +244,5 @@ int a4l_read_calibration_file(char *name, struct 
a4l_calibration_data *data)
return 0;
 }
 
-void a4l_write_calibration_file(FILE *dst, struct list *l,
-   struct a4l_calibration_subdev *subd,
-   a4l_desc_t *desc)
-{
-   struct subdevice_calibration_node *e, *t;
-   int i, j = 0;
-
-   if (list_empty(l))
-   return;
-
-   /* TODO: modify the meaning of board/driver in the proc */
-   if (desc) {
-   write_calibration(dst, "[%s] \n",PLATFORM_STR);
-   write_calibration(dst, DRIVER_STR" = %s;\n", desc->board_name);
-   write_calibration(dst, BOARD_STR" = %s;\n", desc->driver_name);
-   }
-
-   write_calibration(dst, "\n[%s] \n", subd->name);
-   write_calibration(dst, INDEX_STR" = %d;\n", subd->idx);
-   list_for_each_entry_safe(e, t, l, node) {
-   j++;
-   }
-   write_calibration(dst, ELEMENTS_STR" = %d;\n", j);
-
-   j = 0;
-   list_for_each_entry_safe(e, t, l, node) {
-   write_calibration(dst, "[%s_%d] \n", subd->name, j);
-   write_calibration(dst, CHANNEL_STR" = %d;\n", e->chann

[Xenomai-git] Philippe Gerum : cobalt/posix/nsem: allow path lengths up to PATH_MAX

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 68cdffd721f751f2cf08123791d75d27cd7bc880
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=68cdffd721f751f2cf08123791d75d27cd7bc880

Author: Philippe Gerum 
Date:   Mon Oct 27 10:09:35 2014 +0100

cobalt/posix/nsem: allow path lengths up to PATH_MAX

As a consequence of this change, open/close/unlink ops move to low
stage handling.

---

 kernel/cobalt/posix/nsem.c  |   40 ++-
 kernel/cobalt/posix/sem.c   |   14 ++
 kernel/cobalt/posix/sem.h   |1 -
 kernel/cobalt/posix/syscall.c   |6 +++---
 kernel/cobalt/posix/syscall32.c |2 +-
 5 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/kernel/cobalt/posix/nsem.c b/kernel/cobalt/posix/nsem.c
index af0cd49..e0472f7 100644
--- a/kernel/cobalt/posix/nsem.c
+++ b/kernel/cobalt/posix/nsem.c
@@ -33,6 +33,7 @@ struct named_sem {
struct cobalt_sem_shadow __user *usem;
unsigned int refs;
struct xnid id;
+   struct filename *filename;
 };
 
 static struct named_sem *sem_search(struct cobalt_process *cc, xnhandle_t 
handle)
@@ -48,11 +49,12 @@ static struct named_sem *sem_search(struct cobalt_process 
*cc, xnhandle_t handle
 
 static struct cobalt_sem_shadow __user *
 sem_open(struct cobalt_process *cc, struct cobalt_sem_shadow __user *ushadow,
-const char *name, int oflags, mode_t mode, unsigned int value)
+struct filename *filename, int oflags, mode_t mode, unsigned int value)
 {
+   const char *name = filename->name;
struct cobalt_sem_shadow shadow;
-   struct cobalt_sem *sem;
struct named_sem *u, *v;
+   struct cobalt_sem *sem;
xnhandle_t handle;
spl_t s;
int rc;
@@ -126,6 +128,7 @@ sem_open(struct cobalt_process *cc, struct 
cobalt_sem_shadow __user *ushadow,
u->sem = sem;
u->usem = ushadow;
u->refs = 1;
+   u->filename = filename;
 
xnlock_get_irqsave(&named_sem_lock, s);
v = sem_search(cc, handle);
@@ -136,6 +139,7 @@ sem_open(struct cobalt_process *cc, struct 
cobalt_sem_shadow __user *ushadow,
--sem->refs;
xnlock_put_irqrestore(&nklock, s);
 
+   putname(filename);
xnfree(u);
u = v;
} else {
@@ -171,6 +175,7 @@ static int sem_close(struct cobalt_process *cc, xnhandle_t 
handle)
 
__cobalt_sem_destroy(handle);
 
+   putname(u->filename);
xnfree(u);
return 1;
 
@@ -201,16 +206,17 @@ __cobalt_sem_open(struct cobalt_sem_shadow __user *usm,
if (IS_ERR(filename))
return ERR_CAST(filename);
 
-   usm = sem_open(cc, usm, filename->name, oflags, mode, value);
-   if (IS_ERR(usm))
+   usm = sem_open(cc, usm, filename, oflags, mode, value);
+   if (IS_ERR(usm)) {
trace_cobalt_psem_open_failed(filename->name, oflags, mode,
  value, PTR_ERR(usm));
-   putname(filename);
+   putname(filename);
+   }
 
return usm;
 }
 
-COBALT_SYSCALL(sem_open, current,
+COBALT_SYSCALL(sem_open, lostage,
   int, (struct cobalt_sem_shadow __user *__user *u_addrp,
 const char __user *u_name,
 int oflags, mode_t mode, unsigned int value))
@@ -227,7 +233,7 @@ COBALT_SYSCALL(sem_open, current,
return __xn_put_user(usm, u_addrp) ? -EFAULT : 0;
 }
 
-COBALT_SYSCALL(sem_close, current,
+COBALT_SYSCALL(sem_close, lostage,
   int, (struct cobalt_sem_shadow __user *usm))
 {
struct cobalt_process *cc;
@@ -260,21 +266,21 @@ static inline int sem_unlink(const char *name)
return 0;
 }
 
-COBALT_SYSCALL(sem_unlink, current,
+COBALT_SYSCALL(sem_unlink, lostage,
   int, (const char __user *u_name))
 {
-   char name[COBALT_MAXNAME + 1];
-   long len;
+   struct filename *filename;
+   int ret;
 
-   len = __xn_safe_strncpy_from_user(name, u_name, sizeof(name));
-   if (len < 0)
-   return len;
-   if (len >= sizeof(name))
-   return -ENAMETOOLONG;
+   filename = getname(u_name);
+   if (IS_ERR(filename))
+   return PTR_ERR(filename);
 
-   trace_cobalt_psem_unlink(name);
+   trace_cobalt_psem_unlink(filename->name);
+   ret = sem_unlink(filename->name);
+   putname(filename);
 
-   return sem_unlink(name);
+   return ret;
 }
 
 static void cleanup_named_sems(void *cookie, struct xnid *i)
diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index 3555ab8..fb9f391 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -89,8 +89,6 @@ __cobalt_sem_init(const char *name, struct cobalt_sem_shadow 
*sm,
goto out;
}
 
-   ksformat(sem->name, sizeof(sem->name), "%s", name);
-
sys_ppd = cobalt_ppd_get(!!(flags & SEM_PSHARED));
state = cobalt_umm_alloc(

[Xenomai-git] Philippe Gerum : cobalt/autotune: fixup for 32bit emulation

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7ae93fc219c2a68317b5e21f7323820ddb20fa34
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7ae93fc219c2a68317b5e21f7323820ddb20fa34

Author: Philippe Gerum 
Date:   Wed Oct 22 10:10:04 2014 +0200

cobalt/autotune: fixup for 32bit emulation

---

 include/rtdm/uapi/autotune.h   |8 
 kernel/drivers/autotune/autotune.c |4 ++--
 utils/autotune/autotune.c  |8 
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/rtdm/uapi/autotune.h b/include/rtdm/uapi/autotune.h
index 4a75d72..225f2f8 100644
--- a/include/rtdm/uapi/autotune.h
+++ b/include/rtdm/uapi/autotune.h
@@ -24,15 +24,15 @@
 #define RTDM_SUBCLASS_AUTOTUNE 0
 
 struct autotune_setup {
-   int period;
-   int quiet;
+   __u32 period;
+   __u32 quiet;
 };
 
 #define AUTOTUNE_RTIOC_IRQ _IOW(RTDM_CLASS_AUTOTUNE, 0, struct 
autotune_setup)
 #define AUTOTUNE_RTIOC_KERN_IOW(RTDM_CLASS_AUTOTUNE, 1, struct 
autotune_setup)
 #define AUTOTUNE_RTIOC_USER_IOW(RTDM_CLASS_AUTOTUNE, 2, struct 
autotune_setup)
-#define AUTOTUNE_RTIOC_PULSE   _IOW(RTDM_CLASS_AUTOTUNE, 3, 
nanosecs_abs_t)
-#define AUTOTUNE_RTIOC_RUN _IOR(RTDM_CLASS_AUTOTUNE, 4, unsigned 
long)
+#define AUTOTUNE_RTIOC_PULSE   _IOW(RTDM_CLASS_AUTOTUNE, 3, __u64)
+#define AUTOTUNE_RTIOC_RUN _IOR(RTDM_CLASS_AUTOTUNE, 4, __u32)
 #define AUTOTUNE_RTIOC_RESET   _IO(RTDM_CLASS_AUTOTUNE, 5)
 
 #endif /* !_RTDM_UAPI_AUTOTUNE_H */
diff --git a/kernel/drivers/autotune/autotune.c 
b/kernel/drivers/autotune/autotune.c
index 34ba9d5..79608b3 100644
--- a/kernel/drivers/autotune/autotune.c
+++ b/kernel/drivers/autotune/autotune.c
@@ -675,8 +675,8 @@ static int autotune_ioctl_rt(struct rtdm_fd *fd, unsigned 
int request, void *arg
 {
struct autotune_context *context;
struct gravity_tuner *tuner;
-   nanosecs_abs_t timestamp;
-   unsigned int gravity;
+   __u64 timestamp;
+   __u32 gravity;
int ret;
 
context = rtdm_fd_to_private(fd);
diff --git a/utils/autotune/autotune.c b/utils/autotune/autotune.c
index 5a18310..fe2f621 100644
--- a/utils/autotune/autotune.c
+++ b/utils/autotune/autotune.c
@@ -87,8 +87,8 @@ static const struct option base_options[] = {
 
 static void *sampler_thread(void *arg)
 {
-   nanosecs_abs_t timestamp = 0;
int fd = (long)arg, ret, n = 0;
+   __u64 timestamp = 0;
struct timespec now;
 
for (;;) {
@@ -101,7 +101,7 @@ static void *sampler_thread(void *arg)
} else {
n++;
clock_gettime(CLOCK_MONOTONIC, &now);
-   timestamp = (nanosecs_abs_t)now.tv_sec * 10 + 
now.tv_nsec;
+   timestamp = (__u64)now.tv_sec * 10 + 
now.tv_nsec;
}
}
 
@@ -206,8 +206,8 @@ static void usage(void)
 static void run_tuner(int fd, int op, int period, const char *type)
 {
struct autotune_setup setup;
-   unsigned long gravity;
pthread_t sampler;
+   __u32 gravity;
int ret;
 
setup.period = period;
@@ -232,7 +232,7 @@ static void run_tuner(int fd, int op, int period, const 
char *type)
pthread_cancel(sampler);
 
if (!quiet)
-   printf("%lu ns\n", gravity);
+   printf("%u ns\n", gravity);
 }
 
 int main(int argc, char *const argv[])


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


[Xenomai-git] Philippe Gerum : cobalt/testsuite: fixup for 32bit emulation

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3759aa162c5359fc2c9e0d07590b157186ebe90f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3759aa162c5359fc2c9e0d07590b157186ebe90f

Author: Philippe Gerum 
Date:   Wed Oct 22 10:53:36 2014 +0200

cobalt/testsuite: fixup for 32bit emulation

---

 demo/alchemy/altency.c  |   44 ++--
 include/rtdm/uapi/autotune.h|2 +
 include/rtdm/uapi/testing.h |   78 ++-
 kernel/drivers/testing/switchtest.c |2 +-
 kernel/drivers/testing/timerbench.c |   28 ++---
 testsuite/latency/latency.c |   53 
 testsuite/switchtest/switchtest.c   |6 +--
 7 files changed, 90 insertions(+), 123 deletions(-)

diff --git a/demo/alchemy/altency.c b/demo/alchemy/altency.c
index ef1a694..2e4d093 100644
--- a/demo/alchemy/altency.c
+++ b/demo/alchemy/altency.c
@@ -25,9 +25,9 @@ RT_SEM display_sem;
 #define TEN_MILLIONS1000
 
 unsigned max_relaxed;
-long minjitter, maxjitter, avgjitter;
-long gminjitter = TEN_MILLIONS, gmaxjitter = -TEN_MILLIONS, goverrun = 0;
-long long gavgjitter = 0;
+int32_t minjitter, maxjitter, avgjitter;
+int32_t gminjitter = TEN_MILLIONS, gmaxjitter = -TEN_MILLIONS, goverrun = 0;
+int64_t gavgjitter = 0;
 
 long long period_ns = 0;
 int test_duration = 0; /* sec of testing, via -T , 0 is inf */
@@ -57,7 +57,7 @@ int test_loops = 0;   /* outer loop count */
 #define WARMUP_TIME 1
 #define HISTOGRAM_CELLS 300
 int histogram_size = HISTOGRAM_CELLS;
-long *histogram_avg = NULL, *histogram_max = NULL, *histogram_min = NULL;
+int32_t *histogram_avg = NULL, *histogram_max = NULL, *histogram_min = NULL;
 
 char *do_gnuplot = NULL;
 int do_histogram = 0, do_stats = 0, finished = 0;
@@ -65,10 +65,10 @@ int bucketsize = 1000;  /* default = 1000ns, -B 
 to override */
 
 #define need_histo() (do_histogram || do_stats || do_gnuplot)
 
-static inline void add_histogram(long *histogram, long addval)
+static inline void add_histogram(int32_t *histogram, int32_t addval)
 {
/* bucketsize steps */
-   long inabs = (addval >= 0 ? addval : -addval) / bucketsize;
+   int inabs = (addval >= 0 ? addval : -addval) / bucketsize;
histogram[inabs < histogram_size ? inabs : histogram_size - 1]++;
 }
 
@@ -77,7 +77,7 @@ static void latency(void *cookie)
RTIME expected_ns, start_ns, fault_threshold;
unsigned int old_relaxed = 0, new_relaxed;
int ret, count, nsamples, warmup = 1;
-   long minj, maxj, dt, overrun, sumj;
+   int32_t minj, maxj, dt, overrun, sumj;
unsigned long ov;
 
fault_threshold = CONFIG_XENO_DEFAULT_PERIOD;
@@ -100,7 +100,7 @@ static void latency(void *cookie)
 
for (count = sumj = 0; count < nsamples; count++) {
ret = rt_task_wait_period(&ov);
-   dt = (long)(rt_timer_read() - expected_ns);
+   dt = (int32_t)(rt_timer_read() - expected_ns);
new_relaxed = sampling_relaxed;
if (dt > maxj) {
if (new_relaxed != old_relaxed
@@ -213,7 +213,7 @@ static void display(void *cookie)
test_duration);
 
for (;;) {
-   long minj, gminj, maxj, gmaxj, avgj;
+   int32_t minj, gminj, maxj, gmaxj, avgj;
 
if (test_mode == USER_TASK) {
ret = rt_sem_p(&display_sem, TM_INFINITE);
@@ -268,7 +268,7 @@ static void display(void *cookie)
   "lat max", "-overrun", "---msw",
   "---lat best", "--lat worst");
}
-   
printf("RTD|%11.3f|%11.3f|%11.3f|%8ld|%6u|%11.3f|%11.3f\n",
+   
printf("RTD|%11.3f|%11.3f|%11.3f|%8d|%6u|%11.3f|%11.3f\n",
   (double)minj / 1000,
   (double)avgj / 1000,
   (double)maxj / 1000,
@@ -279,7 +279,7 @@ static void display(void *cookie)
}
 }
 
-static double dump_histogram(long *histogram, char *kind)
+static double dump_histogram(int32_t *histogram, char *kind)
 {
int n, total_hits = 0;
double avg = 0; /* used to sum hits 1st */
@@ -288,13 +288,13 @@ static double dump_histogram(long *histogram, char *kind)
printf("---|--param|range-|--samples\n");
 
for (n = 0; n < histogram_size; n++) {
-   long hits = histogram[n];
+   int32_t hits = histogram[n];
 
if (hits) {
total_hits += hits;
avg += n * hits;
if (do_histogram)
-   printf("HSD|%s| %3d -%3d | %8ld\n",
+   printf("HSD|%s| %3d -%3d | %8d\n",
   kind, n, n + 1, hit

[Xenomai-git] Philippe Gerum : smokey/sched-tp: force affinity on the test CPU

2014-10-27 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: b32d11169db844a7770a599b73d66145af069e2f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b32d11169db844a7770a599b73d66145af069e2f

Author: Philippe Gerum 
Date:   Mon Oct 27 08:57:27 2014 +0100

smokey/sched-tp: force affinity on the test CPU

---

 testsuite/smokey/sched-tp/sched-tp.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/testsuite/smokey/sched-tp/sched-tp.c 
b/testsuite/smokey/sched-tp/sched-tp.c
index ee6a07f..b946c85 100644
--- a/testsuite/smokey/sched-tp/sched-tp.c
+++ b/testsuite/smokey/sched-tp/sched-tp.c
@@ -37,8 +37,15 @@ static void *thread_body(void *arg)
pthread_t me = pthread_self();
struct sched_param_ex param;
struct timespec ts;
+   cpu_set_t affinity;
int ret, part;
 
+   CPU_ZERO(&affinity);
+   CPU_SET(0, &affinity);
+   ret = sched_setaffinity(0, sizeof(affinity), &affinity);
+   if (ret)
+   error(1, errno, "sched_setaffinity");
+
part = (int)(long)arg;
param.sched_priority = 50 - part;
param.sched_tp_partition = part;


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