Specifications

2.2. SOFTWARE: EXPLANATION AND INSTALLATION
5
2.2.2 S-function board drivers
The source-code of the user space drivers and some kernel space routines for the two boards were
supplied by the manufacturer [12]. This gave the opportunity to make a Real-Time driver which can
interact with Simulink using LXRT. Simulink offers the possibility to use own c-code in the models
by means of S-function [10] blocks. These S-function blocks are used as board drivers to initialize the
boards and run the acquisition.
(a) Flowchart for Analog In driver. (b) Flowchart for Analog Out driver.
Figure 2.1: Flowcharts of the S-function board drivers.
Due to LXRT only the c-code enabling the acquisition needs to be kernel calls. This implies that the
initialization procedure can be user space calls and only the code in mdlOutputs need to be kernel
calls. This has as biggest advantage that standard manufacturers source-code of the user-space drivers
can be used for initializing the boards.
In figure 2.1 the flowcharts for the Analog In 2.1(a) and Analog Out 2.1(b) show a Soft (user space)
and Hard (kernel space) Real-Time environment. The functions in Soft Real-Time are from the man-
ufacturers user space library and those in Hard Real-Time from the kernel space routines.
There is one exception to this in the Analog In driver where the manufacturers user space drivers
use the function ioctl. This function is not compatible whit RTAI(-LXRT). Instead iopl(3), to
give input/output port permission and mmap, to map the PCI ports, has to be used. Root permission
is needed to call the function iopl(3).
The AIn and AOut drivers are very similar. The order in which initialization functions are called is
the same. The only difference are some extra functions needed to initialize the AIn driver. The most
important function in the AIn driver is AiGetAIValue and in AOut this is PdUModeAO32Write.
These two functions acquire or send data in Real-Time to or from the hardware.