Support for Matlab/Simulink/RTW in RTAI Kernel Space
==================================================

This README completes the original README from Lorenzo Dozio.

What you need for Matlab/Simulink in kernel space
=================================================

- krtai.tlc: is the Target Language Compiler file to be used for RTAI. 

- krtai.tmf: is the template Makefile to be used in Matlab/RTW. In this file 
	     you should check and prossibly modify only the following list 
	     of directories, in order to be compatible with your own 
	     configuration:
		LINUX_HOME = /usr/src/linux
		RTAI_HOME  = /usr/src/rtai

- krtmain.c: is the real time main program that allows the model to be 
	     correctly executed under RTAI.

- krtai2rtw.c: is the link between the Matlab SW and krtmain.c. The
               files generated by RTW can't be compiled with the 
               "__KERNEL__" flag and we need a link between the two
               worlds.

- klib: contains functions which are not defined in kernel space and a
  utility to work with PCI cards
     
- devices/rtai_lib.mdl : library with different I/O modules tested in
  kernel space

- devices/*.c: these are the sources to build the different MEX-files
  (I/O drivers). I'm looking to change the "COMEDI" drivers in order
  to work in kernel space. At this moment only the drivers defined in
  "rtai_lib" works fine in kernel space.

- examples : is a Simulink model to test the support. Contains
             a model to test the system

How to install the support
==========================

- create under $(MATLABROOT)/rtw/c a directory called rtai
  (where $(MATLABROOT) is the root directory of Matlab, e.g.
  /usr/local/matlab)

- copy "krtmain.c"
       "krtai.tlc"
       "krtai.tmf"
       "krtai2rtw.c"
       "krtmain.h"
       "krtai2rtw.h"
       "krt_pci.h"
  and the directory "devices" and klib from "rtai" to $(MATLABROOT)/rtw/c/rtai

- from the Matlab session run "setup" to set the new path

How to test the support
=======================

- open the test.mdl example

- generate the code from the RTW menu using "krtai"

- compile the code from the directory "test_krtai" (typing "make -f test.mk"); 
  in general a directory called "modelname_krtai" is created at the generation 
  stage, where modelname is the name of the Simulink model

- load the required rtai modules and the simulink module 

    insmod rtai
    insmod rtai_shm
    insmod rtai_sched
    insmod rtai_sched_ext
    insmod rtai_lxrt
    insmod rtai_fifos
    insmod net_rpc
    /usr/local/bin/urtnet &
    insmod ./rt_process.o

- start xrtailab o rtailab

- when finished:
    rmmod rt_process
    rmmod net_rpc
    rmmod rtai_fifos
    rmmod rtai_lxrt
    rmmod rtai_sched_ext
    rmmod rtai_sched
    rmmod rtai_shm
    rmmod rtai

For the execution options available to run the RTW generated standalone code
read the file READ in the main RTAI-Lab directory.

Roberto Bucher (roberto.bucher@die.supsi.ch)
2003 Febrary 16 
