From 9756485f5ab7ba8822d6b357634c0dada12c3bc4 Mon Sep 17 00:00:00 2001 From: Thierry Zamofing Date: Fri, 6 Jan 2017 17:29:40 +0100 Subject: [PATCH] try to build user servo loop --- Readme.md | 2 +- python/shapepath.py | 44 +-- usrServo/Makefile | 93 ++++++ usrServo/Makefile.old | 47 +++ usrServo/Makefileso.mak | 231 ++++++++++++++ usrServo/Readme.md | 154 +++++++++ usrServo/pp_proj.h | 295 ++++++++++++++++++ usrServo/sampleKernelModule/Makefile.Deltatau | 94 ++++++ usrServo/sampleKernelModule/Makefile.Ubuntu | 8 + usrServo/sampleKernelModule/hello.c | 21 ++ usrServo/usralgo.mod.c | 21 ++ usrServo/usralgomain.c | 114 +++++++ usrServo/usrcode.c | 109 +++++++ usrServo/usrcode.h | 132 ++++++++ 14 files changed, 1342 insertions(+), 23 deletions(-) create mode 100644 usrServo/Makefile create mode 100644 usrServo/Makefile.old create mode 100644 usrServo/Makefileso.mak create mode 100644 usrServo/Readme.md create mode 100644 usrServo/pp_proj.h create mode 100644 usrServo/sampleKernelModule/Makefile.Deltatau create mode 100644 usrServo/sampleKernelModule/Makefile.Ubuntu create mode 100644 usrServo/sampleKernelModule/hello.c create mode 100644 usrServo/usralgo.mod.c create mode 100644 usrServo/usralgomain.c create mode 100644 usrServo/usrcode.c create mode 100644 usrServo/usrcode.h diff --git a/Readme.md b/Readme.md index 9eb2d91..ed02393 100644 --- a/Readme.md +++ b/Readme.md @@ -72,7 +72,7 @@ Testing ServoFrq. Testing linear,pvt,spline moves ------------------------------- -Tested with shapepath.py: +Tested with shapepath.py: THE BEST TRAJECTORY RESULT IST WITH PVT MOTION diff --git a/python/shapepath.py b/python/shapepath.py index 19184e7..3d4714c 100755 --- a/python/shapepath.py +++ b/python/shapepath.py @@ -22,8 +22,8 @@ verbose bits: "sequencer":[ 'gen_grid_points(w=10,h=10,pitch=100,rnd=.2)', 'sort_points()', - 'gen_prog(file="/tmp/shapepath.prg")', - 'plot_gather()'] + 'gen_prog(file="'+fn+'.prg")', + 'plot_gather("'+fn+'.npz")'] } Sequencer functions are: @@ -44,7 +44,7 @@ Sequencer functions are: - plot gathered data - plot_gather() + plot_gather("'+fn+'.npz") this makes only sence, if motion has been executed and data can be gathered from the powerbrick Acquired time is:MaxSamples*Period*.2 @@ -66,27 +66,27 @@ class ShapePath: cfg=json.loads(s, object_hook=ConvUtf8) s=json.dumps(cfg, indent=2, separators=(',', ': '));print s else: - #cfg={"points": [[100,523],[635,632],[756,213]],"sequencer":['sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871")','plot_gather()']} - #cfg={"sequencer":['gen_rand_points(n=107, scale=1000)','sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871")','plot_gather()']} - #cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=.2)','sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871")','plot_gather()']} - #cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=0.2)','sort_points()','gen_prog(file="/tmp/shapepath.prg")','plot_gather()']} - #cfg = {"sequencer": ['gen_rand_points(n=107, scale=1000)', 'sort_points()','plot_gather()']} - #cfg={"sequencer":['gen_grid_points(w=20,h=20,pitch=50,rnd=.2)','sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871")','plot_gather()']} - #cfg={"sequencer":['gen_grid_points(w=20,h=20,pitch=50,rnd=.2)','sort_points()','gen_prog(file="/tmp/shapepath.prg")','plot_gather()']} + fn='/tmp/shapepath' #fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/'+time.strftime('%y-%m-%d-%H_%M_%S') + #cfg={"points": [[100,523],[635,632],[756,213]],"sequencer":['sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871")','plot_gather("'+fn+'.npz")']} + #cfg={"sequencer":['gen_rand_points(n=107, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871")','plot_gather("'+fn+'.npz")']} + #cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=.2)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871")','plot_gather("'+fn+'.npz")']} + #cfg={"sequencer":['gen_grid_points(w=10,h=10,pitch=100,rnd=0.2)','sort_points()','gen_prog(file="'+fn+'.prg")','plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_rand_points(n=107, scale=1000)', 'sort_points()','plot_gather("'+fn+'.npz")']} + #cfg={"sequencer":['gen_grid_points(w=20,h=20,pitch=50,rnd=.2)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871")','plot_gather("'+fn+'.npz")']} + #cfg={"sequencer":['gen_grid_points(w=20,h=20,pitch=50,rnd=.2)','sort_points()','gen_prog(file="'+fn+'.prg")','plot_gather("'+fn+'.npz")']} #cfg={"sequencer":['gen_rand_points(n=400, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871")','plot_gather("'+fn+'.npz")']} - #cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=50,rnd=.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=50,rnd=.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=100,rnd=0)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather()']} - #cfg = {"points": [[0, 0],[100, 0],[200, 0],[300, 0],[400, 0],[400, 100],[300, 100],[200, 100],[100, 100],[0, 100],[10, 200],[100, 200],[200, 200],[300, 200],[400, 200],[410, 300],[300, 300],[200, 300],[100, 300],[0, 300],[0, 400],[100, 400],[200, 400],[300, 400],[400, 400]],"sequencer": ['gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=-1)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=1000)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_rand_points(n=400, scale=1000)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather()']} - #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="/tmp/shapepath.prg",host="SAROP11-CPPM-MOT6871",mode=2,pt2pt_time=10)', 'plot_gather()']} - fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/mode2' - cfg = {"sequencer":['gen_rand_points(n=400, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=2,pt2pt_time=10)','plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=50,rnd=.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=50,rnd=.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=1)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=100,rnd=0)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"points": [[0, 0],[100, 0],[200, 0],[300, 0],[400, 0],[400, 100],[300, 100],[200, 100],[100, 100],[0, 100],[10, 200],[100, 200],[200, 200],[300, 200],[400, 200],[410, 300],[300, 300],[200, 300],[100, 300],[0, 300],[0, 400],[100, 400],[200, 400],[300, 400],[400, 400]],"sequencer": ['gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=0)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=-1)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=2,h=2,pitch=10000,rnd=0)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=1000)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=20,h=20,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_rand_points(n=400, scale=1000)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=10)', 'plot_gather("'+fn+'.npz")']} + #cfg = {"sequencer": ['gen_grid_points(w=5,h=5,pitch=100,rnd=0.2)', 'sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=2,pt2pt_time=10)', 'plot_gather("'+fn+'.npz")']} + cfg = {"sequencer":['gen_rand_points(n=400, scale=1000)','sort_points()','gen_prog(file="'+fn+'.prg",host="SAROP11-CPPM-MOT6871",mode=1,pt2pt_time=100)','plot_gather("'+fn+'.npz")']} self.cfg=dotdict(cfg) self.args=args diff --git a/usrServo/Makefile b/usrServo/Makefile new file mode 100644 index 0000000..fb1de9c --- /dev/null +++ b/usrServo/Makefile @@ -0,0 +1,93 @@ +#------------------------------------------------------------------------------ +# Copyright (C) Delta Tau Data Systems Inc., 2007 +# All rights reserved. +# +# Generic makefile for any c realtime C plc 0, user servo or user phase +# For a new project change the following +# +# 1.) usralgo-objs should be assigned the 'C' source code files that need to be compiled +# 2.) issue the command 'make depend' the first time a project is created and +# (every time an additional 'C' file is added to the project the command +# 'make depend' must be issued) +# 3.) issue the command make clean +# 4.) issue the command make +# +# Notes +# -------- +# Change DTDEBUG above to -O2 for release w/ optimization +# Change DTDEBUG above to -g3 for debug +# arm,i386,i385hv,ppc460-2,ppc460-1,ppc405 +#------------------------------------------------------------------------------ + +PMAC_ARCH=ppc465-2 + +ifeq ($(PMAC_ARCH),ppc465-2) +ARCH=powerpc +#CROSS_COMPILE=powerpc-meau-linux-gnu- +CROSS_COMPILE=/opt/eldk-4.2/usr/bin/ppc_4xxFP- +KDIR=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +KSRC=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +#CC=powerpc-meau-linux-gnu-gcc +#AS=powerpc-meau-linux-gnu-as +#LD=powerpc-meau-linux-gnu-gcc +CC=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc +AS=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc +LD=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc +#STRIP=i686-meau-linux-gnu-strip +INCLUDE=/opt/powerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include +XENOMAI_INC_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include +XENOMAI_LIB_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/lib +RPATH=-Wl,-rpath-link,/opt/powerpc-465-rootfs/lib/powerpc-linux-gnu +ROOTFS_DIR=/opt/powerpc-465-rootfs +endif + +#RTPMACINCLUDEDIR=/usr/local/dtlibs/rtpmac +#LIBPPMACINCLUDEDIR=/usr/local/dtlibs/libppmac +#THESE PATHS MUST BE ABSOLUTE ! +RTPMACINCLUDEDIR=/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo/ppmac/rtpmac/ +LIBPPMACINCLUDEDIR=/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo/ppmac/libppmac/ + +export ARCH +export CROSS_COMPILE + +OBJS := ${patsubst %, %.o, $(MODULES)} +CLEANMOD := ${patsubst %, .%*, $(MODULES)} +PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) + + +obj-m += usralgo.o +usralgo-objs := usralgomain.o \ +usrcode.o + +LDFLAGS := -nostdlib +EXTRA_CFLAGS := -O2 -DCONFIG_460EX -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -mhard-float -I$(RTPMACINCLUDEDIR) -I$(LIBPPMACINCLUDEDIR) -I$(XENOMAI_INC_DIR) -I$(XENOMAI_INC_DIR)/posix -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/posix -I$(INCLUDE) $(ADD_CFLAGS) --sysroot=$(ROOTFS_DIR) +KBUILD_EXTRA_SYMBOLS := /usr/local/dtlibs/libppmac/Module.symvers + +%.o: %.S + $(CC) -s -D__KERNEL__ -x c -E $< -o $*.i + $(AS) -mbooke -o $@ $*.i + +#all:: +# cp -f /usr/local/usralgo/usralgomain.c $(PWD) +all: +# $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules + $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules V=1 +# mv -f usralgo.ko ../../bin/Debug/ + +#modules: +# @echo "$(CFLAGS)" + +bclean:: + $(RM) *.o .*.o.d .*.o.cmd *.ko *.log + $(RM) -R .tmp* + $(RM) .runinfo + rm -rf .runinfo .tmp* .*.o.d .*.o.cmd .*.cmd *.o *.ko *.mod.c *.i *.so Module.symvers modules.order + +clean:: + $(RM) *.o .*.o.d .*.o.cmd *.ko + $(RM) -R .tmp* + $(RM) .runinfo + rm -rf .runinfo .tmp* .*.o.d .*.o.cmd .*.cmd *.o *.ko *.mod.c *.i *.so Module.symvers modules.order + +dbg: + @echo PATH $(PATH) \ No newline at end of file diff --git a/usrServo/Makefile.old b/usrServo/Makefile.old new file mode 100644 index 0000000..c158bdf --- /dev/null +++ b/usrServo/Makefile.old @@ -0,0 +1,47 @@ + +LIB='-L/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/opt/ppmac/libppmac -lppmac -L/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/usr/local/xenomai-2.6.2.1/lib -lxenomai -lpthread_rt -lpthread -lrt -ldl' + +#/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc -g main.o $LIB -o main +# +CC=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc + +HOST=SAROP11-CPPM-MOT6871 + +ppmac: + scp -r root@$(HOST):/opt/ppmac . +xenomai: + scp -r root@$(HOST):/usr/local/xenomai/lib xenomai +lib: + scp -r root@$(HOST):/usr/lib . + +powerpc-465-rootfs: + tar -xvf powerpc-465-rootfs.tar.gz + +prerequisites: ppmac xenomai lib + +usralgo.ko: usralgo.mod.o usralgo.o usrcode.o + powerpc-meau-linux-gnu-gcc -r -nostdlib -T /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/scripts/module-common.lds arch/powerpc/lib/crtsavres.o -o /REALTI~1/usralgo.ko /REALTI~1/usralgo.o /REALTI~1/usralgo.mod.o + +usralgo.mod.o: + powerpc-meau-linux-gnu-gcc -Wp,-MD,/REALTI~1/.usralgo.mod.o.d -nostdinc -isystem /usr/local/lib/gcc/powerpc-meau-linux-gnu/4.6.4/include -I/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/arch/powerpc/include -Iarch/powerpc/include/generated -Iinclude -include /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/linux/kconfig.h -D__KERNEL__ -Iarch/powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -msoft-float -pipe -Iarch/powerpc -ffixed-r2 -mmultiple -mno-altivec -mno-spe -mspe=no -funit-at-a-time -fno-dwarf2-cfi-asm -mno-string -Wa,-m405 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -O2 -DCONFIG_460EX -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -mhard-float -I/usr/local/dtlibs/rtpmac -I/usr/local/dtlibs/libppmac -I/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include -I/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include/posix -I/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/xenomai -I/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/xenomai/posix -I/opt/powerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include --sysroot=/opt/powerpc-465-rootfs -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(usralgo.mod)" -D"KBUILD_MODNAME=KBUILD_STR(usralgo)" -DMODULE -c -o /REALTI~1/usralgo.mod.o /REALTI~1/usralgo.mod.c + +usralgo.o: + powerpc-meau-linux-gnu-gcc -nostdlib -r -o /REALTI~1/usralgo.o /REALTI~1/usralgomain.o /REALTI~1/usrcode.o + +usrcode.o: powerpc-465-rootfs + $(CC) -nostdinc \ + -Ipowerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/arch/powerpc/include \ + -Ipowerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include \ + -include powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/linux/kconfig.h \ + -D__KERNEL__ -Iarch/powerpc \ + -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -msoft-float -pipe -Iarch/powerpc -ffixed-r2 -mmultiple -mno-altivec -mno-spe -mspe=no -funit-at-a-time -mno-string -Wa,-m405 -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow \ + -DCC_HAVE_ASM_GOTO -O2 -DCONFIG_460EX -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -mhard-float \ + -Ippmac/rtpmac -Ippmac/libppmac\ + -Ipowerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include -Ipowerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include/posix -Ipowerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/xenomai -Ipowerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/xenomai/posix -Ipowerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include \ + --sysroot=powerpc-465-rootfs -DMODULE -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(usrcode)" -D"KBUILD_MODNAME=KBUILD_STR(usralgo)" \ + -c -o usrcode.o usrcode.c +# powerpc-meau-linux-gnu-gcc -Wp,-MD,/REALTI~1/.usrcode.o.d -nostdinc -isystem /usr/local/lib/gcc/powerpc-meau-linux-gnu/4.6.4/include -I/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/arch/powerpc/include -Iarch/powerpc/include/generated -Iinclude -include /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/linux/kconfig.h -D__KERNEL__ -Iarch/powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -msoft-float -pipe -Iarch/powerpc -ffixed-r2 -mmultiple -mno-altivec -mno-spe -mspe=no -funit-at-a-time -fno-dwarf2-cfi-asm -mno-string -Wa,-m405 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -O2 -DCONFIG_460EX -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -mhard-float -I/usr/local/dtlibs/rtpmac -I/usr/local/dtlibs/libppmac -I/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include -I/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include/posix -I/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/xenomai -I/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/include/xenomai/posix -I/opt/powerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include --sysroot=/opt/powerpc-465-rootfs -DMODULE -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(usrcode)" -D"KBUILD_MODNAME=KBUILD_STR(usralgo)" -c -o /REALTI~1/usrcode.o /REALTI~1/usrcode.c + +debug: + echo CC: $(CC) + echo CPP: $(CPP) diff --git a/usrServo/Makefileso.mak b/usrServo/Makefileso.mak new file mode 100644 index 0000000..3f50ae3 --- /dev/null +++ b/usrServo/Makefileso.mak @@ -0,0 +1,231 @@ +#------------------------------------------------------------------------------ +# Copyright (C) Delta Tau Data Systems Inc., 2007 +# All rights reserved. +# +# Generic makefile for any c user mode plc +# For a new project change the following +# +# 1.) PROG should be assigned the name of the desired executable program +# 2.) SRCS should be assigned the 'C' source code files that need to be compiled +# 3.) issue the command 'make depend' the first time a project is created and +# (every time an additional 'C' file is added to the project the command +# 'make depend' must be issued) +# 4.) issue the command make clean +# 5.) issue the command make +# +# Notes +# -------- +# Change DTDEBUG above to -O2 for release w/ optimization +# Change DTDEBUG above to -g3 for debug +# PMAC_ARCH value can be one of the following +# arm,i386,i385hv,ppc460-2,ppc460-1,ppc405 +#------------------------------------------------------------------------------ + +PMAC_ARCH=ppc465-2 + +ifeq ($(PMAC_ARCH),arm) +ARCH=arm +CROSS_COMPILE=arm-omron-linux-gnueabihf- +KDIR=/opt/arm-rootfs/usr/src/linux-3.14.28 +KSRC=/opt/arm-rootfs/usr/src/linux-3.14.28 +CC=arm-omron-linux-gnueabihf-gcc +AS=arm-omron-linux-gnueabihf-as +LD=arm-omron-linux-gnueabihf-gcc +INCLUDE=/opt/arm-rootfs/usr/lib/gcc/arm-linux-gnueabihf/4.6/include +XENOMAI_INC_DIR=/opt/arm-rootfs/usr/xenomai/include +XENOMAI_LIB_DIR=/opt/arm-rootfs/usr/xenomai/lib +LIBMATHDIR=/usr/local/dtlibs/libmath +RPATH=-Wl,-rpath-link,/opt/arm-rootfs/lib/arm-linux-gnueabihf +LIBMATH_RPATH=-Wl,-rpath,/opt/ppmac/libmath +ROOTFS_DIR=/opt/arm-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lpthread_rt -lm -lmath -L$(LIBMATHDIR) +endif + +ifeq ($(PMAC_ARCH),arm-usermode) +ARCH=arm +CROSS_COMPILE=arm-omron-linux-gnueabihf- +KDIR=/opt/arm-rootfs/usr/src/linux-3.14.28 +KSRC=/opt/arm-rootfs/usr/src/linux-3.14.28 +CC=arm-omron-linux-gnueabihf-gcc +AS=arm-omron-linux-gnueabihf-as +LD=arm-omron-linux-gnueabihf-gcc +INCLUDE=/opt/arm-rootfs/usr/lib/gcc/arm-linux-gnueabihf/4.6/include +#XENOMAI_INC_DIR=/opt/arm-rootfs/usr/xenomai/include +XENOMAI_LIB_DIR=/opt/arm-rootfs/usr/xenomai/lib +#LIBMATHDIR=/usr/local/dtlibs/libmath +RPATH=-Wl,-rpath-link,/opt/arm-rootfs/lib/arm-linux-gnueabihf +#LIBMATH_RPATH=-Wl,-rpath,/opt/ppmac/libmath +ROOTFS_DIR=/opt/arm-rootfs +LIBS= -shared -lrt -lppmac -lm -lpthread_rt -lxenomai +endif + +ifeq ($(PMAC_ARCH),i386) +ARCH=i386 +CROSS_COMPILE=i686-meau-linux-gnu- +KDIR=/opt/i386-linux-rootfs/usr/src/linux-headers-3.14.28-xenomai-2.6.4 +KSRC=/opt/i386-linux-rootfs/usr/src/linux-headers-3.14.28-xenomai-2.6.4 +CC=i686-meau-linux-gnu-gcc +AS=i686-meau-linux-gnu-as +LD=i686-meau-linux-gnu-gcc +INCLUDE=/opt/i386-linux-rootfs/usr/lib/gcc/i686-linux-gnu/4.6/include +XENOMAI_INC_DIR=/opt/i386-linux-rootfs/usr/include/xenomai +XENOMAI_LIB_DIR=/opt/i386-linux-rootfs/usr/lib +LIBMATHDIR=/usr/local/dtlibs/libmath +RPATH=-Wl,-rpath-link,/opt/i386-linux-rootfs/lib/i386-linux-gnu +LIBMATH_RPATH=-Wl,-rpath,/opt/ppmac/libmath +ROOTFS_DIR=/opt/i386-linux-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lpthread_rt -lm -lmath -L$(LIBMATHDIR) +endif + +ifeq ($(PMAC_ARCH),i386-usermode) +ARCH=i386 +CROSS_COMPILE=i686-meau-linux-gnu- +KDIR=/opt/i386-linux-rootfs/usr/src/linux-headers-3.14.28-xenomai-2.6.4 +KSRC=/opt/i386-linux-rootfs/usr/src/linux-headers-3.14.28-xenomai-2.6.4 +CC=i686-meau-linux-gnu-gcc +AS=i686-meau-linux-gnu-as +LD=i686-meau-linux-gnu-gcc +INCLUDE=/opt/i386-linux-rootfs/usr/lib/gcc/i686-linux-gnu/4.6/include +XENOMAI_INC_DIR=/opt/i386-linux-rootfs/usr/include/xenomai +XENOMAI_LIB_DIR=/opt/i386-linux-rootfs/usr/lib +#LIBMATHDIR=/usr/local/dtlibs/libmath +RPATH=-Wl,-rpath-link,/opt/i386-linux-rootfs/lib/i386-linux-gnu +#LIBMATH_RPATH=-Wl,-rpath,/opt/ppmac/libmath +ROOTFS_DIR=/opt/i386-linux-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lpthread_rt -lm +endif + +ifeq ($(PMAC_ARCH),i386hv) +ARCH=i386 +CROSS_COMPILE=i686-meau-linux-gnu- +KDIR=/opt/i386-preemptrt-rootfs/usr/src/linux-3.8.13 +KSRC=/opt/i386-preemptrt-rootfs/usr/src/linux-3.8.13 +CC=i686-meau-linux-gnu-gcc +AS=i686-meau-linux-gnu-as +LD=i686-meau-linux-gnu-gcc +INCLUDE=/opt/i386-preemptrt-rootfs/usr/lib/gcc/i686-redhat-linux/4.4.4/include +#XENOMAI_INC_DIR=/opt/i386-linux-rootfs/usr/include/xenomai +XENOMAI_LIB_DIR=/opt/i386-preemptrt-rootfs/lib +LIBMATHDIR=/usr/local/dtlibs/libmath +LIBMATH_RPATH=-Wl,-rpath,/opt/ppmac/libmath +ROOTFS_DIR=/opt/i386-preemptrt-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lmath -L$(LIBMATHDIR) +endif + +ifeq ($(PMAC_ARCH),i386hv-usermode) +ARCH=i386 +CROSS_COMPILE=i686-meau-linux-gnu- +KDIR=/opt/i386-preemptrt-rootfs/usr/src/linux-3.8.13 +KSRC=/opt/i386-preemptrt-rootfs/usr/src/linux-3.8.13 +CC=i686-meau-linux-gnu-gcc +AS=i686-meau-linux-gnu-as +LD=i686-meau-linux-gnu-gcc +INCLUDE=/opt/i386-preemptrt-rootfs/usr/lib/gcc/i686-redhat-linux/4.4.4/include +#XENOMAI_INC_DIR=/opt/i386-linux-rootfs/usr/include/xenomai +XENOMAI_LIB_DIR=/opt/i386-preemptrt-rootfs/lib +#LIBMATHDIR=/usr/local/dtlibs/libmath +#LIBMATH_RPATH=-Wl,-rpath,/opt/ppmac/libmath +ROOTFS_DIR=/opt/i386-preemptrt-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lm +endif + +ifeq ($(PMAC_ARCH),ppc465-2) +ARCH=powerpc +CROSS_COMPILE=powerpc-meau-linux-gnu- +KDIR=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +KSRC=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +CC=powerpc-meau-linux-gnu-gcc +AS=powerpc-meau-linux-gnu-as +LD=powerpc-meau-linux-gnu-gcc +#STRIP=i686-meau-linux-gnu-strip +INCLUDE=/opt/powerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include +XENOMAI_INC_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include +XENOMAI_LIB_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/lib +RPATH=-Wl,-rpath-link,/opt/powerpc-465-rootfs/lib/powerpc-linux-gnu +ROOTFS_DIR=/opt/powerpc-465-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lpthread_rt -lm +endif + +ifeq ($(PMAC_ARCH),ppc465-1) +ARCH=powerpc +CROSS_COMPILE=powerpc-meau-linux-gnu- +KDIR=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +KSRC=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +CC=powerpc-meau-linux-gnu-gcc +AS=powerpc-meau-linux-gnu-as +LD=powerpc-meau-linux-gnu-gcc +#STRIP=i686-meau-linux-gnu-strip +INCLUDE=/opt/powerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include +XENOMAI_INC_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include +XENOMAI_LIB_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/lib +RPATH=-Wl,-rpath-link,/opt/powerpc-465-rootfs/lib/powerpc-linux-gnu +ROOTFS_DIR=/opt/powerpc-465-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lpthread_rt -lm +endif + +ifeq ($(PMAC_ARCH),ppc405) +ARCH=powerpc +CROSS_COMPILE=powerpc-405-linux-gnu- +KDIR=/opt/powerpc-405-rootfs/usr/src/linux-2.6.30.3-xeno-2.5.6 +KSRC=/opt/powerpc-405-rootfs/usr/src/linux-2.6.30.3-xeno-2.5.6 +CC=powerpc-405-linux-gnu-gcc +AS=powerpc-405-linux-gnu-as +LD=powerpc-405-linux-gnu-gcc +INCLUDE=/usr/local/powerpc-405-linux-gnu/include +XENOMAI_INC_DIR=/opt/powerpc-405-rootfs/usr/local/xenomai-2.5.6/include +XENOMAI_LIB_DIR=/opt/powerpc-405-rootfs/usr/local/xenomai-2.5.6/lib +LIB_DIR=/opt/powerpc-405-rootfs/lib +ROOTFS_DIR=/opt/powerpc-405-rootfs +LIBS= -shared -lrt -lpthread -lppmac -lpthread_rt -lm -L$(LIB_DIR) +endif + +RTPMACINCLUDEDIR=/usr/local/dtlibs/rtpmac +LIBPPMACINCLUDEDIR=/usr/local/dtlibs/libppmac +export ARCH +export CROSS_COMPILE + +CFLAGS = -mhard-float -funsigned-char --sysroot=$(ROOTFS_DIR) \ +-I$(RTPMACINCLUDEDIR) -I$(LIBPPMACINCLUDEDIR) -I$(XENOMAI_INC_DIR) -I$(XENOMAI_INC_DIR)/posix -I$(LIBMATHDIR) \ +-D_GNU_SOURCE -D_REENTRANT -D__XENO__ -fPIC +DTDEBUG = -g3 + +LDFLAGS = $(LIBS) --sysroot=$(ROOTFS_DIR) \ + \ +-L../../Bin/Debug/ \ +-L$(XENOMAI_LIB_DIR) -L$(LIBPPMACINCLUDEDIR) \ +-Wl,-rpath,/var/ftp/usrflash/Project/C\ Language/Libraries \ +-Wl,-rpath,/var/ftp/usrflash/Project/Bin/Debug \ +-Wl,-rpath,/opt/ppmac/libppmac \ +-Wl,-z,defs \ +$(LIBMATH_RPATH) \ +$(RPATH) + +RM = rm -f +PROG = ../../Bin/Debug/usralgo.so +SRCS = \ +usrcode.c + +OBJS = $(SRCS:.c=.o) + +# now comes a meta-rule for compiling any C source file. +$(PROG): $(OBJS) + $(LD) -o $(PROG) $(OBJS) $(LDFLAGS) + +%.o: %.c clean + $(CC) $(CFLAGS) $(DTDEBUG) -c $< + + +bclean: + $(RM) $(PROG) $(OBJS) *.log + +clean: + $(RM) $(PROG) $(OBJS) + +depend: + $(RM) ../../Bin/Debug/dependencyko.lst + makedepend -f- -- $(CFLAGS) -- $(SRCS) > ../Bin/Debug/dependencyko.lst + +#ifneq ($(MAKECMDGOALS),depend) +#include ../Bin/Debug/dependencyko.lst +#endif + diff --git a/usrServo/Readme.md b/usrServo/Readme.md new file mode 100644 index 0000000..bb5125f --- /dev/null +++ b/usrServo/Readme.md @@ -0,0 +1,154 @@ + scp -r root@SAROP11-CPPM-MOT6871:/opt/ppmac . + scp -r root@SAROP11-CPPM-MOT6871:/usr/local/xenomai/lib xenomai + scp -r root@SAROP11-CPPM-MOT6871:/usr/lib . + +LIB='-L ppmac/libppmac/ -Lxenomai -lppmac -lxenomai -lpthread_rt -lpthread -lrt -ldl' +LIB='-L/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/opt/ppmac/libppmac -lppmac -L/opt/eldk-4.2/PPMAC_rootfs-7-wheezy/usr/local/xenomai-2.6.2.1/lib -lxenomai -lpthread_rt -lpthread -lrt -ldl' + + /opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc -g main.o $LIB -o main + + +export LD_LIBRARY_PATH=/opt/ppmac/libppmac/ + + +Motor[4].Ctrl=Sys.ServoCtrl +Motor[4].Ctrl=UserAlgo.ServoCtrlAddr[0] + +UserAlgo.ServoCtrlAddr[0]=$.... + +Motor[4].IpbGain=2.9192927 + + +UserAlgo.ServoCtrlAddr[4]=$a1108068 + + +usrflash/Project/Bin/Debug/usralgo.so +usrflash/Project/Bin/Debug/usralgo.ko + + +Helpfull Deltatau lines +----------------------- + +cat /opt/ppmac/projpp/projpp_help.txt +root@:/# projpp -l + +$$$*** +!common() +!mx-stage() +#4$ +#4j/ +#4k + +Start IDE +New Project, PowerBrick_LV +makefile and output at: +C:\Documents and Settings\user\Desktop\scratch\PowerBrick_LVUserServoLoop\PowerBrick_LVUserServoLoop\C Language\Realtime Routines + +Update Firmware +--------------- + +we are using: 2.0.2.14, IDE wants newer, probably 2.1.1.3 (http://forums.deltatau.com/filedepot/) +With IDE the new firmware can be installed (tools->...->download firmware) + + + +User Servo Loop +--------------- + +build usralgo.ko (or copy from IDE after build) + +rmmod usralgo + +insmod /mypath/usralgo.ko (e.g. insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko) + +cat /proc/kallsyms | grep MyUserAlgoFunctionName (e.g. cat /proc/kallsyms | grep user_pid_ctrl) + a47e448b r __kstrtab_user_pid_ctrl [usralgo] + a47e4458 r __ksymtab_user_pid_ctrl [usralgo] + a47e4068 T user_pid_ctrl [usralgo] + + +UserAlgo.ServoCtrlAddr[4] = $a47e4068 +Motor[4].Ctrl =UserAlgo.ServoCtrlAddr[4].a + +build usralgo.ko +---------------- +The sources are from C:\Documents and Settings\user\Desktop\scratch\PowerBrick_LVUserServoLoop\PowerBrick_LVUserServoLoop\C Language\Realtime Routines +The Makefile was build with informations from the .../Realtime Routines/.usralgo.o.cmd etc. files + +rootfs files are on the powerbrick or in C:\DeltaTau\Power PMAC IDE\compilers\opt -> powerpc-465-rootfs.tar.gz +On the powerbrick the kernel sources are not installed -> therefore the rootfs from the IDE is needed + + +Make usralgo.ko + + + + +Sample Kernel Module +-------------------- + +http://www.thegeekstuff.com/2013/07/write-linux-kernel-module/ +https://linux.die.net/lkmpg/x121.html + +Do a module on Ubuntu works. + -> path usrServo/sampleKernelModul + ln -sfT Makefile.Ubuntu Makefile + make clean + make + dmesg + insmod /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo/sampleKernelModule/hello.ko + rmmod hello.ko + dmesg + +Try to do a module for PowerBrick: + uncompress powerpc-465-rootfs.tar.gz (from PMAC IDE) to /opt -> /opt/powerpc-465-rootfs/usr/include/ etc. + compile fixdep, modpost + cd /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/scripts/basic + gcc fixdep.c -o fixdep + cd /opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp/scripts/mod + gcc modpost.c file2alias.c sumversion.c -o modpost + ln -sfT Makefile.Deltatau Makefile + make clean + make + scp hello.ko root@SAROP11-CPPM-MOT6871:/tmp + + + +Build test the Servo kernel module +---------------------------------- +cd /home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/usrServo +make clean +make + scp usralgo.ko root@SAROP11-CPPM-MOT6871:/tmp + +build usralgo.ko (or copy from IDE after build) + +******** UP TO HERE IT WORKED *********** + + + + +insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko +insmod /tmp/usralgo.ko + + 286 dmesg + 287 rmmod hello.ko + 288 dmesg + 289 cat /proc/kallsyms | grep user_pid_ctrl + 290 rmmod usralgo + 291 cat /proc/kallsyms | grep user_pid_ctrl + 292 insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko + 293 cat /proc/kallsyms | grep user_pid_ctrl + 294 rmmod usralgo + 295 insmod /tmp/usralgo.ko + 296 cat /proc/kallsyms | grep user_pid_ctrl + 297 history + +THIS ALSO WORKED !!! + + + +rmmod usralgo +insmod /mypath/usralgo.ko (e.g. insmod /opt/ppmac/usrflash/Project/Bin/Debug/usralgo.ko) +cat /proc/kallsyms | grep MyUserAlgoFunctionName (e.g. cat /proc/kallsyms | grep user_pid_ctrl) + diff --git a/usrServo/pp_proj.h b/usrServo/pp_proj.h new file mode 100644 index 0000000..69f926c --- /dev/null +++ b/usrServo/pp_proj.h @@ -0,0 +1,295 @@ + +#ifndef _PP_PROJ_H_ +#define _PP_PROJ_H_ +//*********************************************************************************** +// C header for accessing PMAC Global, CSGlobal, Ptr vars +// _PPScriptMode_ for Pmac Script like access global & csglobal +// global Mypvar - access with "Mypvar" +// global Myparray(32) - access with "Myparray(i)" +// csglobal Myqvar - access with "Myqvar(i)" where "i" is Coord # +// csglobal Myqarray(16) - access with "Myqvar(i,j)" where "j" is index +// _EnumMode_ for Pmac enum data type checking on Set & Get global functions +// Example +// global Mypvar +// csglobal Myqvar +// "SetGlobalVar(Myqvar, data)" will give a compile error because its a csglobal var. +// "SetCSGlobalVar(Mypvar, data)" will give a compile error because its a global var. +//************************************************************************************ + +#ifdef _PPScriptMode_ +enum globalP {_globalP_=-1}; +enum globalParray {_globalParray_=-1}; +enum csglobalQ {_csglobalQ_=-1}; +enum csglobalQarray {_csglobalQarray_=-1}; + +enum ptrM {_ptrM_=-1}; +enum ptrMarray {_ptrMarray_=-1}; +void SetEnumGlobalVar(enum globalP var, double data) +{ + pshm->P[var] = data; +} + +double GetEnumGlobalVar(enum globalP var) +{ + return pshm->P[var]; +} + +void SetEnumGlobalArrayVar(enum globalParray var, unsigned index, double data) +{ + pshm->P[(var + index)%MAX_P] = data; +} + +double GetEnumGlobalArrayVar(enum globalParray var, unsigned index) +{ + return pshm->P[(var + index)%MAX_P]; +} + +void SetEnumCSGlobalVar(enum csglobalQ var, unsigned cs, double data) +{ + pshm->Coord[cs % MAX_COORDS].Q[var] = data; +} + +double GetEnumCSGlobalVar(enum csglobalQ var, unsigned cs) +{ + return pshm->Coord[cs % MAX_COORDS].Q[var]; +} + +void SetEnumCSGlobalArrayVar(enum csglobalQarray var, unsigned index, unsigned cs, double data) +{ + pshm->Coord[cs % MAX_COORDS].Q[(var + index)%MAX_Q] = data; +} + +double GetEnumCSGlobalArrayVar(enum csglobalQarray var, unsigned index, unsigned cs) +{ + return pshm->Coord[cs % MAX_COORDS].Q[(var + index)%MAX_Q]; +} + +void SetEnumPtrVar(enum ptrM var, double data) +{ + im_write(pshm->Mdef + var, data, &pshm->Ldata); +} + +double GetEnumPtrVar(enum ptrM var) +{ + return im_read(pshm->Mdef + var, &pshm->Ldata); +} + +void SetEnumPtrArrayVar(enum ptrMarray var, unsigned index, double data) +{ + im_write(pshm->Mdef + ((var + index)%MAX_M), data, &pshm->Ldata); +} + +double GetEnumPtrArrayVar(enum ptrMarray var, unsigned index) +{ + return im_read(pshm->Mdef + ((var + index)%MAX_M), &pshm->Ldata); +} + +#define SetGlobalVar(i, x) SetEnumGlobalVar(i, x) +#define SetGlobalArrayVar(i, j, x) SetEnumGlobalArrayVar(i, j, x) +#define GetGlobalVar(i) GetEnumGlobalVar(i) +#define GetGlobalArrayVar(i, j) GetEnumGlobalArrayVar(i, j) + +#define SetCSGlobalVar(i, j, x) SetEnumCSGlobalVar(i, j, x) +#define SetCSGlobalArrayVar(i, j, k, x) SetEnumCSGlobalArrayVar(i, j, k, x) +#define GetCSGlobalVar(i, j) GetEnumCSGlobalVar(i, j) +#define GetCSGlobalArrayVar(i, j, k) GetEnumCSGlobalArrayVar(i, j, k) + +#define SetPtrVar(i, x) SetEnumPtrVar(i, x) +#define SetPtrArrayVar(i, j, x) SetEnumPtrArrayVar(i, j, x) +#define GetPtrVar(i) GetEnumPtrVar(i) +#define GetPtrArrayVar(i, j) GetEnumPtrArrayVar(i, j) +// end of #ifdef _PPScriptMode_ +#else +#ifdef _EnumMode_ +enum globalP {_globalP_=-1}; +enum globalParray {_globalParray_=-1}; +enum csglobalQ {_csglobalQ_=-1}; +enum csglobalQarray {_csglobalQarray_=-1}; +enum ptrM {_ptrM_=-1}; +enum ptrMarray {_ptrMarray_=-1}; +void SetEnumGlobalVar(enum globalP var, double data) +{ + pshm->P[var] = data; +} + +double GetEnumGlobalVar(enum globalP var) +{ + return pshm->P[var]; +} + +void SetEnumGlobalArrayVar(enum globalParray var, unsigned index, double data) +{ + pshm->P[(var + index)%MAX_P] = data; +} + +double GetEnumGlobalArrayVar(enum globalParray var, unsigned index) +{ + return pshm->P[(var + index)%MAX_P]; +} + +void SetEnumCSGlobalVar(enum csglobalQ var, unsigned cs, double data) +{ + pshm->Coord[cs % MAX_COORDS].Q[var] = data; +} + +double GetEnumCSGlobalVar(enum csglobalQ var, unsigned cs) +{ + return pshm->Coord[cs % MAX_COORDS].Q[var]; +} + +void SetEnumCSGlobalArrayVar(enum csglobalQarray var, unsigned index, unsigned cs, double data) +{ + pshm->Coord[cs % MAX_COORDS].Q[(var + index)%MAX_Q] = data; +} + +double GetEnumCSGlobalArrayVar(enum csglobalQarray var, unsigned index, unsigned cs) +{ + return pshm->Coord[cs % MAX_COORDS].Q[(var + index)%MAX_Q]; +} + +void SetEnumPtrVar(enum ptrM var, double data) +{ + im_write(pshm->Mdef + var, data, &pshm->Ldata); +} + +double GetEnumPtrVar(enum ptrM var) +{ + return im_read(pshm->Mdef + var, &pshm->Ldata); +} + +void SetEnumPtrArrayVar(enum ptrMarray var, unsigned index, double data) +{ + im_write(pshm->Mdef + ((var + index)%MAX_M), data, &pshm->Ldata); +} + +double GetEnumPtrArrayVar(enum ptrMarray var, unsigned index) +{ + return im_read(pshm->Mdef + ((var + index)%MAX_M), &pshm->Ldata); +} + +#define SetGlobalVar(i, x) SetEnumGlobalVar(i, x) +#define SetGlobalArrayVar(i, j, x) SetEnumGlobalArrayVar(i, j, x) +#define GetGlobalVar(i) GetEnumGlobalVar(i) +#define GetGlobalArrayVar(i, j) GetEnumGlobalArrayVar(i, j) + +#define SetCSGlobalVar(i, j, x) SetEnumCSGlobalVar(i, j, x) +#define SetCSGlobalArrayVar(i, j, k, x) SetEnumCSGlobalArrayVar(i, j, k, x) +#define GetCSGlobalVar(i, j) GetEnumCSGlobalVar(i, j) +#define GetCSGlobalArrayVar(i, j, k) GetEnumCSGlobalArrayVar(i, j, k) + +#define SetPtrVar(i, x) SetEnumPtrVar(i, x) +#define SetPtrArrayVar(i, j, x) SetEnumPtrArrayVar(i, j, x) +#define GetPtrVar(i) GetEnumPtrVar(i) +#define GetPtrArrayVar(i, j) GetEnumPtrArrayVar(i, j) +// end of #ifdef _EnumMode_ +#else +// ***** Standard default mode ***** +#endif +#endif +//Kinematic defines for CfromScript +#define FWD_KIN 0 +#define INV_KIN 1 +#define RT_PLC 2 +#define BG_PLC 3 +#define RT_PROG 4 +#define KinPosMotor L +#define KinVelMotor R +#define KinEnaAxisA 0x1 +#define KinPosAxisA C[0] +#define KinVelAxisA C[32] +#define KinEnaAxisB 0x2 +#define KinPosAxisB C[1] +#define KinVelAxisB C[33] +#define KinEnaAxisC 0x4 +#define KinPosAxisC C[2] +#define KinVelAxisC C[34] +#define KinEnaAxisU 0x8 +#define KinPosAxisU C[3] +#define KinVelAxisU C[35] +#define KinEnaAxisV 0x10 +#define KinPosAxisV C[4] +#define KinVelAxisV C[36] +#define KinEnaAxisW 0x20 +#define KinPosAxisW C[5] +#define KinVelAxisW C[37] +#define KinEnaAxisX 0x40 +#define KinPosAxisX C[6] +#define KinVelAxisX C[38] +#define KinEnaAxisY 0x80 +#define KinPosAxisY C[7] +#define KinVelAxisY C[39] +#define KinEnaAxisZ 0x100 +#define KinPosAxisZ C[8] +#define KinVelAxisZ C[40] +#define KinEnaAxisAA 0x200 +#define KinPosAxisAA C[9] +#define KinVelAxisAA C[41] +#define KinEnaAxisBB 0x400 +#define KinPosAxisBB C[10] +#define KinVelAxisBB C[42] +#define KinEnaAxisCC 0x800 +#define KinPosAxisCC C[11] +#define KinVelAxisCC C[43] +#define KinEnaAxisDD 0x1000 +#define KinPosAxisDD C[12] +#define KinVelAxisDD C[44] +#define KinEnaAxisEE 0x2000 +#define KinPosAxisEE C[13] +#define KinVelAxisEE C[45] +#define KinEnaAxisFF 0x4000 +#define KinPosAxisFF C[14] +#define KinVelAxisFF C[46] +#define KinEnaAxisGG 0x8000 +#define KinPosAxisGG C[15] +#define KinVelAxisGG C[47] +#define KinEnaAxisHH 0x10000 +#define KinPosAxisHH C[16] +#define KinVelAxisHH C[48] +#define KinEnaAxisLL 0x20000 +#define KinPosAxisLL C[17] +#define KinVelAxisLL C[49] +#define KinEnaAxisMM 0x40000 +#define KinPosAxisMM C[18] +#define KinVelAxisMM C[50] +#define KinEnaAxisNN 0x80000 +#define KinPosAxisNN C[19] +#define KinVelAxisNN C[51] +#define KinEnaAxisOO 0x100000 +#define KinPosAxisOO C[20] +#define KinVelAxisOO C[52] +#define KinEnaAxisPP 0x200000 +#define KinPosAxisPP C[21] +#define KinVelAxisPP C[53] +#define KinEnaAxisQQ 0x400000 +#define KinPosAxisQQ C[22] +#define KinVelAxisQQ C[54] +#define KinEnaAxisRR 0x800000 +#define KinPosAxisRR C[23] +#define KinVelAxisRR C[55] +#define KinEnaAxisSS 0x1000000 +#define KinPosAxisSS C[24] +#define KinVelAxisSS C[56] +#define KinEnaAxisTT 0x2000000 +#define KinPosAxisTT C[25] +#define KinVelAxisTT C[57] +#define KinEnaAxisUU 0x4000000 +#define KinPosAxisUU C[26] +#define KinVelAxisUU C[58] +#define KinEnaAxisVV 0x8000000 +#define KinPosAxisVV C[27] +#define KinVelAxisVV C[59] +#define KinEnaAxisWW 0x10000000 +#define KinPosAxisWW C[28] +#define KinVelAxisWW C[60] +#define KinEnaAxisXX 0x20000000 +#define KinPosAxisXX C[29] +#define KinVelAxisXX C[61] +#define KinEnaAxisYY 0x40000000 +#define KinPosAxisYY C[30] +#define KinVelAxisYY C[62] +#define KinEnaAxisZZ 0x80000000 +#define KinPosAxisZZ C[31] +#define KinVelAxisZZ C[63] +#define KinAxisUsed D[0] +#define KinVelEna D[0] +#endif //_PP_PROJ_H_ diff --git a/usrServo/sampleKernelModule/Makefile.Deltatau b/usrServo/sampleKernelModule/Makefile.Deltatau new file mode 100644 index 0000000..96e015e --- /dev/null +++ b/usrServo/sampleKernelModule/Makefile.Deltatau @@ -0,0 +1,94 @@ +#------------------------------------------------------------------------------ +# Copyright (C) Delta Tau Data Systems Inc., 2007 +# All rights reserved. +# +# Generic makefile for any c realtime C plc 0, user servo or user phase +# For a new project change the following +# +# 1.) usralgo-objs should be assigned the 'C' source code files that need to be compiled +# 2.) issue the command 'make depend' the first time a project is created and +# (every time an additional 'C' file is added to the project the command +# 'make depend' must be issued) +# 3.) issue the command make clean +# 4.) issue the command make +# +# Notes +# -------- +# Change DTDEBUG above to -O2 for release w/ optimization +# Change DTDEBUG above to -g3 for debug +# arm,i386,i385hv,ppc460-2,ppc460-1,ppc405 +#------------------------------------------------------------------------------ + +PMAC_ARCH=ppc465-2 + +ifeq ($(PMAC_ARCH),ppc465-2) +ARCH=powerpc +#CROSS_COMPILE=powerpc-meau-linux-gnu- +CROSS_COMPILE=/opt/eldk-4.2/usr/bin/ppc_4xxFP- +KDIR=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +KSRC=/opt/powerpc-465-rootfs/usr/src/linux-3.2.21-serengeti-smp +#CC=powerpc-meau-linux-gnu-gcc +#AS=powerpc-meau-linux-gnu-as +#LD=powerpc-meau-linux-gnu-gcc +CC=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc +AS=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc +LD=/opt/eldk-4.2/usr/bin/ppc_4xxFP-gcc +#STRIP=i686-meau-linux-gnu-strip +INCLUDE=/opt/powerpc-465-rootfs/usr/lib/gcc/powerpc-linux-gnu/4.6/include +XENOMAI_INC_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/include +XENOMAI_LIB_DIR=/opt/powerpc-465-rootfs/usr/local/xenomai-2.6.2.1/lib +RPATH=-Wl,-rpath-link,/opt/powerpc-465-rootfs/lib/powerpc-linux-gnu +ROOTFS_DIR=/opt/powerpc-465-rootfs +endif + +#RTPMACINCLUDEDIR=/usr/local/dtlibs/rtpmac +#LIBPPMACINCLUDEDIR=/usr/local/dtlibs/libppmac +RTPMACINCLUDEDIR=../ppmac/rtpmac/ +LIBPPMACINCLUDEDIR=../ppmac/libppmac/ + +export ARCH +export CROSS_COMPILE + +OBJS := ${patsubst %, %.o, $(MODULES)} +CLEANMOD := ${patsubst %, .%*, $(MODULES)} +PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) + + +#obj-m += usralgo.o +#usralgo-objs := usralgomain.o \ +usrcode.o +obj-m += hello.o + + + +LDFLAGS := -nostdlib +EXTRA_CFLAGS := -O2 -DCONFIG_460EX -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -mhard-float -I$(RTPMACINCLUDEDIR) -I$(LIBPPMACINCLUDEDIR) -I$(XENOMAI_INC_DIR) -I$(XENOMAI_INC_DIR)/posix -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/posix -I$(INCLUDE) $(ADD_CFLAGS) --sysroot=$(ROOTFS_DIR) +KBUILD_EXTRA_SYMBOLS := /usr/local/dtlibs/libppmac/Module.symvers + +%.o: %.S + $(CC) -s -D__KERNEL__ -x c -E $< -o $*.i + $(AS) -mbooke -o $@ $*.i + +#all:: +# cp -f /usr/local/usralgo/usralgomain.c $(PWD) +all: + $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules +# mv -f usralgo.ko ../../bin/Debug/ + +#modules: +# @echo "$(CFLAGS)" + +bclean:: + $(RM) *.o .*.o.d .*.o.cmd *.ko *.log + $(RM) -R .tmp* + $(RM) .runinfo + rm -rf .runinfo .tmp* .*.o.d .*.o.cmd .*.cmd *.o *.ko *.mod.c *.i *.so Module.symvers modules.order + +clean:: + $(RM) *.o .*.o.d .*.o.cmd *.ko + $(RM) -R .tmp* + $(RM) .runinfo + rm -rf .runinfo .tmp* .*.o.d .*.o.cmd .*.cmd *.o *.ko *.mod.c *.i *.so Module.symvers modules.order + +dbg: + @echo PATH $(PATH) \ No newline at end of file diff --git a/usrServo/sampleKernelModule/Makefile.Ubuntu b/usrServo/sampleKernelModule/Makefile.Ubuntu new file mode 100644 index 0000000..bb37106 --- /dev/null +++ b/usrServo/sampleKernelModule/Makefile.Ubuntu @@ -0,0 +1,8 @@ +obj-m += hello.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +# make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules V=1 + +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean \ No newline at end of file diff --git a/usrServo/sampleKernelModule/hello.c b/usrServo/sampleKernelModule/hello.c new file mode 100644 index 0000000..eae5337 --- /dev/null +++ b/usrServo/sampleKernelModule/hello.c @@ -0,0 +1,21 @@ +#include // included for all kernel modules +#include // included for KERN_INFO +#include // included for __init and __exit macros + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Lakshmanan"); +MODULE_DESCRIPTION("A Simple Hello World module"); + +static int __init hello_init(void) +{ + printk(KERN_INFO "Hello world!\n"); + return 0; // Non-zero return means that the module couldn't be loaded. +} + +static void __exit hello_cleanup(void) +{ + printk(KERN_INFO "Cleaning up module.\n"); +} + +module_init(hello_init); +module_exit(hello_cleanup); diff --git a/usrServo/usralgo.mod.c b/usrServo/usralgo.mod.c new file mode 100644 index 0000000..147b9f6 --- /dev/null +++ b/usrServo/usralgo.mod.c @@ -0,0 +1,21 @@ +#include +#include +#include + +MODULE_INFO(vermagic, VERMAGIC_STRING); + +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif + .arch = MODULE_ARCH_INIT, +}; + +static const char __module_depends[] +__used +__attribute__((section(".modinfo"))) = +"depends="; + diff --git a/usrServo/usralgomain.c b/usrServo/usralgomain.c new file mode 100644 index 0000000..3232aa8 --- /dev/null +++ b/usrServo/usralgomain.c @@ -0,0 +1,114 @@ +//--------------------------------------------------------------------------- +// Project PowerPMAC Firmware +// Delta Tau Data Systems, Inc. +// Copyright 2007. All Rights Reserved. +// +// SUBSYSTEM: User Algo Driver +// FILE: usralgo.c +// AUTH OR: Henry Bausley +// +// OVERVIEW +// ~~~~~~~~ +// This file is a device driver that exports functions that can be used by other +// kernel mode modules. ie. RtPmac.rtl can call functions that are part of this +// driver for use as user written servo, phase, plc rti, plc rt thread +// No one should ever have to touch this module! Custom routines are added +// as additional modules as whatever name the user wants. +// +// NOTES +// ~~~~~ +// - The driver must be loaded +// bash-3.0# insmod /opt/ppmac/usralgo/usralgo.ko +// +// - A node can be created on the file system the thing you fopen +// but it is not required. Could be used by gpos if ioctl's were added +// bash-3.0# mknod -m 666 /dev/usralgo c 240 0 +// +//-------------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//#define KDBEUG 1 + +#ifdef KDBEUG + #define PRINTK(arg) printk(arg) +#else + #define PRINTK(arg) +#endif + +#define USRALGO_MAJOR 240 +#define USRALGO_NAME "usralgo" + +struct SHM *pshm; // Pointer to shared memory +volatile unsigned *piom; // Pointer to I/O memory +void *pushm; // Pointer to user memory + + +// define which file operations are supported +struct file_operations usralgo_fops = +{ + .owner = THIS_MODULE, + .llseek = NULL, + .read = NULL, + .write = NULL, +// .readdir = NULL, + .poll = NULL, +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) + .ioctl = NULL, +#else + .unlocked_ioctl = NULL, +#endif + .mmap = NULL, + .open = NULL, + .flush = NULL, + .release = NULL, + .fsync = NULL, + .fasync = NULL, + .lock = NULL, +}; + +//----------------------------------------------------------------------- +// initialize module -- this what is called when you do insmod ./usralgo.ko +//----------------------------------------------------------------------- +static int __init usralgo_init_module (void) +{ + int i; + + PRINTK(KERN_INFO "initializing module usralgo\n"); + pshm = GetSharedMemPtr(); + pushm = GetUserBufferPtr(); + piom = GetIOMemPtr(); + + i = register_chrdev (USRALGO_MAJOR, USRALGO_NAME, &usralgo_fops); + if (i != 0) return - EIO; + + return 0; +} + +//----------------------------------------------------------------------- +// close and cleanup module +//------------------------- +static void __exit usralgo_cleanup_module (void) +{ + PRINTK("cleaning up module usralgo\n"); + unregister_chrdev (USRALGO_MAJOR, USRALGO_NAME); +} + +module_init(usralgo_init_module); +module_exit(usralgo_cleanup_module); +MODULE_AUTHOR("www.deltatau.com"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Linux Device Driver for usralgo"); diff --git a/usrServo/usrcode.c b/usrServo/usrcode.c new file mode 100644 index 0000000..88cb5b6 --- /dev/null +++ b/usrServo/usrcode.c @@ -0,0 +1,109 @@ +//--------------------------------------------------------------------------- +// Project PowerPMAC Firmware +// Delta Tau Data Systems, Inc. +// Copyright 2007. All Rights Reserved. +// +// SUBSYSTEM: User Servo Driver +// FILE: usrcode.c +// TEMPLATE AUTHOR: Henry Bausley +// +// OVERVIEW +// ~~~~~~~~ +// This file is where exportable user code can be placed. +// To make a function callable as a user servo do three steps +// +// 1.) Prototye the function user_func(void ,void ); +// 2.) Export the function EXPORT_SYMBOL(user_func); +// 3.) Make sure useralgo.ko has been loaded with projpp.ini +// +//-------------------------------------------------------------------------------- +#include "usrcode.h" +//---------------------------------------------------------------------------------- +// pp_proj.h is the C header for accessing PMAC Global, CSGlobal, Ptr vars +// _PPScriptMode_ for Pmac Script like access global & csglobal +// global Mypvar - access with "Mypvar" +// global Myparray(32) - access with "Myparray(i)" +// csglobal Myqvar - access with "Myqvar(i)" where "i" is Coord # +// csglobal Myqarray(16) - access with "Myqvar(i,j)" where "j" is index +// _EnumMode_ for Pmac enum data type checking on Set & Get global functions +// Example +// global Mypvar +// csglobal Myqvar +// "SetGlobalVar(Myqvar, data)" will give a compile error because its a csglobal var. +// "SetCSGlobalVar(Mypvar, data)" will give a compile error because its a global var. +//------------------------------------------------------------------------------------ +#define _PPScriptMode_ // uncomment for Pmac Script type access +// #define _EnumMode_ // uncomment for Pmac enum data type checking on Set & Get global functions + +#include "pp_proj.h" +#ifdef __KERNEL__ +// Kernal mode can't have paths with spaces and long names +//#include "../../PMACSC~1/GLOBAL~1/asharedwithcapp.pmh" +#else +//#include "../../PMAC Script Language/Global Includes/asharedwithcapp.pmh" +#endif + +extern struct SHM *pshm; // Pointer to shared memory +extern volatile unsigned *piom; // Pointer to I/O memory +extern void *pushm; // Pointer to user memory + +void user_phase( struct MotorData *Mptr) +{ +} + +double user_pid_ctrl( struct MotorData *Mptr) +{ + //double *p; + //p = pushm; + //return 0; + double ctrl_out; + if (Mptr->ClosedLoop) { + // Compute PD terms + ctrl_out=Mptr->Servo.Kp*Mptr->PosError-Mptr->Servo.Kvfb*Mptr->ActVel; + Mptr->Servo.Integrator+=Mptr->PosError*Mptr->Servo.Ki; // I term + ctrl_out+=Mptr->Servo.Integrator; + // Combine + if (ctrl_out>10)ctrl_out=10; + if (ctrl_out<-10)ctrl_out=-10; + return ctrl_out; + } + else { + Mptr->Servo.Integrator=0.0; + return 0.0; + } +} + +void CaptCompISR(void) +{ + unsigned *pUnsigned = pushm; + *pUnsigned = *pUnsigned + 1; +} + +double GetLocal(struct LocalData *Ldata,int m) +{ + return *(Ldata->L + Ldata->Lindex + m); +} + +void SetLocal(struct LocalData *Ldata,int m,double value) +{ + *(Ldata->L + Ldata->Lindex + m) = value; +} + +double *GetLocalPtr(struct LocalData *Ldata,int m) +{ + return (Ldata->L + Ldata->Lindex + m); +} + +double CfromScript(double cfrom_type, double arg2, double arg3, double arg4, double arg5, double arg6, double arg7, struct LocalData *Ldata) +{ + int icfrom_type = (int) cfrom_type; + double *C, *D, *L, *R, rtn; // C, D, R - only needed if doing Kinmatics + + C = GetCVarPtr(Ldata); // Only needed if doing Kinmatics + D = GetDVarPtr(Ldata); // Only needed if doing Kinmatics + L = GetLVarPtr(Ldata); // Only needed if using Ldata or Kinmatics + R = GetRVarPtr(Ldata); // Only needed if doing Kinmatics + rtn = -1.0; + return rtn; +} + diff --git a/usrServo/usrcode.h b/usrServo/usrcode.h new file mode 100644 index 0000000..09f0153 --- /dev/null +++ b/usrServo/usrcode.h @@ -0,0 +1,132 @@ +#ifdef __KERNEL__ +#include +#else +#define EXPORT_SYMBOL(x) // x +#define KERN_ALERT +#define printk printf +#include +#endif +#include // Global Rt/Gp Externals and structures +#include + +int rtsprintf(char * buf, const char *fmt, ...); + +double user_pid_ctrl( struct MotorData *Mptr); +EXPORT_SYMBOL(user_pid_ctrl); + +void user_phase( struct MotorData *Mptr); +EXPORT_SYMBOL(user_phase); + +void CaptCompISR(void); +EXPORT_SYMBOL(CaptCompISR); + +double CfromScript(double arg1,double arg2,double arg3,double arg4,double arg5,double arg6,double arg7,struct LocalData *Ldata); +EXPORT_SYMBOL(CfromScript); + +//---------------------------------------- +// Required Kinematic define Names +//---------------------------------------- +#define KinPosMotor L +#define KinVelMotor R +#define KinEnaAxisA 0x1 +#define KinPosAxisA C[0] +#define KinVelAxisA C[32] +#define KinEnaAxisB 0x2 +#define KinPosAxisB C[1] +#define KinVelAxisB C[33] +#define KinEnaAxisC 0x4 +#define KinPosAxisC C[2] +#define KinVelAxisC C[34] +#define KinEnaAxisU 0x8 +#define KinPosAxisU C[3] +#define KinVelAxisU C[35] +#define KinEnaAxisV 0x10 +#define KinPosAxisV C[4] +#define KinVelAxisV C[36] +#define KinEnaAxisW 0x20 +#define KinPosAxisW C[5] +#define KinVelAxisW C[37] +#define KinEnaAxisX 0x40 +#define KinPosAxisX C[6] +#define KinVelAxisX C[38] +#define KinEnaAxisY 0x80 +#define KinPosAxisY C[7] +#define KinVelAxisY C[39] +#define KinEnaAxisZ 0x100 +#define KinPosAxisZ C[8] +#define KinVelAxisZ C[40] +#define KinEnaAxisAA 0x200 +#define KinPosAxisAA C[9] +#define KinVelAxisAA C[41] +#define KinEnaAxisBB 0x400 +#define KinPosAxisBB C[10] +#define KinVelAxisBB C[42] +#define KinEnaAxisCC 0x800 +#define KinPosAxisCC C[11] +#define KinVelAxisCC C[43] +#define KinEnaAxisDD 0x1000 +#define KinPosAxisDD C[12] +#define KinVelAxisDD C[44] +#define KinEnaAxisEE 0x2000 +#define KinPosAxisEE C[13] +#define KinVelAxisEE C[45] +#define KinEnaAxisFF 0x4000 +#define KinPosAxisFF C[14] +#define KinVelAxisFF C[46] +#define KinEnaAxisGG 0x8000 +#define KinPosAxisGG C[15] +#define KinVelAxisGG C[47] +#define KinEnaAxisHH 0x10000 +#define KinPosAxisHH C[16] +#define KinVelAxisHH C[48] +#define KinEnaAxisLL 0x20000 +#define KinPosAxisLL C[17] +#define KinVelAxisLL C[49] +#define KinEnaAxisMM 0x40000 +#define KinPosAxisMM C[18] +#define KinVelAxisMM C[50] +#define KinEnaAxisNN 0x80000 +#define KinPosAxisNN C[19] +#define KinVelAxisNN C[51] +#define KinEnaAxisOO 0x100000 +#define KinPosAxisOO C[20] +#define KinVelAxisOO C[52] +#define KinEnaAxisPP 0x200000 +#define KinPosAxisPP C[21] +#define KinVelAxisPP C[53] +#define KinEnaAxisQQ 0x400000 +#define KinPosAxisQQ C[22] +#define KinVelAxisQQ C[54] +#define KinEnaAxisRR 0x800000 +#define KinPosAxisRR C[23] +#define KinVelAxisRR C[55] +#define KinEnaAxisSS 0x1000000 +#define KinPosAxisSS C[24] +#define KinVelAxisSS C[56] +#define KinEnaAxisTT 0x2000000 +#define KinPosAxisTT C[25] +#define KinVelAxisTT C[57] +#define KinEnaAxisUU 0x4000000 +#define KinPosAxisUU C[26] +#define KinVelAxisUU C[58] +#define KinEnaAxisVV 0x8000000 +#define KinPosAxisVV C[27] +#define KinVelAxisVV C[59] +#define KinEnaAxisWW 0x10000000 +#define KinPosAxisWW C[28] +#define KinVelAxisWW C[60] +#define KinEnaAxisXX 0x20000000 +#define KinPosAxisXX C[29] +#define KinVelAxisXX C[61] +#define KinEnaAxisYY 0x40000000 +#define KinPosAxisYY C[30] +#define KinVelAxisYY C[62] +#define KinEnaAxisZZ 0x80000000 +#define KinPosAxisZZ C[31] +#define KinVelAxisZZ C[63] +#define KinAxisUsed D[0] +#define KinVelEna D[0] +//---------------------------------------- + + +