I nformación de acceso libre sobre cambio climático
Gráfica 1. Evolución de emisiones de Gei en México, 1990-2006.
Basically the kernel API was transferred into userspace via the master character device (see chapter 2,Figure 2.1 and subsection 7.1.1).
The function calls of the kernel API are mapped to the userspace via an ioctl()
interface. The userspace API functions share a set of generic ioctl() calls. The kernel part of the interface calls the according API functions directly, what results in a minimum additional delay (see subsection 7.2.3).
For performance reasons, the actual domain process data (see section 2.3) are not copied between kernel and user memory on every access: Instead, the data are memory-mapped to the userspace application. Once the master is configured and activated, the master module creates one process data memory area spanning all domains and maps it to userspace, so that the application can directly access the process data. As a result, there is no additional delay when accessing process data from userspace.
Kernel/User API Differences Because of the memory-mapping of the process data, the memory is managed internally by the library functions. As a result, it is not possi- ble to provide external memory for domains, like in the kernel API. The corresponding functions are only available in kernelspace. This is the only difference when using the application interface in userspace.
7.2.3 Timing
An interesting aspect is the timing of the userspace library calls compared to those of the kernel API.Table 7.1shows the call times and standard deviancies of typical (and time-critical) API functions measured on an Intel Pentium 4 M CPU with 2.2 GHz and a standard 2.6.26 kernel.
Table 7.1: Application Interface Timing Comparison
Kernelspace Userspace Function µ(t) σ(t) µ(t) σ(t) ecrt_master_receive() 1.1 µs 0.3 µs 2.2 µs 0.5 µs ecrt_domain_process() < 0.1 µs < 0.1 µs 1.0 µs 0.2 µs ecrt_domain_queue() < 0.1 µs < 0.1 µs 1.0 µs 0.1 µs ecrt_master_send() 1.8 µs 0.2 µs 2.5 µs 0.5 µs
The test results show, that for this configuration, the userspace API causes about 1 µs additional delay for each function, compared to the kernel API.
7.3 RTDM Interface
When using the userspace interfaces of realtime extensions like Xenomai or RTAI, the use of ioctl() is not recommended, because it may disturb realtime operation. To accomplish this, the Real-Time Device Model (RTDM) [17] has been developed. The master module provides an RTDM interface (see Figure 2.1) in addition to the normal character device, if the master sources were configured with --enable-rtdm (see chapter 9).
To force an application to use the RTDM interface instead of the normal character device, it has to be linked with the libethercat rtdm library instead of libethercat. The use of the libethercat rtdm is transparent, so the EtherCAT header ecrt.h with the complete API can be used as usual.
To make the example in Listing 7.1 use the RTDM library, the linker command has
to be altered as follows:
gcc e t h e r c a t - with - r t d m . c - o e c t e s t - I / opt / e t h e r l a b / i n c l u d e \ - L / opt / e t h e r l a b / lib - l e t h e r c a t _ r t d m \
7.4 System Integration
7.4 System Integration
To integrate the EtherCAT master as a service into a running system, it comes with an init script and a sysconfig file, that are described below. Modern systems may be managed by systemd [7]. Integration of the master with systemd is described in
subsection 7.4.4.
7.4.1 Init Script
The EtherCAT master init script conforms to the requirements of the “Linux Standard Base” (LSB, [6]). The script is installed to etc/init.d/ethercat below the installation prefix and has to be copied (or better: linked) to the appropriate location (see chap- ter 9), before the master can be inserted as a service. Please note, that the init script depends on the sysconfig file described below.
To provide service dependencies (i. e. which services have to be started before others) inside the init script code, LSB defines a special comment block. System tools can extract this information to insert the EtherCAT init script at the correct place in the startup sequence: # R e q u i r e d - S t a r t : $ l o c a l _ f s $ s y s l o g $ n e t w o r k # Should - S t a r t : $ t i m e ntp # R e q u i r e d - S t o p : $ l o c a l _ f s $ s y s l o g $ n e t w o r k # Should - S t o p : $ t i m e ntp # Default - S t a r t : 3 5 # Default - S t o p : 0 1 2 6 # Short - D e s c r i p t i o n : E t h e r C A T m a s t e r # D e s c r i p t i o n : E t h e r C A T m a s t e r 1 . 5 . 2 ### END I N I T I N F O # - - - -
7.4.2 Sysconfig File
For persistent configuration, the init script uses a sysconfig file installed to etc/syscon- fig/ethercat (below the installation prefix), that is mandatory for the init script. The sysconfig file contains all configuration variables needed to operate one or more mas- ters. The documentation is inside the file and included below:
1 # - - - -
2 3 #
4 # M a i n E t h e r n e t d e v i c e s .
5 #
6 # The MASTER < X > _ D E V I C E v a r i a b l e s p e c i f i e s the E t h e r n e t d e v i c e for a m a s t e r
8 #
9 # S p e c i f y the MAC a d d r e s s ( h e x a d e c i m a l w i t h c o l o n s ) of the E t h e r n e t d e v i c e to
10 # use . E x a m p l e : " 0 0 : 0 0 : 0 8 : 4 4 : ab : 6 6 "
11 #
12 # The b r o a d c a s t a d d r e s s " ff : ff : ff : ff : ff : ff " has a s p e c i a l m e a n i n g : It t e l l s
13 # the m a s t e r to a c c e p t the f i r s t d e v i c e o f f e r e d by any E t h e r n e t d r i v e r .
14 #
15 # The MASTER < X > _ D E V I C E v a r i a b l e s a l s o d e t e r m i n e , how m a n y m a s t e r s w i l l be
16 # c r e a t e d : A non - e m p t y v a r i a b l e M A S T E R 0 _ D E V I C E w i l l c r e a t e one master , a d d i n g a
17 # non - e m p t y v a r i a b l e M A S T E R 1 _ D E V I C E w i l l c r e a t e a s e c o n d master , and so on .
18 # 19 M A S T E R 0 _ D E V I C E ="" 20 # M A S T E R 1 _ D E V I C E ="" 21 22 # 23 # B a c k u p E t h e r n e t d e v i c e s 24 #
25 # The MASTER < X > _ B A C K U P v a r i a b l e s s p e c i f y the d e v i c e s u s e d for r e d u n d a n c y . T h e y
26 # b e h a v e s n e a r l y the s a m e as the MASTER < X > _ D E V I C E v a r i a b l e , e x c e p t t h a t it
27 # d o e s not i n t e r p r e t the ff : ff : ff : ff : ff : ff a d d r e s s . 28 # 29 # M A S T E R 0 _ B A C K U P ="" 30 31 # 32 # E t h e r n e t d r i v e r m o d u l e s to use for E t h e r C A T o p e r a t i o n . 33 #
34 # S p e c i f y a non - e m p t y l i s t of E t h e r n e t drivers , t h a t s h a l l be u s e d for E t h e r C A T
35 # o p e r a t i o n .
36 #
37 # E x c e p t for the g e n e r i c E t h e r n e t d r i v e r module , the i n i t s c r i p t w i l l try to
38 # u n l o a d the u s u a l E t h e r n e t d r i v e r m o d u l e s in the l i s t and r e p l a c e t h e m w i t h
39 # the E t h e r C A T - c a p a b l e o n e s . If a c e r t a i n ( E t h e r C A T - c a p a b l e ) d r i v e r is not
40 # found , a w a r n i n g w i l l a p p e a r .
41 #
42 # P o s s i b l e v a l u e s : 8 1 3 9 too , e100 , e1000 , e1000e , r8169 , g e n e r i c . S e p a r a t e
43 # m u l t i p l e d r i v e r s w i t h s p a c e s .
44 #
45 # N o t e : The e100 , e1000 , e 1 0 0 0 e and r 8 1 6 9 d r i v e r s are not b u i l t by d e f a u l t .
46 # E n a b l e t h e m w i t h the - - enable - < driver > c o n f i g u r e s w i t c h e s .
47 #
48 # A t t e n t i o n : W h e n u s i n g the g e n e r i c driver , the c o r r e s p o n d i n g E t h e r n e t d e v i c e
49 # has to be a c t i v a t e d ( w i t h OS methods , for e x a m p l e ’ ip l i n k set e t h X up ’) ,
50 # b e f o r e the m a s t e r is started , o t h e r w i s e all f r a m e s w i l l t i m e out .
51 # 52 D E V I C E _ M O D U L E S ="" 53 54 # 55 # F l a g s for l o a d i n g k e r n e l m o d u l e s . 56 # 57 # T h i s can u s u a l l y be l e f t e m p t y . A d j u s t t h i s v a r i a b l e , if you h a v e p r o b l e m s 58 # w i t h m o d u l e l o a d i n g . 59 # 60 # M O D P R O B E _ F L A G S =" - b " 61 62 # - - - -
For systems managed by systemd (seesubsection 7.4.4), the sysconfig file has moved to/etc/ethercat.conf. Both versions are part of the master sources and are meant to used alternatively.
7.4 System Integration