3464 |
3464 |
3465 The master module has a parameter \textit{ec\_eoeif\_count} to specify |
3465 The master module has a parameter \textit{ec\_eoeif\_count} to specify |
3466 the number of EoE interfaces (and handlers) per master to create. This |
3466 the number of EoE interfaces (and handlers) per master to create. This |
3467 parameter can either be specified when manually loading the master |
3467 parameter can either be specified when manually loading the master |
3468 module, or (when using the init script) by setting the |
3468 module, or (when using the init script) by setting the |
3469 \textit{\$EOE\_INTERFACES} variable in the sysconfig file (see |
3469 \textit{EOE\_INTERFACES} variable in the sysconfig file (see |
3470 section~\ref{sec:sysconfig}). Upon loading of the master module, the |
3470 section~\ref{sec:sysconfig}). Upon loading of the master module, the |
3471 virtual interfaces become available: |
3471 virtual interfaces become available: |
3472 |
3472 |
3473 \begin{lstlisting} |
3473 \begin{lstlisting} |
3474 host# `\textbf{ifconfig -a}` |
3474 host# `\textbf{ifconfig -a}` |
4042 \label{sec:init} |
4042 \label{sec:init} |
4043 \index{Init script} |
4043 \index{Init script} |
4044 |
4044 |
4045 The EtherCAT master provides an ``init script'', that conforms to the |
4045 The EtherCAT master provides an ``init script'', that conforms to the |
4046 requirements of the ``Linux Standard Base'' (LSB\index{LSB}, |
4046 requirements of the ``Linux Standard Base'' (LSB\index{LSB}, |
4047 \cite{lsb}). The script is installed to \textit{/etc/init.d/ethercat}, |
4047 \cite{lsb}). The script is installed to \textit{etc/init.d/ethercat} |
4048 so that the master can be easily inserted as a service. The different |
4048 below the installation prefix and has to be copied to the appropriate |
4049 Linux distributions offer different ways to mark the service for |
4049 location (see section~\ref{sec:make}), before the master can be |
4050 starting and stopping in certain runlevels (for example, SUSE provides |
4050 inserted as a service. The different Linux distributions offer |
4051 the \textit{insserv} command). |
4051 different ways to mark the service for starting and stopping in |
|
4052 certain runlevels (for example, SUSE Linux provides the |
|
4053 \textit{insserv} command). |
4052 |
4054 |
4053 To provide service dependencies (i.~e. which services have to be |
4055 To provide service dependencies (i.~e. which services have to be |
4054 started before) right inside the init script code, LSB defines a |
4056 started before) right inside the init script code, LSB defines a |
4055 special comment block. System tools can extract this information to |
4057 special comment block. System tools can extract this information to |
4056 insert the EtherCAT init script at the correct place in the startup |
4058 insert the EtherCAT init script at the correct place in the startup |
4071 \end{lstlisting} |
4073 \end{lstlisting} |
4072 |
4074 |
4073 The init script can also be used for manually starting and stopping |
4075 The init script can also be used for manually starting and stopping |
4074 the EtherCAT master. It has to be executed with one of the parameters |
4076 the EtherCAT master. It has to be executed with one of the parameters |
4075 \textit{start}, \textit{stop}, \textit{restart} or \textit{status}. |
4077 \textit{start}, \textit{stop}, \textit{restart} or \textit{status}. |
4076 Besides, a link to the script is placed at |
|
4077 \textit{/usr/sbin/rcethercat} for easier access. |
|
4078 |
4078 |
4079 \begin{lstlisting} |
4079 \begin{lstlisting} |
4080 host# `\textbf{/etc/init.d/ethercat restart}` |
4080 host# `\textbf{/etc/init.d/ethercat restart}` |
4081 Shutting down EtherCAT master done |
4081 Shutting down EtherCAT master done |
4082 Starting EtherCAT master done |
4082 Starting EtherCAT master done |
4085 \subsubsection{The EtherCAT Sysconfig File} |
4085 \subsubsection{The EtherCAT Sysconfig File} |
4086 \label{sec:sysconfig} |
4086 \label{sec:sysconfig} |
4087 \index{Sysconfig file} |
4087 \index{Sysconfig file} |
4088 |
4088 |
4089 For persistent configuration, the init script uses a sysconfig file |
4089 For persistent configuration, the init script uses a sysconfig file |
4090 installed to \textit{/etc/sys\-config/ethercat}, that is mandatory for |
4090 installed to \textit{etc/sysconfig/ethercat} (below the installation |
4091 the init script. The sysconfig file contains all configuration |
4091 prefix), that is mandatory for the init script. The sysconfig file |
4092 variables needed to operate a master: |
4092 contains all configuration variables needed to operate a master: |
4093 |
4093 |
4094 \begin{description} |
4094 \begin{description} |
4095 \item[DEVICE\_INDEX] This variable must contain the PCI index of the |
4095 \item[DEVICE\_INDEX] This variable must contain the PCI index of the |
4096 EtherCAT device. Setting this is mandatory for the EtherCAT init |
4096 EtherCAT device. Setting this is mandatory for the EtherCAT init |
4097 script. Default: $-1$ |
4097 script. Default: $-1$ |
4303 The current EtherCAT master code is available at~\cite{etherlab}. |
4303 The current EtherCAT master code is available at~\cite{etherlab}. |
4304 After downloading the \textit{tar.bz2} file, it has to be unpacked |
4304 After downloading the \textit{tar.bz2} file, it has to be unpacked |
4305 with the command below (or similar): |
4305 with the command below (or similar): |
4306 |
4306 |
4307 \begin{lstlisting} |
4307 \begin{lstlisting} |
4308 host> `\textbf{tar xjf ethercat-stable-1.1-r513-src.tar.bz2}` |
4308 host> `\textbf{tar xjf ethercat-1.1-rXXX.tar.bz2}` |
4309 host> `\textbf{cd ethercat-stable-1.1-r513-src}` |
4309 host> `\textbf{cd ethercat-1.1-rXXX/}` |
4310 \end{lstlisting} |
4310 \end{lstlisting} |
4311 |
4311 |
4312 For compilation, the kernel sources are needed. Basically any kernel |
4312 The tarball was created with GNU Autotools, so the build process |
4313 sources are appropriate\footnote{If a realtime extension is to be |
4313 follows the usual commands: |
4314 used, the kernel has to be patched before that.}, that are |
|
4315 configured with networking. If the host kernel is not the running |
|
4316 kernel, a copy of the configuration template has to be made: |
|
4317 |
4314 |
4318 \begin{lstlisting} |
4315 \begin{lstlisting} |
4319 host> `\textbf{cp ethercat.conf.tmpl ethercat.conf}` |
4316 host> `\textbf{./configure}` |
4320 \end{lstlisting} |
4317 host> `\textbf{make}` |
4321 |
4318 \end{lstlisting} |
4322 Now the \textit{\$KERNEL} variable inside the \textit{ethercat.conf} |
4319 |
4323 file can be adjusted to reflect the appropriate kernel version. If |
4320 The default installation prefix is \textit{/opt/etherlab}. It can be |
4324 everything is correct now, the sucessive call to |
4321 changed with the \texttt{--prefix} argument. |
|
4322 |
|
4323 Linux kernel sources are needed for compilation\footnote{If a realtime |
|
4324 extension shall to be used, the kernel should be patched before |
|
4325 compiling the EtherCAT master.}. To compile the EtherCAT master |
|
4326 modules for a different kernel than the running kernel, the target |
|
4327 kernel version can be specified with the \texttt{--with-linux} |
|
4328 argument. Example: |
4325 |
4329 |
4326 \begin{lstlisting} |
4330 \begin{lstlisting} |
|
4331 host> `\textbf{./configure --with-linux="2.6.17-ipipe"}` |
4327 host> `\textbf{make}` |
4332 host> `\textbf{make}` |
4328 \end{lstlisting} |
4333 \end{lstlisting} |
4329 |
4334 |
4330 will result in no errors. |
|
4331 |
|
4332 The following commands have to be entered as \textit{root}: To install |
4335 The following commands have to be entered as \textit{root}: To install |
4333 the kernel modules, the init script, the sysconfig file and the user |
4336 the kernel modules, headers, the init script, the sysconfig file and |
4334 space tools, the below command has to be executed: |
4337 the user space tools, the below command has to be executed: |
4335 |
4338 |
4336 \begin{lstlisting} |
4339 \begin{lstlisting} |
4337 host# `\textbf{make install}` |
4340 host# `\textbf{make install}` |
4338 \end{lstlisting} |
4341 \end{lstlisting} |
4339 |
4342 |
4340 If the sysconfig file did not exist yet, the user is notified to edit |
4343 If the EtherCAT master shall be run as a service (recommended), the |
4341 it, before running the master. For the contents of the file, see |
4344 init script and the sysconfig file have to be copied to the |
4342 section~\ref{sec:sysconfig}. To give a short summary: The most |
4345 appropriate locations. The below example is suitable for SUSE Linux. |
4343 important thing is to adjust the \textit{\$DEVICE\_INDEX} variable. It |
4346 It may vary for other distributions. |
4344 has to be set to the index of the compatible network device to use |
4347 |
|
4348 \begin{lstlisting} |
|
4349 host# `\textbf{cd /opt/etherlab}` |
|
4350 host# `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}` |
|
4351 host# `\textbf{cp etc/init.d/ethercat /etc/init.d/}` |
|
4352 host# `\textbf{insserv ethercat}` |
|
4353 \end{lstlisting} |
|
4354 |
|
4355 Now the sysconfig file has to be customized. For the contents of the |
|
4356 file, see section~\ref{sec:sysconfig}. To give a short summary: The |
|
4357 most important thing is to adjust the \textit{DEVICE\_INDEX} variable. |
|
4358 It has to be set to the index of the compatible network device to use |
4345 with EtherCAT, where the order of devices is dependent on their |
4359 with EtherCAT, where the order of devices is dependent on their |
4346 position in the PCI bus. If this is not known, the index can be |
4360 position in the PCI bus. If this is not known, the index can be |
4347 determinded with trial and error, but it has to be considered that a |
4361 determinded with trial and error, but it has to be considered that a |
4348 wrong value can cause a loss of network connection. |
4362 wrong value can cause a loss of network connection. |
4349 |
4363 |
4353 \begin{lstlisting} |
4367 \begin{lstlisting} |
4354 host# `\textbf{/etc/init.d/ethercat start}` |
4368 host# `\textbf{/etc/init.d/ethercat start}` |
4355 \end{lstlisting} |
4369 \end{lstlisting} |
4356 |
4370 |
4357 The operation of the master can be observed by looking at the |
4371 The operation of the master can be observed by looking at the |
4358 syslog\index{syslog} messages, which should look like the ones below: |
4372 syslog\index{syslog} messages, which should look like the ones below. |
|
4373 If EtherCAT slaves are connected to the master's EtherCAT device, the |
|
4374 activity indicators should begin to flash. |
4359 |
4375 |
4360 \begin{lstlisting}[numbers=left] |
4376 \begin{lstlisting}[numbers=left] |
4361 EtherCAT: Master driver, 1.1 (stable) - rev. 513, |
4377 EtherCAT: Master driver, 1.1 (stable) - rev. 513, |
4362 compiled by fp at Aug 09 2006 10:23:20 |
4378 compiled by fp at Aug 09 2006 10:23:20 |
4363 EtherCAT: Initializing 1 EtherCAT master(s)... |
4379 EtherCAT: Initializing 1 EtherCAT master(s)... |