author | Florian Pose <fp@igh-essen.com> |
Wed, 13 Aug 2008 13:19:51 +0000 | |
branch | stable-1.4 |
changeset 1627 | 22954d039fa5 |
parent 1140 | cc779f7d2496 |
child 1202 | 91d190223daa |
child 1630 | ffa89570d84f |
permissions | -rw-r--r-- |
369 | 1 |
%------------------------------------------------------------------------------ |
2 |
% |
|
3 |
% IgH EtherCAT Master Documentation |
|
4 |
% |
|
5 |
% $Id$ |
|
6 |
% |
|
1095 | 7 |
% vi: spell spelllang=en |
8 |
% |
|
369 | 9 |
%------------------------------------------------------------------------------ |
10 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
11 |
% |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
12 |
% Conventions |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
13 |
% The IgH EtherCAT Master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
14 |
% Feature Summary |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
15 |
% License |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
16 |
% Architecture |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
17 |
% Phases |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
18 |
% Behavior (Scanning) TODO |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
19 |
% Application Interface |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
20 |
% Interface version |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
21 |
% Master Requesting and Releasing |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
22 |
% Master Locking |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
23 |
% Slave configuration |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
24 |
% Configuring Pdo assignment and mapping |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
25 |
% Domains (memory) |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
26 |
% Pdo entry registration |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
27 |
% Sdo configuration |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
28 |
% Sdo access |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
29 |
% Cyclic operation |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
30 |
% Ethernet Devices |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
31 |
% Device Interface |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
32 |
% Device Modules |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
33 |
% Network Driver Basics |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
34 |
% EtherCAT Network Drivers |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
35 |
% Device Selection |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
36 |
% The Device Interface |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
37 |
% Patching Network Drivers |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
38 |
% The Master's State Machines |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
39 |
% Master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
40 |
% Slave scanning |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
41 |
% SII |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
42 |
% Pdo assign/mapping |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
43 |
% Slave configuration |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
44 |
% State change |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
45 |
% Pdo assign/mapping |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
46 |
% CoE upload/download/information |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
47 |
% Mailbox Protocol Implementations |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
48 |
% Ethernet-over-EtherCAT (EoE) |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
49 |
% CANopen-over-EtherCAT (CoE) |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
50 |
% User Space |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
51 |
% The ethercat command |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
52 |
% System Integration |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
53 |
% The EtherCAT Init Script |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
54 |
% The EtherCAT Sysconfig File |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
55 |
% Monitoring and Debugging |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
56 |
% Installation |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
57 |
% Example applications |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
58 |
% Bibliography |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
59 |
% Glossary |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
60 |
% |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
61 |
|
369 | 62 |
\documentclass[a4paper,12pt,BCOR6mm,bibtotoc,idxtotoc]{scrbook} |
63 |
||
64 |
\usepackage[latin1]{inputenc} |
|
65 |
\usepackage[automark,headsepline]{scrpage2} |
|
66 |
\usepackage{graphicx} |
|
67 |
\usepackage{makeidx} |
|
68 |
\usepackage[refpage]{nomencl} |
|
69 |
\usepackage{listings} |
|
70 |
\usepackage{svn} |
|
71 |
\usepackage{textcomp} |
|
72 |
\usepackage{url} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
73 |
\usepackage{SIunits} |
371
97f684433d3b
Improved documentation makefile, removed svn.sty, fixed LaTeX penalties.
Florian Pose <fp@igh-essen.com>
parents:
370
diff
changeset
|
74 |
\usepackage[pdfpagelabels,plainpages=false]{hyperref} |
369 | 75 |
|
76 |
\setlength{\parskip}{0.8ex plus 0.8ex minus 0.5ex} |
|
77 |
\setlength{\parindent}{0mm} |
|
78 |
||
79 |
\setcounter{secnumdepth}{\subsubsectionlevel} |
|
80 |
||
81 |
\DeclareFontShape{OT1}{cmtt}{bx}{n} |
|
82 |
{ |
|
83 |
<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10 |
|
84 |
}{} |
|
85 |
||
86 |
\lstset{basicstyle=\ttfamily\small,numberstyle=\tiny,aboveskip=4mm, |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
87 |
belowskip=2mm,escapechar=`} |
369 | 88 |
\renewcommand\lstlistlistingname{List of Listings} |
89 |
||
917
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
90 |
% Workaround for lstlistoflistings bug |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
91 |
\makeatletter% --> De-TeX-FAQ |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
92 |
\renewcommand*{\lstlistoflistings}{% |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
93 |
\begingroup |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
94 |
\if@twocolumn |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
95 |
\@restonecoltrue\onecolumn |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
96 |
\else |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
97 |
\@restonecolfalse |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
98 |
\fi |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
99 |
\lol@heading |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
100 |
\setlength{\parskip}{\z@}% |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
101 |
\setlength{\parindent}{\z@}% |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
102 |
\setlength{\parfillskip}{\z@ \@plus 1fil}% |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
103 |
\@starttoc{lol}% |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
104 |
\if@restonecol\twocolumn\fi |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
105 |
\endgroup |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
106 |
} |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
107 |
\makeatother% --> \makeatletter |
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
108 |
|
369 | 109 |
\renewcommand\nomname{Glossary} |
110 |
||
111 |
\newcommand{\IgH}{\raisebox{-0.7667ex} |
|
112 |
{\includegraphics[height=2.2ex]{images/ighsign}}} |
|
113 |
||
114 |
\SVN $Date$ |
|
115 |
\SVN $Revision$ |
|
116 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
117 |
\newcommand{\masterversion}{1.4.0} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
118 |
\newcommand{\linenum}[1]{\normalfont\textcircled{\tiny #1}} |
487 | 119 |
|
369 | 120 |
\makeindex |
917
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
121 |
\makenomenclature |
369 | 122 |
|
123 |
%------------------------------------------------------------------------------ |
|
124 |
||
125 |
\begin{document} |
|
126 |
||
127 |
\pagenumbering{roman} |
|
128 |
\pagestyle{empty} |
|
129 |
||
130 |
\begin{titlepage} |
|
131 |
\begin{center} |
|
132 |
\rule{\textwidth}{1.5mm} |
|
133 |
||
134 |
{\Huge\bf IgH \includegraphics[height=2.4ex]{images/ethercat} |
|
487 | 135 |
Master \masterversion\\[1ex] |
369 | 136 |
Documentation} |
137 |
||
138 |
\vspace{1ex} |
|
139 |
\rule{\textwidth}{1.5mm} |
|
140 |
||
141 |
\vspace{\fill} |
|
142 |
{\Large Florian Pose, \url{fp@igh-essen.com}\\[1ex] |
|
143 |
Ingenieurgemeinschaft \IgH} |
|
144 |
||
145 |
\vspace{\fill} |
|
146 |
{\Large Essen, \SVNDate\\[1ex] |
|
147 |
Revision \SVNRevision} |
|
148 |
\end{center} |
|
149 |
\end{titlepage} |
|
150 |
||
151 |
%------------------------------------------------------------------------------ |
|
152 |
||
153 |
\tableofcontents |
|
154 |
\listoftables |
|
155 |
\listoffigures |
|
156 |
\lstlistoflistings |
|
157 |
||
158 |
%------------------------------------------------------------------------------ |
|
159 |
||
160 |
\newpage |
|
161 |
\pagestyle{scrheadings} |
|
162 |
||
163 |
\section*{Conventions} |
|
164 |
\addcontentsline{toc}{section}{Conventions} |
|
165 |
\markleft{Conventions} |
|
166 |
||
167 |
The following typographic conventions are used: |
|
168 |
||
169 |
\begin{itemize} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
170 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
171 |
\item \textit{Italic face} is used for newly introduced terms and file names. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
172 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
173 |
\item \texttt{Typewriter face} is used for code examples and command line |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
174 |
output. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
175 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
176 |
\item \texttt{\textbf{Bold typewriter face}} is used for user input in command |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
177 |
lines. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
178 |
|
369 | 179 |
\end{itemize} |
180 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
181 |
Data values and addresses are usually specified as hexadecimal values. These |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
182 |
are marked in the \textit{C} programming language style with the prefix |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
183 |
\lstinline+0x+ (example: \lstinline+0x88A4+). Unless otherwise noted, address |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
184 |
values are specified as byte addresses. |
369 | 185 |
|
186 |
Function names are always printed with parentheses, but without |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
187 |
parameters. So, if a function \lstinline+ecrt_request_master()+ has |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
188 |
empty parentheses, this shall not imply that it has no parameters. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
189 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
190 |
If shell commands have to be entered, this is marked by a dollar prompt: |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
191 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
192 |
\begin{lstlisting} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
193 |
$ |
369 | 194 |
\end{lstlisting} |
195 |
||
196 |
Further, if a shell command has to be entered as the superuser, the |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
197 |
prompt is a mesh: |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
198 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
199 |
\begin{lstlisting} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
200 |
# |
369 | 201 |
\end{lstlisting} |
202 |
||
203 |
%------------------------------------------------------------------------------ |
|
204 |
||
205 |
\chapter{The IgH EtherCAT Master} |
|
206 |
\label{chapter:master} |
|
207 |
\pagenumbering{arabic} |
|
208 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
209 |
This chapter covers some general information about the EtherCAT master. |
369 | 210 |
|
211 |
%------------------------------------------------------------------------------ |
|
212 |
||
213 |
\section{Feature Summary} |
|
214 |
\label{sec:summary} |
|
215 |
\index{Master!Features} |
|
216 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
217 |
The list below gives a short summary of the master features. |
369 | 218 |
|
219 |
\begin{itemize} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
220 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
221 |
\item Designed as a kernel module for Linux 2.6. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
222 |
|
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
223 |
\item Implemented according to IEC 61158-12 \cite{dlspec} \cite{alspec}. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
224 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
225 |
\item Comes with EtherCAT-capable drivers for several common Ethernet devices. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
226 |
|
369 | 227 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
228 |
|
369 | 229 |
\item The Ethernet hardware is operated without interrupts. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
230 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
231 |
\item Drivers for additional Ethernet hardware can easily be implemented |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
232 |
using the common device interface (see section~\ref{sec:ecdev}) provided by |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
233 |
the master module. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
234 |
|
369 | 235 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
236 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
237 |
\item The master module supports multiple EtherCAT masters running in |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
238 |
parallel. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
239 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
240 |
\item The master code supports any Linux realtime extension through its |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
241 |
independent architecture. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
242 |
|
369 | 243 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
244 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
245 |
\item RTAI\nomenclature{RTAI}{Realtime Application Interface}, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
246 |
ADEOS\nomenclature{ADEOS}{Adaptive Domain Environment for Operating |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
247 |
Systems}, etc. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
248 |
|
369 | 249 |
\item It runs well even without realtime extensions. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
250 |
|
369 | 251 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
252 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
253 |
\item Common ``realtime interface'' for applications, that want to use |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
254 |
EtherCAT functionality (see section~\ref{sec:ecrt}). |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
255 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
256 |
\item \textit{Domains} are introduced, to allow grouping of process |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
257 |
data transfers with different slave groups and task periods. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
258 |
|
369 | 259 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
260 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
261 |
\item Handling of multiple domains with different task periods. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
262 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
263 |
\item Automatic calculation of process data mapping, FMMU and sync manager |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
264 |
configuration within each domain. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
265 |
|
369 | 266 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
267 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
268 |
\item Communication through several finite state machines. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
269 |
|
369 | 270 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
271 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
272 |
\item Automatic bus scanning after topology changes. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
273 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
274 |
\item Bus monitoring during operation. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
275 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
276 |
\item Automatic reconfiguration of slaves (for example after power failure) |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
277 |
during operation. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
278 |
|
369 | 279 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
280 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
281 |
\item CANopen-over-EtherCAT (CoE) |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
282 |
|
369 | 283 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
284 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
285 |
\item Sdo upload, download and information service. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
286 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
287 |
\item Slave configuration via Sdos. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
288 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
289 |
\item Sdo access from user-space and from the application. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
290 |
|
369 | 291 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
292 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
293 |
\item Ethernet-over-EtherCAT (EoE) |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
294 |
|
369 | 295 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
296 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
297 |
\item Transparent use of EoE slaves via virtual network interfaces. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
298 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
299 |
\item Natively supports either a switched or a routed EoE network |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
300 |
architecture. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
301 |
|
369 | 302 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
303 |
|
1140
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
304 |
\item User space command-line-tool ``ethercat`` (see |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
305 |
section~\ref{sec:ethercat}) |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
306 |
|
369 | 307 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
308 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
309 |
\item Showing the current bus with slaves, Pdos and Sdos. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
310 |
\item Showing the bus configuration. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
311 |
\item Showing domains and process data. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
312 |
\item Setting the master's debug level. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
313 |
\item Writing alias addresses. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
314 |
\item Sdo uploading/downloading. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
315 |
\item Reading/writing a slave's SII. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
316 |
\item Setting slave states. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
317 |
\item Generate slave description XML. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
318 |
|
369 | 319 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
320 |
|
369 | 321 |
\item Seamless system integration though LSB\nomenclature{LSB}{Linux |
322 |
Standard Base} compliance. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
323 |
|
369 | 324 |
\begin{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
325 |
|
1095 | 326 |
\item Master and network device configuration via sysconfig files. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
327 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
328 |
\item Init script for master control. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
329 |
|
369 | 330 |
\end{itemize} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
331 |
|
369 | 332 |
\item Virtual read-only network interface for monitoring and debugging |
333 |
purposes. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
334 |
|
369 | 335 |
\end{itemize} |
336 |
||
337 |
%------------------------------------------------------------------------------ |
|
338 |
||
339 |
\section{License} |
|
340 |
\label{sec:license} |
|
341 |
||
342 |
The master code is released under the terms and conditions of the GNU |
|
343 |
General Public License\index{GPL} \cite{gpl} (version 2). Other |
|
344 |
developers, that want to use EtherCAT with Linux systems, are invited |
|
345 |
to use the master code or even participate on development. |
|
346 |
||
347 |
%------------------------------------------------------------------------------ |
|
348 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
349 |
\chapter{Architecture} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
350 |
\label{sec:arch} |
369 | 351 |
\index{Master!Architecture} |
352 |
||
353 |
The EtherCAT master is integrated into the Linux 2.6 kernel. This was |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
354 |
an early design decision, which has been made for several reasons: |
369 | 355 |
|
356 |
\begin{itemize} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
357 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
358 |
\item Kernel code has significantly better realtime characteristics, i.~e. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
359 |
less latency than user space code. It was foreseeable, that a fieldbus master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
360 |
has a lot of cyclic work to do. Cyclic work is usually triggered by timer |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
361 |
interrupts inside the kernel. The execution delay of a function that processes |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
362 |
timer interrupts is less, when it resides in kernel space, because there is no |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
363 |
need of time-consuming context switches to a user space process. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
364 |
|
369 | 365 |
\item It was also foreseeable, that the master code has to directly |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
366 |
communicate with the Ethernet hardware. This has to be done in the kernel |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
367 |
anyway (through network device drivers), which is one more reason for the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
368 |
master code being in kernel space. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
369 |
|
369 | 370 |
\end{itemize} |
371 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
372 |
Figure~\ref{fig:arch} gives a general overview of the master architecture. |
369 | 373 |
|
374 |
\begin{figure}[htbp] |
|
375 |
\centering |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
376 |
\includegraphics[width=.9\textwidth]{images/architecture} |
369 | 377 |
\caption{Master architecture} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
378 |
\label{fig:arch} |
369 | 379 |
\end{figure} |
380 |
||
381 |
\paragraph{Master Module} |
|
382 |
\index{Master module} |
|
383 |
||
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
384 |
Kernel module containing one or more EtherCAT master instances (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
385 |
section~\ref{sec:mastermod}), the ``Device Interface'' (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
386 |
section~\ref{sec:ecdev}) and the ``Realtime Interface'' (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
387 |
section~\ref{sec:ecrt}). |
369 | 388 |
|
389 |
\paragraph{Device Modules} |
|
390 |
\index{Device modules} |
|
391 |
||
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
392 |
EtherCAT-capable Ethernet device driver modules\index{Device modules}, that |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
393 |
offer their devices to the EtherCAT master via the device interface (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
394 |
section~\ref{sec:ecdev}). These modified network drivers can handle network |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
395 |
devices used for EtherCAT operation and ``normal'' Ethernet devices in |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
396 |
parallel. A master can accept a certain device and then is able to send and |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
397 |
receive EtherCAT frames. Ethernet devices declined by the master module are |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
398 |
connected to the kernel's network stack as usual. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
399 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
400 |
\paragraph{Application Modules} |
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
401 |
\index{Application module} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
402 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
403 |
Kernel modules, that use the EtherCAT master (usually for cyclic exchange of |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
404 |
process data with EtherCAT slaves). These modules are not part of the EtherCAT |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
405 |
master code\footnote{Although there are some examples provided in the |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
406 |
\textit{examples} directory, see chapter~\ref{chapter:examples}}, but have to |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
407 |
be generated or written by the user. An application module can ``request'' a |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
408 |
master through the realtime interface (see section~\ref{sec:ecrt}). If this |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
409 |
succeeds, the module has the control over the master: It can provide a bus |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
410 |
configuration and exchange process data. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
411 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
412 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
413 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
414 |
\section{Phases} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
415 |
\index{Master phases} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
416 |
|
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
417 |
The EtherCAT master runs through several phases (see fig.~\ref{fig:phases}): |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
418 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
419 |
\begin{figure}[htbp] |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
420 |
\centering |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
421 |
\includegraphics[width=.9\textwidth]{images/phases} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
422 |
\caption{Master phases and transitions} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
423 |
\label{fig:phases} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
424 |
\end{figure} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
425 |
\begin{description} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
426 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
427 |
\item[Orphaned phase]\index{Orphaned phase} This mode takes effect, when the |
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
428 |
master still waits for its Ethernet device to connect. No bus communication is |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
429 |
possible until then. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
430 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
431 |
\item[Idle phase]\index{Idle phase} takes effect when the master has accepted |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
432 |
an Ethernet device, but is not requested by any application yet. The master |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
433 |
runs its state machine (see section~\ref{sec:fsm-master}), that automatically |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
434 |
scans the bus for slaves and executes pending operations from the user space |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
435 |
interface (for example Sdo access). The command-line tool can be used to access |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
436 |
the bus, but there is no process data exchange because of the missing bus |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
437 |
configuration. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
438 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
439 |
\item[Operation phase]\index{Operation phase} The master is requested by an |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
440 |
application that can provide a bus configuration and exchange process data. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
441 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
442 |
\end{description} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
443 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
444 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
445 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
446 |
\section{General behavior} % FIXME |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
447 |
\index{Master behavior} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
448 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
449 |
\ldots |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
450 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
451 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
452 |
|
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
453 |
\section{Master Module} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
454 |
\label{sec:mastermodule} |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
455 |
\index{Master module} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
456 |
|
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
457 |
The EtherCAT master kernel module \textit{ec\_master} can contain multiple |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
458 |
master instances. Each master waits for a certain Ethernet device identified |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
459 |
by its MAC address\index{MAC address}. These addresses have to be specified on |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
460 |
module loading via the \textit{main\_devices} module parameter. The number of |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
461 |
master instances to initialize is taken from the number of MAC addresses |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
462 |
given. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
463 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
464 |
The below command loads the master module with a single master instance that |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
465 |
waits for the Ethernet device with the MAC address |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
466 |
\lstinline+00:0E:0C:DA:A2:20+. The master will be accessible via index $0$. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
467 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
468 |
\begin{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
469 |
# `\textbf{modprobe ec\_master main\_devices=00:0E:0C:DA:A2:20}` |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
470 |
\end{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
471 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
472 |
MAC addresses for multiple masters have to be separated by commas: |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
473 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
474 |
\begin{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
475 |
# `\textbf{modprobe ec\_master main\_devices=00:0E:0C:DA:A2:20,00:e0:81:71:d5:1c}` |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
476 |
\end{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
477 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
478 |
The two masters can be addressed by their indices 0 and 1 respectively (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
479 |
figure~\ref{fig:masters}). The master index is needed for the |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
480 |
\lstinline+ecrt_master_request()+ function of the realtime interface (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
481 |
section~\ref{sec:ecrt}) and the \lstinline+--master+ option of the |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
482 |
\textit{ethercat} command-line tool (see section~\ref{sec:ethercat}), which |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
483 |
defaults to $0$. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
484 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
485 |
\begin{figure}[htbp] |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
486 |
\centering |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
487 |
\includegraphics[width=.5\textwidth]{images/masters} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
488 |
\caption{Multiple masters in one module} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
489 |
\label{fig:masters} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
490 |
\end{figure} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
491 |
|
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
492 |
\paragraph{Init script} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
493 |
\index{Init script} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
494 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
495 |
Most probably you won't want to load the master module and the Ethernet driver |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
496 |
modules manually, but start the master as a service. See |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
497 |
section~\ref{sec:system} on how to do this. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
498 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
499 |
\paragraph{Syslog} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
500 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
501 |
The master module outputs information about it's state and events to the |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
502 |
kernel ring buffer. These also end up in the system logs. The above module |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
503 |
loading command should result in the messages below: |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
504 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
505 |
\begin{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
506 |
# `\textbf{dmesg | tail -2}` |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
507 |
EtherCAT: Master driver `\masterversion` |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
508 |
EtherCAT: 2 masters waiting for devices. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
509 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
510 |
# `\textbf{tail -2 /var/log/messages}` |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
511 |
Jul 4 10:22:45 ethercat kernel: EtherCAT: Master driver `\masterversion` |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
512 |
Jul 4 10:22:45 ethercat kernel: EtherCAT: 2 masters waiting |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
513 |
for devices. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
514 |
\end{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
515 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
516 |
All EtherCAT master output is prefixed with \lstinline+EtherCAT+ which makes |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
517 |
searching the logs easier. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
518 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
519 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
520 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
521 |
\section{Handling of Process Data} % FIXME |
369 | 522 |
\label{sec:processdata} |
523 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
524 |
\ldots |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
525 |
|
369 | 526 |
\paragraph{Process Data Image} |
527 |
\index{Process data} |
|
528 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
529 |
The slaves offer their inputs and outputs by presenting the master so-called |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
530 |
``Process Data Objects'' (Pdos\index{Pdo}). The available Pdos can be |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
531 |
determined by reading out the slave's TXPDO and RXPDO E$^2$PROM categories. The |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
532 |
application can register the Pdos for data exchange during cyclic operation. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
533 |
The sum of all registered Pdos defines the ``process data image'', which is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
534 |
exchanged via the ``Logical ReadWrite'' datagrams introduced |
369 | 535 |
in~\cite[section~5.4.2.4]{dlspec}. |
536 |
||
537 |
\paragraph{Process Data Domains} |
|
538 |
\index{Domain} |
|
539 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
540 |
The process data image can be easily managed by creating so-called |
814 | 541 |
``domains'', which group Pdos and allocate the datagrams needed to |
369 | 542 |
exchange them. Domains are mandatory for process data exchange, so |
543 |
there has to be at least one. They were introduced for the following |
|
544 |
reasons: |
|
545 |
||
546 |
\begin{itemize} |
|
547 |
\item The maximum size of a ``Logical ReadWrite'' datagram is limited |
|
548 |
due to the limited size of an Ethernet frame: The maximum data size |
|
549 |
is the Ethernet data field size minus the EtherCAT frame header, |
|
550 |
EtherCAT datagram header and EtherCAT datagram footer: $1500 - 2 - |
|
551 |
12 - 2 = 1484$ octets. If the size of the process data image exceeds |
|
552 |
this limit, multiple frames have to be sent, and the image has to be |
|
553 |
partitioned for the use of multiple datagrams. A domain manages this |
|
554 |
automatically. |
|
814 | 555 |
\item Not every Pdo has to be exchanged with the same frequency: The |
556 |
values of Pdos can vary slowly over time (for example temperature |
|
369 | 557 |
values), so exchanging them with a high frequency would just waste |
558 |
bus bandwidth. For this reason, multiple domains can be created, to |
|
814 | 559 |
group different Pdos and so allow separate exchange. |
369 | 560 |
\end{itemize} |
561 |
||
562 |
There is no upper limit for the number of domains, but each domain |
|
563 |
occupies one FMMU in each slave involved, so the maximum number of |
|
564 |
domains is also limited by the slaves' capabilities. |
|
565 |
||
566 |
\paragraph{FMMU Configuration} |
|
567 |
\index{FMMU!Configuration} |
|
568 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
569 |
An application can register Pdos for process data exchange. Every |
814 | 570 |
Pdo is part of a memory area in the slave's physical memory, that is |
369 | 571 |
protected by a sync manager \cite[section~6.7]{dlspec} for |
572 |
synchronized access. In order to make a sync manager react on a |
|
573 |
datagram accessing its memory, it is necessary to access the last byte |
|
574 |
covered by the sync manager. Otherwise the sync manager will not react |
|
575 |
on the datagram and no data will be exchanged. That is why the whole |
|
576 |
synchronized memory area has to be included into the process data |
|
814 | 577 |
image: For example, if a certain Pdo of a slave is registered for |
369 | 578 |
exchange with a certain domain, one FMMU will be configured to map the |
814 | 579 |
complete sync-manager-protected memory, the Pdo resides in. If a |
580 |
second Pdo of the same slave is registered for process data exchange |
|
581 |
within the same domain, and this Pdo resides in the same |
|
582 |
sync-manager-protected memory as the first Pdo, the FMMU configuration |
|
369 | 583 |
is not touched, because the appropriate memory is already part of the |
814 | 584 |
domain's process data image. If the second Pdo belongs to another |
369 | 585 |
sync-manager-protected area, this complete area is also included into |
586 |
the domains process data image. See figure~\ref{fig:fmmus} for an |
|
587 |
overview, how FMMU's are configured to map physical memory to logical |
|
588 |
process data images. |
|
589 |
||
590 |
\begin{figure}[htbp] |
|
591 |
\centering |
|
592 |
\includegraphics[width=\textwidth]{images/fmmus} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
593 |
\caption{FMMU configuration for several domains} |
369 | 594 |
\label{fig:fmmus} |
595 |
\end{figure} |
|
596 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
597 |
\paragraph{Process Data Pointers} % FIXME |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
598 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
599 |
The figure also demonstrates the way, the application can access the exchanged |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
600 |
process data: At Pdo registration, the application has to provide the address |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
601 |
of a process data pointer. Upon calculation of the domain image and allocation |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
602 |
of process data memory, this pointer is redirected to the appropriate location |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
603 |
inside the domain's process data memory and can later be easily dereferenced by |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
604 |
the module code. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
605 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
606 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
607 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
608 |
\chapter{Application Interface} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
609 |
\label{sec:ecrt} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
610 |
\index{Application interface} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
611 |
|
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
612 |
The application interface provides functions and data structures for |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
613 |
applications to access and use an EtherCAT master. The complete documentation |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
614 |
of the interface is included as Doxygen~\cite{doxygen} comments in the header |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
615 |
file \textit{include/ecrt.h}. You can either directly view the file comments |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
616 |
or generate an HTML documentation as described in section~\ref{sec:gendoc}. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
617 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
618 |
The following sections cover a general description of the application |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
619 |
interface. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
620 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
621 |
Every application should use the master in two steps: |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
622 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
623 |
\begin{description} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
624 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
625 |
\item[Configuration] The master is requested and the configuration is applied. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
626 |
Domains are created Slaves are configured and Pdo entries are registered (see |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
627 |
section~\ref{sec:masterconfig}). |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
628 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
629 |
\item[Operation] Cyclic code is run, process data is exchanged (see |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
630 |
section~\ref{sec:cyclic}). |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
631 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
632 |
\end{description} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
633 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
634 |
%------------------------------------------------------------------------------ |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
635 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
636 |
\section{Master Configuration} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
637 |
\label{sec:masterconfig} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
638 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
639 |
\ldots |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
640 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
641 |
\begin{figure}[htbp] |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
642 |
\centering |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
643 |
\includegraphics[width=.8\textwidth]{images/app-config} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
644 |
\caption{Master configuration structures} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
645 |
\label{fig:app-config} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
646 |
\end{figure} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
647 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
648 |
%------------------------------------------------------------------------------ |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
649 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
650 |
\section{Cyclic Operation} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
651 |
\label{sec:cyclic} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
652 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
653 |
\ldots |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
654 |
% FIXME PDOS endianess |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
655 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
656 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
657 |
%------------------------------------------------------------------------------ |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
658 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
659 |
\section{Concurrent Master Access} % FIXME |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
660 |
\label{sec:concurr} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
661 |
\index{Concurrency} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
662 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
663 |
In some cases, one master is used by several instances, for example when an |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
664 |
application does cyclic process data exchange, and there are EoE-capable slaves |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
665 |
that require to exchange Ethernet data with the kernel (see |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
666 |
section~\ref{sec:eoeimp}). For this reason, the master is a shared resource, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
667 |
and access to it has to be sequentialized. This is usually done by locking with |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
668 |
semaphores, or other methods to protect critical sections. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
669 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
670 |
The master itself can not provide locking mechanisms, because it has no chance |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
671 |
to know the appropriate kind of lock. Imagine, the application uses RTAI |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
672 |
functionality, then ordinary kernel semaphores would not be sufficient. For |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
673 |
that, an important design decision was made: The application that reserved a |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
674 |
master must have the total control, therefore it has to take responsibility for |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
675 |
providing the appropriate locking mechanisms. If another instance wants to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
676 |
access the master, it has to request the master lock by callbacks, that have to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
677 |
be set by the application. Moreover the application can deny access to the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
678 |
master if it considers it to be awkward at the moment. |
369 | 679 |
|
680 |
\begin{figure}[htbp] |
|
681 |
\centering |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
682 |
\includegraphics[width=.6\textwidth]{images/master-locks} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
683 |
\caption{Concurrent master access} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
684 |
\label{fig:locks} |
369 | 685 |
\end{figure} |
686 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
687 |
Figure~\ref{fig:locks} exemplary shows, how two processes share one master: The |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
688 |
application's cyclic task uses the master for process data exchange, while the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
689 |
master-internal EoE process uses it to communicate with EoE-capable slaves. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
690 |
Both have to acquire the master lock before access: The application task can |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
691 |
access the lock natively, while the EoE process has to use the callbacks. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
692 |
Section~\ref{sec:concurrency} gives an example, of how to implement this. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
693 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
694 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
695 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
696 |
\chapter{Ethernet devices} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
697 |
\label{sec:devices} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
698 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
699 |
The EtherCAT protocol is based on the Ethernet standard. That's why the master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
700 |
relies on standard Ethernet hardware to communicate with the bus. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
701 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
702 |
The term \textit{device} is used as a synonym for Ethernet network interface |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
703 |
hardware. There are device driver modules that handle Ethernet hardware, which |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
704 |
the master can use to connect to an EtherCAT bus. |
369 | 705 |
|
706 |
Section~\ref{sec:networkdrivers} offers an overview of general Linux |
|
707 |
network driver modules, while section~\ref{sec:requirements} will show |
|
708 |
the requirements to an EtherCAT-enabled network driver. Finally, |
|
709 |
sections~\ref{sec:seldev} to~\ref{sec:patching} show how to fulfill |
|
710 |
these requirements and implement such a driver module. |
|
711 |
||
712 |
%------------------------------------------------------------------------------ |
|
713 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
714 |
\section{Network Driver Basics} |
369 | 715 |
\label{sec:networkdrivers} |
716 |
\index{Network drivers} |
|
717 |
||
718 |
EtherCAT relies on Ethernet hardware and the master needs a physical |
|
719 |
Ethernet device to communicate with the bus. Therefore it is necessary |
|
720 |
to understand how Linux handles network devices and their drivers, |
|
721 |
respectively. |
|
722 |
||
723 |
\paragraph{Tasks of a Network Driver} |
|
724 |
||
1095 | 725 |
Network device drivers usually handle the lower two layers of the OSI model, |
726 |
that is the physical layer and the data-link layer. A network device itself |
|
727 |
natively handles the physical layer issues: It represents the hardware to |
|
728 |
connect to the medium and to send and receive data in the way, the physical |
|
729 |
layer protocol describes. The network device driver is responsible for getting |
|
730 |
data from the kernel's networking stack and forwarding it to the hardware, |
|
731 |
that does the physical transmission. If data is received by the hardware |
|
732 |
respectively, the driver is notified (usually by means of an interrupt) and |
|
733 |
has to read the data from the hardware memory and forward it to the network |
|
734 |
stack. There are a few more tasks, a network device driver has to handle, |
|
735 |
including queue control, statistics and device dependent features. |
|
369 | 736 |
|
737 |
\paragraph{Driver Startup} |
|
738 |
||
739 |
Usually, a driver searches for compatible devices on module loading. |
|
740 |
For PCI drivers, this is done by scanning the PCI bus and checking for |
|
741 |
known device IDs. If a device is found, data structures are allocated |
|
742 |
and the device is taken into operation. |
|
743 |
||
744 |
\paragraph{Interrupt Operation} |
|
745 |
\index{Interrupt} |
|
746 |
||
747 |
A network device usually provides a hardware interrupt that is used to |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
748 |
notify the driver of received frames and success of transmission, or |
369 | 749 |
errors, respectively. The driver has to register an interrupt service |
750 |
routine (ISR\index{ISR}\nomenclature{ISR}{Interrupt Service Routine}), |
|
751 |
that is executed each time, the hardware signals such an event. If the |
|
752 |
interrupt was thrown by the own device (multiple devices can share one |
|
753 |
hardware interrupt), the reason for the interrupt has to be determined |
|
754 |
by reading the device's interrupt register. For example, if the flag |
|
755 |
for received frames is set, frame data has to be copied from hardware |
|
756 |
to kernel memory and passed to the network stack. |
|
757 |
||
758 |
\paragraph{The net\_device structure} |
|
759 |
\index{net\_device} |
|
760 |
||
761 |
The driver registers a \textit{net\_device} structure for each device |
|
762 |
to communicate with the network stack and to create a ``network |
|
763 |
interface''. In case of an Ethernet driver, this interface appears as |
|
764 |
\textit{ethX}, where X is a number assigned by the kernel on |
|
765 |
registration. The \textit{net\_device} structure receives events |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
766 |
(either from user space or from the network stack) via several |
369 | 767 |
callbacks, which have to be set before registration. Not every |
768 |
callback is mandatory, but for reasonable operation the ones below are |
|
769 |
needed in any case: |
|
770 |
||
771 |
\begin{description} |
|
1095 | 772 |
|
773 |
\item[open()] This function is called when network communication has to be |
|
774 |
started, for example after a command \textit{ifconfig ethX up} from user |
|
775 |
space. Frame reception has to be enabled by the driver. |
|
776 |
||
777 |
\item[stop()] The purpose of this callback is to ``close'' the device, i.~e. |
|
778 |
make the hardware stop receiving frames. |
|
779 |
||
780 |
\item[hard\_start\_xmit()] This function is cal\-led for each frame that has |
|
781 |
to be transmitted. The network stack passes the frame as a pointer to an |
|
782 |
\textit{sk\_buff} structure (``socket buffer''\index{Socket buffer}, see |
|
783 |
below), which has to be freed after sending. |
|
784 |
||
785 |
\item[get\_stats()] This call has to return a pointer to the device's |
|
786 |
\textit{net\_device\_stats} structure, which permanently has to be filled with |
|
787 |
frame statistics. This means, that every time a frame is received, sent, or an |
|
788 |
error happened, the appropriate counter in this structure has to be increased. |
|
789 |
||
790 |
\end{description} |
|
791 |
||
792 |
The actual registration is done with the \lstinline+register_netdev()+ call, |
|
793 |
unregistering is done with \lstinline+unregister_netdev()+. |
|
369 | 794 |
|
795 |
\paragraph{The netif Interface} |
|
796 |
\index{netif} |
|
797 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
798 |
All other communication in the direction interface $\to$ network stack is done |
1095 | 799 |
via the \lstinline+netif_*()+ calls. For example, on successful device |
800 |
opening, the network stack has to be notified, that it can now pass frames to |
|
801 |
the interface. This is done by calling \lstinline+netif_start_queue()+. After |
|
802 |
this call, the \lstinline+hard_start_xmit()+ callback can be called by the |
|
803 |
network stack. Furthermore a network driver usually manages a frame |
|
804 |
transmission queue. If this gets filled up, the network stack has to be told |
|
805 |
to stop passing further frames for a while. This happens with a call to |
|
806 |
\lstinline+netif_stop_queue()+. If some frames have been sent, and there is |
|
807 |
enough space again to queue new frames, this can be notified with |
|
808 |
\lstinline+netif_wake_queue()+. Another important call is |
|
809 |
\lstinline+netif_receive_skb()+\footnote{This function is part of the NAPI |
|
810 |
(``New API''), that replaces the kernel 2.4 technique for interfacing to the |
|
811 |
network stack (with \lstinline+netif_rx()+). NAPI is a technique to improve |
|
812 |
network performance on Linux. Read more in |
|
813 |
\url{http://www.cyberus.ca/~hadi/usenix-paper.tgz}.}: It passes a frame to the |
|
814 |
network stack, that was just received by the device. Frame data has to be |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
815 |
packed into a so-called ``socket buffer'' for that (see below). |
369 | 816 |
|
817 |
\paragraph{Socket Buffers} |
|
818 |
\index{Socket buffer} |
|
819 |
||
1095 | 820 |
Socket buffers are the basic data type for the whole network stack. They |
821 |
serve as containers for network data and are able to quickly add data headers |
|
822 |
and footers, or strip them off again. Therefore a socket buffer consists of an |
|
823 |
allocated buffer and several pointers that mark beginning of the buffer |
|
824 |
(\textit{head}), beginning of data (\textit{data}), end of data |
|
825 |
(\textit{tail}) and end of buffer (\textit{end}). In addition, a socket buffer |
|
826 |
holds network header information and (in case of received data) a pointer to |
|
827 |
the \textit{net\_device}, it was received on. There exist functions that |
|
828 |
create a socket buffer (\lstinline+dev_alloc_skb()+), add data either from |
|
829 |
front (\lstinline+skb_push()+) or back (\lstinline+skb_put()+), remove data |
|
830 |
from front (\lstinline+skb_pull()+) or back (\lstinline+skb_trim()+), or |
|
831 |
delete the buffer (\lstinline+kfree_skb()+). A socket buffer is passed from |
|
832 |
layer to layer, and is freed by the layer that uses it the last time. In case |
|
833 |
of sending, freeing has to be done by the network driver. |
|
369 | 834 |
|
835 |
%------------------------------------------------------------------------------ |
|
836 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
837 |
\section{EtherCAT Device Drivers} |
369 | 838 |
\label{sec:requirements} |
839 |
||
1095 | 840 |
There are a few requirements for Ethernet network devices to function as |
841 |
EtherCAT devices, when connected to an EtherCAT bus. |
|
369 | 842 |
|
843 |
\paragraph{Dedicated Interfaces} |
|
844 |
||
1095 | 845 |
For performance and realtime purposes, the EtherCAT master needs direct and |
846 |
exclusive access to the Ethernet hardware. This implies that the network |
|
847 |
device must not be connected to the kernel's network stack as usual, because |
|
848 |
the kernel would try to use it as an ordinary Ethernet device. |
|
369 | 849 |
|
850 |
\paragraph{Interrupt-less Operation} |
|
851 |
\index{Interrupt} |
|
852 |
||
1095 | 853 |
EtherCAT frames travel through the logical EtherCAT ring and are then sent |
854 |
back to the master. Communication is highly deterministic: A frame is sent and |
|
855 |
will be received again after a constant time. Therefore, there is no need to |
|
856 |
notify the driver about frame reception: The master can instead query the |
|
857 |
hardware for received frames. |
|
858 |
||
859 |
Figure~\ref{fig:interrupt} shows two workflows for cyclic frame transmission |
|
860 |
and reception with and without interrupts. |
|
369 | 861 |
|
862 |
\begin{figure}[htbp] |
|
863 |
\centering |
|
864 |
\includegraphics[width=.8\textwidth]{images/interrupt} |
|
865 |
\caption{Interrupt Operation versus Interrupt-less Operation} |
|
866 |
\label{fig:interrupt} |
|
867 |
\end{figure} |
|
868 |
||
1095 | 869 |
In the left workflow ``Interrupt Operation'', the data from the last cycle is |
870 |
first processed and a new frame is assembled with new datagrams, which is then |
|
871 |
sent. The cyclic work is done for now. Later, when the frame is received |
|
872 |
again by the hardware, an interrupt is triggered and the ISR is executed. The |
|
873 |
ISR will fetch the frame data from the hardware and initiate the frame |
|
874 |
dissection: The datagrams will be processed, so that the data is ready for |
|
875 |
processing in the next cycle. |
|
876 |
||
877 |
In the right workflow ``Interrupt-less Operation'', there is no hardware |
|
878 |
interrupt enabled. Instead, the hardware will be polled by the master by |
|
879 |
executing the ISR. If the frame has been received in the meantime, it will be |
|
880 |
dissected. The situation is now the same as at the beginning of the left |
|
881 |
workflow: The received data is processed and a new frame is assembled and |
|
882 |
sent. There is nothing to do for the rest of the cycle. |
|
883 |
||
884 |
The interrupt-less operation is desirable, because there is simply no need for |
|
885 |
an interrupt. Moreover hardware interrupts are not conducive in improving the |
|
886 |
driver's realtime behaviour: Their indeterministic incidences contribute to |
|
887 |
increasing the jitter. Besides, if a realtime extension (like RTAI) is used, |
|
888 |
some additional effort would have to be made to prioritize interrupts. |
|
369 | 889 |
|
890 |
\paragraph{Ethernet and EtherCAT Devices} |
|
891 |
||
1095 | 892 |
Another issue lies in the way Linux handles devices of the same type. For |
893 |
example, a PCI\nomenclature{PCI}{Peripheral Component Interconnect, Computer |
|
894 |
Bus} driver scans the PCI bus for devices it can handle. Then it registers |
|
895 |
itself as the responsible driver for all of the devices found. The problem is, |
|
896 |
that an unmodified driver can not be told to ignore a device because it will |
|
897 |
be used for EtherCAT later. There must be a way to handle multiple devices of |
|
898 |
the same type, where one is reserved for EtherCAT, while the other is treated |
|
369 | 899 |
as an ordinary Ethernet device. |
900 |
||
1095 | 901 |
For all this reasons, the author decided that the only acceptable solution is |
902 |
to modify standard Ethernet drivers in a way that they keep their normal |
|
903 |
functionality, but gain the ability to treat one or more of the devices as |
|
904 |
EtherCAT-capable. |
|
369 | 905 |
|
906 |
Below are the advantages of this solution: |
|
907 |
||
908 |
\begin{itemize} |
|
909 |
\item No need to tell the standard drivers to ignore certain devices. |
|
910 |
\item One networking driver for EtherCAT and non-EtherCAT devices. |
|
911 |
\item No need to implement a network driver from scratch and running |
|
912 |
into issues, the former developers already solved. |
|
913 |
\end{itemize} |
|
914 |
||
915 |
The chosen approach has the following disadvantages: |
|
916 |
||
917 |
\begin{itemize} |
|
918 |
\item The modified driver gets more complicated, as it must handle |
|
919 |
EtherCAT and non-EtherCAT devices. |
|
920 |
\item Many additional case differentiations in the driver code. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
921 |
\item Changes and bug fixes on the standard drivers have to be ported |
369 | 922 |
to the Ether\-CAT-capable versions from time to time. |
923 |
\end{itemize} |
|
924 |
||
925 |
%------------------------------------------------------------------------------ |
|
926 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
927 |
\section{Device Selection} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
928 |
\label{sec:deviceselection} |
369 | 929 |
|
930 |
After loading the master module, at least one EtherCAT-capable network |
|
931 |
driver module has to be loaded, that connects one of its devices to |
|
932 |
the master. To specify an EtherCAT device and the master to connect |
|
933 |
to, all EtherCAT-capable network driver modules should provide two |
|
934 |
module parameters: |
|
935 |
||
936 |
\begin{description} |
|
937 |
\item[ec\_device\_index] PCI device index of the device that is |
|
938 |
connected to the EtherCAT bus. If this parameter is left away, all |
|
939 |
devices found are treated as ordinary Ethernet devices. Default: |
|
940 |
$-1$ |
|
941 |
\item[ec\_master\_index] Index of the master to connect to. Default: |
|
942 |
$0$ |
|
943 |
\end{description} |
|
944 |
||
945 |
The following command loads the EtherCAT-capable RTL8139 device |
|
946 |
driver, telling it to handle the second device as an EtherCAT device |
|
947 |
and connecting it to the first master: |
|
948 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
949 |
\begin{lstlisting}[gobble=2] |
379 | 950 |
# `\textbf{modprobe ec\_8139too ec\_device\_index=1}` |
369 | 951 |
\end{lstlisting} |
952 |
||
953 |
Usually, this command does not have to be entered manually, but is |
|
954 |
called by the EtherCAT init script. See section~\ref{sec:init} for |
|
955 |
more information. |
|
956 |
||
957 |
%------------------------------------------------------------------------------ |
|
958 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
959 |
\section{The Device Interface} |
369 | 960 |
\label{sec:ecdev} |
961 |
\index{Device interface} |
|
962 |
||
963 |
An anticipation to the section about the master module |
|
964 |
(section~\ref{sec:mastermod}) has to be made in order to understand |
|
965 |
the way, a network device driver module can connect a device to a |
|
966 |
specific EtherCAT master. |
|
967 |
||
968 |
The master module provides a ``device interface'' for network device |
|
969 |
drivers. To use this interface, a network device driver module must |
|
970 |
include the header |
|
971 |
\textit{devices/ecdev.h}\nomenclature{ecdev}{EtherCAT Device}, coming |
|
972 |
with the EtherCAT master code. This header offers a function interface |
|
973 |
for EtherCAT devices which is explained below. All functions of the |
|
974 |
device interface are named with the prefix \textit{ecdev}. |
|
975 |
||
976 |
\paragraph{Device Registration} |
|
977 |
||
978 |
A network device driver can connect a physical device to an EtherCAT |
|
979 |
master with the \textit{ecdev\_register()} function. |
|
980 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
981 |
\begin{lstlisting}[gobble=2,language=C] |
369 | 982 |
ec_device_t *ecdev_register(unsigned int master_index, |
983 |
struct net_device *net_dev, |
|
984 |
ec_isr_t isr, |
|
985 |
struct module *module); |
|
986 |
\end{lstlisting} |
|
987 |
||
988 |
The first parameter \textit{master\_index} must be the index of the |
|
989 |
EtherCAT master to connect to (see section~\ref{sec:mastermod}), |
|
990 |
followed by \textit{net\_dev}, the pointer to the corresponding |
|
991 |
net\_device structure, which represents the network device to connect. |
|
992 |
The third parameter \textit{isr} must be a pointer to the interrupt |
|
993 |
service routine (ISR\index{ISR}) handling the device. The master will |
|
994 |
later execute the ISR in order to receive frames and to update the |
|
995 |
device status. The last parameter \textit{module} must be the pointer |
|
996 |
to the device driver module, which is usually accessible via the macro |
|
997 |
\textit{THIS\_MODULE} (see next paragraph). On success, the function |
|
998 |
returns a pointer to an \textit{ec\_device\_t} object, which has to be |
|
999 |
specified when calling further functions of the device interface. |
|
1000 |
Therefore the device module has to store this pointer for future use. |
|
1001 |
In error case, the \textit{ecdev\_register()} returns \textit{NULL}, |
|
1002 |
which means that the device could not be registered. The reason for |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1003 |
this is printed to \textit{Syslog}\index{Syslog}. In this case, the |
369 | 1004 |
device module is supposed to abort the module initialisation and let |
1005 |
the \textit{insmod} command fail. |
|
1006 |
||
1007 |
\paragraph{Implicit Dependencies} |
|
1008 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1009 |
The reason for the module pointer has to be specified at device registration is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1010 |
a non-trivial one: The master has to know about the module, because there will |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1011 |
be an implicit dependency between the device module and a later connected |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1012 |
application module: When an application module connects to the master, the use |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1013 |
count of the master module will be increased, so that the master module can not |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1014 |
be unloaded for the time of the connection. This is reasonable, and so |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1015 |
automatically done by the kernel. The kernel knows about this dependency, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1016 |
because the application module uses kernel symbols provided by the master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1017 |
module. Moreover it is mandatory, that the device module can be unloaded |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1018 |
neither, because it is implicitly used by the application module, too. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1019 |
Unloading it would lead to a fatal situation, because the master would have no |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1020 |
device to send and receive frames for the application. This dependency can not |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1021 |
be detected automatically, because the application module does not use any |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1022 |
symbols of the device module. Therefore the master explicitly increments the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1023 |
use counter of the connected device module upon connection of an application |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1024 |
and decrements it, if it disconnects again. In this manner, it is impossible to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1025 |
unload a device module while the master is in use. This is done with the kernel |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1026 |
function pair \textit{try\_module\_get()} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1027 |
\index{try\_module\_get@\textit{try\_module\_get()}} and \textit{module\_put()} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1028 |
\index{module\_put@\textit{module\_put()}}. The first one increases the use |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1029 |
count of a module and only fails, if the module is currently being unloaded. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1030 |
The last one decreases the use count again and never fails. Both functions take |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1031 |
a pointer to the module as their argument, which the device module therefore |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1032 |
has to specify upon device registration. |
369 | 1033 |
|
1034 |
\paragraph{Device Unregistering} |
|
1035 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1036 |
The deregistration of a device is usually done in the device module's cleanup |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1037 |
function, by calling the \textit{ecdev\_unregister()} function and specifying |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1038 |
the master index and a pointer to the device object again. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1039 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1040 |
\begin{lstlisting}[gobble=2,language=C] |
369 | 1041 |
void ecdev_unregister(unsigned int master_index, |
1042 |
ec_device_t *device); |
|
1043 |
\end{lstlisting} |
|
1044 |
||
1045 |
This function can fail too (if the master index is invalid, or the |
|
1046 |
given device was not registered), but due to the fact, that this |
|
1047 |
failure can not be dealt with appropriately, because the device module |
|
1048 |
is unloading anyway, the failure code would not be of any interest. So |
|
1049 |
the function has a void return value. |
|
1050 |
||
1051 |
\paragraph{Starting the Master} |
|
1052 |
||
1053 |
When a device has been initialized completely and is ready to send and |
|
1054 |
receive frames, the master has to be notified about this by calling |
|
1055 |
the \textit{ecdev\_start()} function. |
|
1056 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1057 |
\begin{lstlisting}[gobble=2,language=C] |
369 | 1058 |
int ecdev_start(unsigned int master_index); |
1059 |
\end{lstlisting} |
|
1060 |
||
1061 |
The master will then enter ``Idle Mode'' and start scanning the bus |
|
1062 |
(and possibly handling EoE slaves). Moreover it will make the bus |
|
1063 |
accessible via Sysfs interface and react to user interactions. The |
|
1064 |
function takes one parameter \textit{master\_index}, which has to be |
|
1065 |
the same as at the call to \textit{ecdev\_register()}. The return |
|
1066 |
value will be non-zero if the starting process failed. In this case |
|
1067 |
the device module is supposed to abort the init sequence and make the |
|
1068 |
init function return an error code. |
|
1069 |
||
1070 |
\paragraph{Stopping the Master} |
|
1071 |
||
1072 |
Before a device can be unregistered, the master has to be stopped by |
|
1073 |
calling the \textit{ecdev\_stop()} function. It will stop processing |
|
1074 |
messages of EoE slaves and leave ``Idle Mode''. The only parameter is |
|
1075 |
\textit{master\_index}. This function can not fail. |
|
1076 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1077 |
\begin{lstlisting}[gobble=2,language=C] |
369 | 1078 |
void ecdev_stop(unsigned int master_index); |
1079 |
\end{lstlisting} |
|
1080 |
||
1081 |
A subsequent call to \textit{ecdev\_unregister()} will now unregister |
|
1082 |
the device savely. |
|
1083 |
||
1084 |
\paragraph{Receiving Frames} |
|
1085 |
||
1086 |
The interrupt service routine handling device events usually has a |
|
1087 |
section where new frames are fetched from the hardware and forwarded |
|
1088 |
to the kernel network stack via \textit{netif\_receive\_skb()}. For an |
|
1089 |
EtherCAT-capable device, this has to be replaced by calling the |
|
1090 |
\textit{ecdev\_receive()} function to forward the received data to the |
|
1091 |
connected EtherCAT master instead. |
|
1092 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1093 |
\begin{lstlisting}[gobble=2,language=C] |
369 | 1094 |
void ecdev_receive(ec_device_t *device, |
1095 |
const void *data, |
|
1096 |
size_t size); |
|
1097 |
\end{lstlisting} |
|
1098 |
||
1099 |
This function takes 3 arguments, a pointer to the device object |
|
1100 |
(\textit{device}), a pointer to the received data, and the size of the |
|
1101 |
received data. The data range has to include the Ethernet headers |
|
1102 |
starting with the destination address and reach up to the last octet |
|
1103 |
of EtherCAT data, excluding the FCS. Most network devices handle the |
|
1104 |
FCS in hardware, so it is not seen by the driver code and therefore |
|
1105 |
doesn't have to be cut off manually. |
|
1106 |
||
1107 |
\paragraph{Handling the Link Status} |
|
1108 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1109 |
Information about the link status (i.~e. if there is a carrier signal detected |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1110 |
on the physical port) is also important to the master. This information is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1111 |
usually gathered by the ISR and should be forwarded to the master by calling |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1112 |
the \textit{ecdev\_link\_state()} function. The master then can react on this |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1113 |
and warn the application of a lost link. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1114 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1115 |
\begin{lstlisting}[gobble=2,language=C] |
369 | 1116 |
void ecdev_link_state(ec_device_t *device, |
1117 |
uint8_t new_state); |
|
1118 |
\end{lstlisting} |
|
1119 |
||
1120 |
The parameter \textit{device} has to be a pointer to the device object |
|
1121 |
returned by \textit{ecdev\_\-register()}. With the second parameter |
|
1122 |
\textit{new\_state}, the new link state is passed: 1, if the link went |
|
1123 |
up, and 0, if it went down. |
|
1124 |
||
1125 |
%------------------------------------------------------------------------------ |
|
1126 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1127 |
\section{Patching Network Drivers} |
369 | 1128 |
\label{sec:patching} |
1129 |
\index{Network drivers} |
|
1130 |
||
1131 |
This section will demonstrate, how to make a standard Ethernet driver |
|
1132 |
EtherCAT-capable. The below code examples are taken out of the |
|
1133 |
modified RealTek RTL8139 driver coming with the EtherCAT master |
|
1134 |
(\textit{devices/8139too.c}). The driver was originally developed by |
|
1135 |
Donald Becker, and is currently maintained by Jeff Garzik. |
|
1136 |
||
1137 |
Unfortunately, there is no standard procedure to enable an Ethernet |
|
1138 |
driver for use with the EtherCAT master, but there are a few common |
|
1139 |
techniques, that are described in this section. |
|
1140 |
||
1141 |
\begin{enumerate} |
|
1142 |
\item A first simple rule is, that \textit{netif\_*()}-calls must be |
|
1143 |
strictly avoided for all EtherCAT devices. As mentioned before, |
|
1144 |
EtherCAT devices have no connection to the network stack, and |
|
1145 |
therefore must not call its interface functions. |
|
1146 |
\item Another important thing is, that EtherCAT devices should be |
|
1147 |
operated without interrupts. So any calls of registering interrupt |
|
1148 |
handlers and enabling interrupts at hardware level must be avoided, |
|
1149 |
too. |
|
1150 |
\item The master does not use a new socket buffer for each send |
|
1151 |
operation: Instead there is a fix one allocated on master |
|
1152 |
initialization. This socket buffer is filled with an EtherCAT frame |
|
1153 |
with every send operation and passed to the |
|
1154 |
\textit{hard\_start\_xmit()} callback. For that it is necessary, |
|
1155 |
that the socket buffer is not be freed by the network driver as |
|
1156 |
usual. |
|
1157 |
\end{enumerate} |
|
1158 |
||
1159 |
As mentioned before, the driver will handle both EtherCAT and ordinary |
|
1160 |
Ethernet devices. This implies, that for each device-dependent |
|
1161 |
operation, it has to be checked if an EtherCAT device is involved, or |
|
1162 |
just an Ethernet device. For means of simplicity, this example driver |
|
1163 |
will only handle one EtherCAT device. This makes the case |
|
1164 |
differentiations easier. |
|
1165 |
||
1166 |
\paragraph{Global Variables} |
|
1167 |
||
1168 |
First of all, there have to be additional global variables declared, |
|
1169 |
as shown in the listing: |
|
1170 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1171 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1172 |
static int ec_device_index = -1; |
1173 |
static int ec_device_master_index = 0; |
|
1174 |
static ec_device_t *rtl_ec_dev; |
|
1175 |
struct net_device *rtl_ec_net_dev = NULL; |
|
1176 |
\end{lstlisting} |
|
1177 |
||
1178 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1179 |
\item[\linenum{1} -- \linenum{2}] To |
369 | 1180 |
comply to the requirements for parameters of EtherCAT device modules |
1181 |
described in section~\ref{sec:seldev}, there have to be additional |
|
1182 |
parameter variables: \textit{ec\_\-device\_\-index} holds the index |
|
1183 |
of the EtherCAT device and defaults to $-1$ (no EtherCAT device), |
|
1184 |
while \textit{ec\_device\_master\_index} stores index of the master, |
|
1185 |
the single device will be connected to. Default: $0$ |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1186 |
\item[\linenum{3}] \textit{rtl\_ec\_dev} will be |
369 | 1187 |
the pointer to the later registered RealTek EtherCAT device, which |
1188 |
can be used as a parameter for device methods. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1189 |
\item[\linenum{4}] \textit{rtl\_ec\_net\_dev} is |
369 | 1190 |
a pointer to the \textit{net\_device} structure of the dedicated |
1191 |
device and is set while scanning the PCI bus and finding the device |
|
1192 |
with the specified index. This is done inside the |
|
1193 |
\textit{pci\_module\_init()} function executed as the first thing on |
|
1194 |
module loading. |
|
1195 |
\end{description} |
|
1196 |
||
1197 |
\paragraph{Module Initialization} |
|
1198 |
||
1199 |
Below is the (shortened) coding of the device driver's module init |
|
1200 |
function: |
|
1201 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1202 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1203 |
static int __init rtl8139_init_module(void) |
1204 |
{ |
|
1205 |
if (pci_module_init(&rtl8139_pci_driver) < 0) { |
|
1206 |
printk(KERN_ERR "Failed to init PCI mod.\n"); |
|
1207 |
goto out_return; |
|
1208 |
} |
|
1209 |
||
1210 |
if (rtl_ec_net_dev) { |
|
1211 |
printk(KERN_INFO "Registering" |
|
1212 |
" EtherCAT device...\n"); |
|
1213 |
if (!(rtl_ec_dev = |
|
1214 |
ecdev_register(ec_device_master_index, |
|
1215 |
rtl_ec_net_dev, |
|
1216 |
rtl8139_interrupt, |
|
1217 |
THIS_MODULE))) { |
|
1218 |
printk(KERN_ERR "Failed to reg." |
|
1219 |
" EtherCAT device!\n"); |
|
1220 |
goto out_unreg_pci; |
|
1221 |
} |
|
1222 |
||
1223 |
printk(KERN_INFO "Starting EtherCAT" |
|
1224 |
" device...\n"); |
|
1225 |
if (ecdev_start(ec_device_master_index)) { |
|
1226 |
printk(KERN_ERR "Failed to start" |
|
1227 |
" EtherCAT device!\n"); |
|
1228 |
goto out_unreg_ec; |
|
1229 |
} |
|
1230 |
} else { |
|
1231 |
printk(KERN_WARNING "No EtherCAT device" |
|
1232 |
" registered!\n"); |
|
1233 |
} |
|
1234 |
||
1235 |
return 0; |
|
1236 |
||
1237 |
out_unreg_ec: |
|
1238 |
ecdev_unregister(ec_device_master_index, rtl_ec_dev); |
|
1239 |
out_unreg_pci: |
|
1240 |
pci_unregister_driver(&rtl8139_pci_driver); |
|
1241 |
out_return: |
|
1242 |
return -1; |
|
1243 |
} |
|
1244 |
\end{lstlisting} |
|
1245 |
||
1246 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1247 |
\item[\linenum{3}] This call initializes all |
369 | 1248 |
RTL8139-compatible devices found on the pci bus. If a device with |
1249 |
index \textit{ec\_device\_index} is found, a pointer to its |
|
1250 |
\textit{net\_device} structure is stored in |
|
1251 |
\textit{rtl\_ec\_net\_dev} for later use (see next listings). |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1252 |
\item[\linenum{8}] If the specified device was |
369 | 1253 |
found, \textit{rtl\_ec\_net\_dev} is non-zero. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1254 |
\item[\linenum{11}] The device is connected to |
369 | 1255 |
the specified master with a call to \textit{ecdev\_register()}. If |
1256 |
this fails, module loading is aborted. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1257 |
\item[\linenum{23}] The device registration was |
369 | 1258 |
successful and the master is started. This can fail, which aborts |
1259 |
module loading. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1260 |
\item[\linenum{29}] If no EtherCAT device was |
369 | 1261 |
found, a warning is output. |
1262 |
\end{description} |
|
1263 |
||
1264 |
\paragraph{Device Searching} |
|
1265 |
||
1266 |
During the PCI initialization phase, a variable \textit{board\_idx} is |
|
1267 |
increased for each RTL8139-compatible device found. The code below is |
|
1268 |
executed for each device: |
|
1269 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1270 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1271 |
if (board_idx == ec_device_index) { |
1272 |
rtl_ec_net_dev = dev; |
|
1273 |
strcpy(dev->name, "ec0"); |
|
1274 |
} |
|
1275 |
\end{lstlisting} |
|
1276 |
||
1277 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1278 |
\item[\linenum{1}] The device with the specified |
369 | 1279 |
index will be the EtherCAT device. |
1280 |
\end{description} |
|
1281 |
||
1282 |
\paragraph{Avoiding Device Registration} |
|
1283 |
||
1284 |
Later in the PCI initialization phase, the net\_devices get |
|
1285 |
registered. This has to be avoided for EtherCAT devices and so this is |
|
1286 |
a typical example for an EtherCAT case differentiation: |
|
1287 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1288 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1289 |
if (dev != rtl_ec_net_dev) { |
1290 |
i = register_netdev(dev); |
|
1291 |
if (i) goto err_out; |
|
1292 |
} |
|
1293 |
\end{lstlisting} |
|
1294 |
||
1295 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1296 |
\item[\linenum{1}] If the current net\_device is |
369 | 1297 |
not the EtherCAT device, it is registered at the network stack. |
1298 |
\end{description} |
|
1299 |
||
1300 |
\paragraph{Avoiding Interrupt Registration} |
|
1301 |
||
1302 |
In the next two listings, there is an interrupt requested and the |
|
1303 |
device's interrupts are enabled. This also has to be encapsulated by |
|
1304 |
if-clauses, because interrupt operation is not wanted for EtherCAT |
|
1305 |
devices. |
|
1306 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1307 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1308 |
if (dev != rtl_ec_net_dev) { |
1309 |
retval = request_irq(dev->irq, rtl8139_interrupt, |
|
1310 |
SA_SHIRQ, dev->name, dev); |
|
1311 |
if (retval) return retval; |
|
1312 |
} |
|
1313 |
\end{lstlisting} |
|
1314 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1315 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1316 |
if (dev != rtl_ec_net_dev) { |
1317 |
/* Enable all known interrupts by setting |
|
1318 |
the interrupt mask. */ |
|
1319 |
RTL_W16(IntrMask, rtl8139_intr_mask); |
|
1320 |
} |
|
1321 |
\end{lstlisting} |
|
1322 |
||
1323 |
\paragraph{Frame Sending} |
|
1324 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1325 |
The listing below shows an excerpt of the function representing the |
369 | 1326 |
\textit{hard\_start\_xmit()} callback of the net\_device. |
1327 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1328 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1329 |
/* Note: the chip doesn't have auto-pad! */ |
1330 |
if (likely(len < TX_BUF_SIZE)) { |
|
1331 |
if (len < ETH_ZLEN) |
|
1332 |
memset(tp->tx_buf[entry], 0, ETH_ZLEN); |
|
1333 |
skb_copy_and_csum_dev(skb, tp->tx_buf[entry]); |
|
1334 |
if (dev != rtl_ec_net_dev) { |
|
1335 |
dev_kfree_skb(skb); |
|
1336 |
} |
|
1337 |
} else { |
|
1338 |
if (dev != rtl_ec_net_dev) { |
|
1339 |
dev_kfree_skb(skb); |
|
1340 |
} |
|
1341 |
tp->stats.tx_dropped++; |
|
1342 |
return 0; |
|
1343 |
} |
|
1344 |
\end{lstlisting} |
|
1345 |
||
1346 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1347 |
\item[\linenum{6} + \linenum{10}] The |
369 | 1348 |
master uses a fixed socket buffer for transmission, which is reused |
1349 |
and may not be freed. |
|
1350 |
\end{description} |
|
1351 |
||
1352 |
\paragraph{Frame Receiving} |
|
1353 |
||
1354 |
During ordinary frame reception, a socket buffer is created and filled |
|
1355 |
with the received data. This is not necessary for an EtherCAT device: |
|
1356 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1357 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1358 |
if (dev != rtl_ec_net_dev) { |
1359 |
/* Malloc up new buffer, compatible with net-2e. */ |
|
1360 |
/* Omit the four octet CRC from the length. */ |
|
1361 |
||
1362 |
skb = dev_alloc_skb (pkt_size + 2); |
|
1363 |
if (likely(skb)) { |
|
1364 |
skb->dev = dev; |
|
1365 |
skb_reserve(skb, 2); /* 16 byte align |
|
1366 |
the IP fields. */ |
|
1367 |
eth_copy_and_sum(skb, &rx_ring[ring_off + 4], |
|
1368 |
pkt_size, 0); |
|
1369 |
skb_put(skb, pkt_size); |
|
1370 |
skb->protocol = eth_type_trans(skb, dev); |
|
1371 |
||
1372 |
dev->last_rx = jiffies; |
|
1373 |
tp->stats.rx_bytes += pkt_size; |
|
1374 |
tp->stats.rx_packets++; |
|
1375 |
||
1376 |
netif_receive_skb (skb); |
|
1377 |
} else { |
|
1378 |
if (net_ratelimit()) |
|
1379 |
printk(KERN_WARNING |
|
1380 |
"%s: Memory squeeze, dropping" |
|
1381 |
" packet.\n", dev->name); |
|
1382 |
tp->stats.rx_dropped++; |
|
1383 |
} |
|
1384 |
} else { |
|
1385 |
ecdev_receive(rtl_ec_dev, |
|
1386 |
&rx_ring[ring_offset + 4], pkt_size); |
|
1387 |
dev->last_rx = jiffies; |
|
1388 |
tp->stats.rx_bytes += pkt_size; |
|
1389 |
tp->stats.rx_packets++; |
|
1390 |
} |
|
1391 |
\end{lstlisting} |
|
1392 |
||
1393 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1394 |
\item[\linenum{28}] If the device is an EtherCAT |
369 | 1395 |
device, no socket buffer is allocated. Instead a pointer to the data |
1396 |
(which is still in the device's receive ring) is passed to the |
|
1397 |
EtherCAT master. Unnecessary copy operations are avoided. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1398 |
\item[\linenum{30} -- \linenum{32}] The |
369 | 1399 |
device's statistics are updated as usual. |
1400 |
\end{description} |
|
1401 |
||
1402 |
\paragraph{Link State} |
|
1403 |
||
1404 |
The link state (i.~e. if there is a carrier signal detected on the |
|
1405 |
receive port) is determined during execution of the ISR. The listing |
|
1406 |
below shows the different processing for Ethernet and EtherCAT |
|
1407 |
devices: |
|
1408 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1409 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1410 |
if (dev != rtl_ec_net_dev) { |
1411 |
if (tp->phys[0] >= 0) { |
|
1412 |
mii_check_media(&tp->mii, netif_msg_link(tp), |
|
1413 |
init_media); |
|
1414 |
} |
|
1415 |
} else { |
|
1416 |
void __iomem *ioaddr = tp->mmio_addr; |
|
1417 |
uint16_t link = RTL_R16(BasicModeStatus) |
|
1418 |
& BMSR_LSTATUS; |
|
1419 |
ecdev_link_state(rtl_ec_dev, link ? 1 : 0); |
|
1420 |
} |
|
1421 |
\end{lstlisting} |
|
1422 |
||
1423 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1424 |
\item[\linenum{3}] The ``media check'' is done |
369 | 1425 |
via the media independent interface (MII\nomenclature{MII}{Media |
1426 |
Independent Interface}), a standard interface for Fast Ethernet |
|
1427 |
devices. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1428 |
\item[\linenum{7} -- \linenum{10}] For |
369 | 1429 |
EtherCAT devices, the link state is fetched manually from the |
1430 |
appropriate device register, and passed to the EtherCAT master by |
|
1431 |
calling \textit{ecdev\_\-link\_\-state()}. |
|
1432 |
\end{description} |
|
1433 |
||
1434 |
\paragraph{Module Cleanup} |
|
1435 |
||
1436 |
Below is the module's cleanup function: |
|
1437 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1438 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1439 |
static void __exit rtl8139_cleanup_module (void) |
1440 |
{ |
|
1441 |
printk(KERN_INFO "Cleaning up RTL8139-EtherCAT" |
|
1442 |
" module...\n"); |
|
1443 |
||
1444 |
if (rtl_ec_net_dev) { |
|
1445 |
printk(KERN_INFO "Stopping device...\n"); |
|
1446 |
ecdev_stop(ec_device_master_index); |
|
1447 |
printk(KERN_INFO "Unregistering device...\n"); |
|
1448 |
ecdev_unregister(ec_device_master_index, |
|
1449 |
rtl_ec_dev); |
|
1450 |
rtl_ec_dev = NULL; |
|
1451 |
} |
|
1452 |
||
1453 |
pci_unregister_driver(&rtl8139_pci_driver); |
|
1454 |
||
1455 |
printk(KERN_INFO "RTL8139-EtherCAT module" |
|
1456 |
" cleaned up.\n"); |
|
1457 |
} |
|
1458 |
\end{lstlisting} |
|
1459 |
||
1460 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1461 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1462 |
\item[\linenum{6}] Stopping and deregistration is only done, if a device was |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1463 |
registered before. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1464 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1465 |
\item[\linenum{8}] The master is first stopped, so it does not access the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1466 |
device any more. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1467 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1468 |
\item[\linenum{10}] After this, the device is unregistered. The master is now |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1469 |
``orphaned''. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1470 |
|
369 | 1471 |
\end{description} |
1472 |
||
1473 |
%------------------------------------------------------------------------------ |
|
1474 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1475 |
\chapter{State Machines} |
369 | 1476 |
\label{sec:fsm} |
1477 |
\index{FSM} |
|
1478 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1479 |
Many parts of the EtherCAT master are implemented as \textit{finite state |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1480 |
machines} (FSMs\nomenclature{FSM}{Finite State Machine}). Though this leads |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1481 |
to a higher grade of complexity in some aspects, is opens many new |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1482 |
possibilities. |
369 | 1483 |
|
1484 |
The below short code example exemplary shows how to read all slave |
|
1485 |
states and moreover illustrates the restrictions of ``sequential'' |
|
1486 |
coding: |
|
1487 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1488 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1489 |
ec_datagram_brd(datagram, 0x0130, 2); // prepare datagram |
1490 |
if (ec_master_simple_io(master, datagram)) return -1; |
|
1491 |
slave_states = EC_READ_U8(datagram->data); // process datagram |
|
1492 |
\end{lstlisting} |
|
1493 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1494 |
The \textit{ec\_master\_simple\_io()} function provides a simple interface for |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1495 |
synchronously sending a single datagram and receiving the result\footnote{For |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1496 |
all communication issues have been meanwhile sourced out into state machines, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1497 |
the function is deprecated and stopped existing. Nevertheless it is adequate |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1498 |
for showing it's own restrictions.}. Internally, it queues the specified |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1499 |
datagram, invokes the \textit{ec\_master\_send\_datagrams()} function to send |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1500 |
a frame with the queued datagram and then waits actively for its reception. |
369 | 1501 |
|
1502 |
This sequential approach is very simple, reflecting in only three |
|
1503 |
lines of code. The disadvantage is, that the master is blocked for the |
|
1504 |
time it waits for datagram reception. There is no difficulty when only |
|
1505 |
one instance is using the master, but if more instances want to |
|
1506 |
(synchronously\footnote{At this time, synchronous master access will |
|
1507 |
be adequate to show the advantages of an FSM. The asynchronous |
|
1508 |
approach will be discussed in section~\ref{sec:eoeimp}}) use the |
|
1509 |
master, it is inevitable to think about an alternative to the |
|
1510 |
sequential model. |
|
1511 |
||
1512 |
Master access has to be sequentialized for more than one instance |
|
1513 |
wanting to send and receive datagrams synchronously. With the present |
|
1514 |
approach, this would result in having one phase of active waiting for |
|
1515 |
each instance, which would be non-acceptable especially in realtime |
|
1516 |
circumstances, because of the huge time overhead. |
|
1517 |
||
1518 |
A possible solution is, that all instances would be executed |
|
1519 |
sequentially to queue their datagrams, then give the control to the |
|
1520 |
next instance instead of waiting for the datagram reception. Finally, |
|
1521 |
bus IO is done by a higher instance, which means that all queued |
|
1522 |
datagrams are sent and received. The next step is to execute all |
|
1523 |
instances again, which then process their received datagrams and issue |
|
1524 |
new ones. |
|
1525 |
||
1526 |
This approach results in all instances having to retain their state, |
|
1527 |
when giving the control back to the higher instance. It is quite |
|
1528 |
obvious to use a \textit{finite state machine} model in this case. |
|
1529 |
Section~\ref{sec:fsmtheory} will introduce some of the theory used, |
|
1530 |
while the listings below show the basic approach by coding the example |
|
1531 |
from above as a state machine: |
|
1532 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1533 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1534 |
// state 1 |
1535 |
ec_datagram_brd(datagram, 0x0130, 2); // prepare datagram |
|
1536 |
ec_master_queue(master, datagram); // queue datagram |
|
1537 |
next_state = state_2; |
|
1538 |
// state processing finished |
|
1539 |
\end{lstlisting} |
|
1540 |
||
1541 |
After all instances executed their current state and queued their |
|
1542 |
datagrams, these are sent and received. Then the respective next |
|
1543 |
states are executed: |
|
1544 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1545 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1546 |
// state 2 |
1547 |
if (datagram->state != EC_DGRAM_STATE_RECEIVED) { |
|
1548 |
next_state = state_error; |
|
1549 |
return; // state processing finished |
|
1550 |
} |
|
1551 |
slave_states = EC_READ_U8(datagram->data); // process datagram |
|
1552 |
// state processing finished. |
|
1553 |
\end{lstlisting} |
|
1554 |
||
1555 |
See section~\ref{sec:statemodel} for an introduction to the |
|
1556 |
state machine programming concept used in the master code. |
|
1557 |
||
1558 |
%------------------------------------------------------------------------------ |
|
1559 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1560 |
\section{State Machine Theory} |
369 | 1561 |
\label{sec:fsmtheory} |
1562 |
\index{FSM!Theory} |
|
1563 |
||
1564 |
A finite state machine \cite{automata} is a model of behavior with |
|
1565 |
inputs and outputs, where the outputs not only depend on the inputs, |
|
1566 |
but the history of inputs. The mathematical definition of a finite |
|
1567 |
state machine (or finite automaton) is a six-tuple $(\Sigma, \Gamma, |
|
1568 |
S, s_0, \delta, \omega)$, with |
|
1569 |
||
1570 |
\begin{itemize} |
|
1571 |
\item the input alphabet $\Sigma$, with $\Sigma \neq |
|
1572 |
\emptyset$, containing all input symbols, |
|
1573 |
\item the output alphabet $\Gamma$, with $\Gamma \neq |
|
1574 |
\emptyset$, containing all output symbols, |
|
1575 |
\item the set of states $S$, with $S \neq \emptyset$, |
|
1576 |
\item the set of initial states $s_0$ with $s_0 \subseteq S, s_0 \neq |
|
1577 |
\emptyset$ |
|
1578 |
\item the transition function $\delta: S \times \Sigma \rightarrow S |
|
1579 |
\times \Gamma$ |
|
1580 |
\item the output function $\omega$. |
|
1581 |
\end{itemize} |
|
1582 |
||
1583 |
The state transition function $\delta$ is often specified by a |
|
1584 |
\textit{state transition table}, or by a \textit{state transition |
|
1585 |
diagram}. The transition table offers a matrix view of the state |
|
1586 |
machine behavior (see table~\ref{tab:statetrans}). The matrix rows |
|
1587 |
correspond to the states ($S = \{s_0, s_1, s_2\}$) and the columns |
|
1588 |
correspond to the input symbols ($\Gamma = \{a, b, \varepsilon\}$). |
|
1589 |
The table contents in a certain row $i$ and column $j$ then represent |
|
1590 |
the next state (and possibly the output) for the case, that a certain |
|
1591 |
input symbol $\sigma_j$ is read in the state $s_i$. |
|
1592 |
||
1593 |
\begin{table}[htbp] |
|
1594 |
\caption{A typical state transition table} |
|
1595 |
\label{tab:statetrans} |
|
1596 |
\vspace{2mm} |
|
1597 |
\centering |
|
1598 |
\begin{tabular}{l|ccc} |
|
1599 |
& $a$ & $b$ & $\varepsilon$\\ \hline |
|
1600 |
$s_0$ & $s_1$ & $s_1$ & $s_2$\\ |
|
1601 |
$s_1$ & $s_2$ & $s_1$ & $s_0$\\ |
|
1602 |
$s_2$ & $s_0$ & $s_0$ & $s_0$\\ \hline |
|
1603 |
\end{tabular} |
|
1604 |
\end{table} |
|
1605 |
||
1606 |
The state diagram for the same example looks like the one in |
|
1607 |
figure~\ref{fig:statetrans}. The states are represented as circles or |
|
1608 |
ellipses and the transitions are drawn as arrows between them. Close |
|
1609 |
to a transition arrow can be the condition that must be fulfilled to |
|
1610 |
allow the transition. The initial state is marked by a filled black |
|
1611 |
circle with an arrow pointing to the respective state. |
|
1612 |
||
1613 |
\begin{figure}[htbp] |
|
1614 |
\centering |
|
1615 |
\includegraphics[width=.5\textwidth]{images/statetrans} |
|
1616 |
\caption{A typical state transition diagram} |
|
1617 |
\label{fig:statetrans} |
|
1618 |
\end{figure} |
|
1619 |
||
1620 |
\paragraph{Deterministic and non-deterministic state machines} |
|
1621 |
||
1622 |
A state machine can be deterministic, meaning that for one state and |
|
1623 |
input, there is one (and only one) following state. In this case, the |
|
1624 |
state machine has exactly one starting state. Non-deterministic state |
|
1625 |
machines can have more than one transitions for a single state-input |
|
1626 |
combination. There is a set of starting states in the latter case. |
|
1627 |
||
1628 |
\paragraph{Moore and Mealy machines} |
|
1629 |
||
1630 |
There is a distinction between so-called \textit{Moore machines}, and |
|
1631 |
\textit{Mealy machines}. Mathematically spoken, the distinction lies |
|
1632 |
in the output function $\omega$: If it only depends on the current |
|
1633 |
state ($\omega: S \rightarrow \Gamma$), the machine corresponds to the |
|
1634 |
``Moore Model''. Otherwise, if $\omega$ is a function of a state and |
|
1635 |
the input alphabet ($\omega: S \times \Sigma \rightarrow \Gamma$) the |
|
1636 |
state machine corresponds to the ``Mealy model''. Mealy machines are |
|
1637 |
the more practical solution in most cases, because their design allows |
|
1638 |
machines with a minimum number of states. In practice, a mixture of |
|
1639 |
both models is often used. |
|
1640 |
||
1641 |
\paragraph{Misunderstandings about state machines} |
|
1642 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1643 |
There is a phenomenon called ``state explosion'', that is often taken as a |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1644 |
counter-argument against general use of state machines in complex environments. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1645 |
It has to be mentioned, that this point is misleading~\cite{fsmmis}. State |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1646 |
explosions happen usually as a result of a bad state machine design: Common |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1647 |
mistakes are storing the present values of all inputs in a state, or not |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1648 |
dividing a complex state machine into simpler sub state machines. The EtherCAT |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1649 |
master uses several state machines, that are executed hierarchically and so |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1650 |
serve as sub state machines. These are also described below. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1651 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1652 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1653 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1654 |
\section{The Master's State Model} |
369 | 1655 |
\label{sec:statemodel} |
1656 |
||
1657 |
This section will introduce the techniques used in the master to |
|
1658 |
implement state machines. |
|
1659 |
||
1660 |
\paragraph{State Machine Programming} |
|
1661 |
||
1662 |
There are certain ways to implement a state machine in \textit{C} |
|
1663 |
code. An obvious way is to implement the different states and actions |
|
1664 |
by one big case differentiation: |
|
1665 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1666 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1667 |
enum {STATE_1, STATE_2, STATE_3}; |
1668 |
int state = STATE_1; |
|
1669 |
||
1670 |
void state_machine_run(void *priv_data) { |
|
1671 |
switch (state) { |
|
1672 |
case STATE_1: |
|
1673 |
action_1(); |
|
1674 |
state = STATE_2; |
|
1675 |
break; |
|
1676 |
case STATE_2: |
|
1677 |
action_2() |
|
1678 |
if (some_condition) state = STATE_1; |
|
1679 |
else state = STATE_3; |
|
1680 |
break; |
|
1681 |
case STATE_3: |
|
1682 |
action_3(); |
|
1683 |
state = STATE_1; |
|
1684 |
break; |
|
1685 |
} |
|
1686 |
} |
|
1687 |
\end{lstlisting} |
|
1688 |
||
1689 |
For small state machines, this is an option. The disadvantage is, that |
|
1690 |
with an increasing number of states the code soon gets complex and an |
|
1691 |
additional case differentiation is executed each run. Besides, lots of |
|
1692 |
indentation is wasted. |
|
1693 |
||
1694 |
The method used in the master is to implement every state in an own |
|
1695 |
function and to store the current state function with a function |
|
1696 |
pointer: |
|
1697 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1698 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1699 |
void (*state)(void *) = state1; |
1700 |
||
1701 |
void state_machine_run(void *priv_data) { |
|
1702 |
state(priv_data); |
|
1703 |
} |
|
1704 |
||
1705 |
void state1(void *priv_data) { |
|
1706 |
action_1(); |
|
1707 |
state = state2; |
|
1708 |
} |
|
1709 |
||
1710 |
void state2(void *priv_data) { |
|
1711 |
action_2(); |
|
1712 |
if (some_condition) state = state1; |
|
1713 |
else state = state2; |
|
1714 |
} |
|
1715 |
||
1716 |
void state3(void *priv_data) { |
|
1717 |
action_3(); |
|
1718 |
state = state1; |
|
1719 |
} |
|
1720 |
\end{lstlisting} |
|
1721 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1722 |
In the master code, state pointers of all state machines\footnote{All except |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1723 |
for the EoE state machine, because multiple EoE slaves have to be handled in |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1724 |
parallel. For this reason each EoE handler object has its own state pointer.} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1725 |
are gathered in a single object of the \textit{ec\_fsm\_t} class. This is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1726 |
advantageous, because there is always one instance of every state machine |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1727 |
available and can be started on demand. |
369 | 1728 |
|
1729 |
\paragraph{Mealy and Moore} |
|
1730 |
||
1731 |
If a closer look is taken to the above listing, it can be seen that |
|
1732 |
the actions executed (the ``outputs'' of the state machine) only |
|
1733 |
depend on the current state. This accords to the ``Moore'' model |
|
1734 |
introduced in section~\ref{sec:fsmtheory}. As mentioned, the ``Mealy'' |
|
1735 |
model offers a higher flexibility, which can be seen in the listing |
|
1736 |
below: |
|
1737 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1738 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1739 |
void state7(void *priv_data) { |
1740 |
if (some_condition) { |
|
1741 |
action_7a(); |
|
1742 |
state = state1; |
|
1743 |
} |
|
1744 |
else { |
|
1745 |
action_7b(); |
|
1746 |
state = state8; |
|
1747 |
} |
|
1748 |
} |
|
1749 |
\end{lstlisting} |
|
1750 |
||
1751 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1752 |
\item[\linenum{3} + \linenum{7}] The |
369 | 1753 |
state function executes the actions depending on the state |
1754 |
transition, that is about to be done. |
|
1755 |
\end{description} |
|
1756 |
||
1757 |
The most flexible alternative is to execute certain actions depending |
|
1758 |
on the state, followed by some actions dependent on the state |
|
1759 |
transition: |
|
1760 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1761 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
369 | 1762 |
void state9(void *priv_data) { |
1763 |
action_9(); |
|
1764 |
if (some_condition) { |
|
1765 |
action_9a(); |
|
1766 |
state = state7; |
|
1767 |
} |
|
1768 |
else { |
|
1769 |
action_9b(); |
|
1770 |
state = state10; |
|
1771 |
} |
|
1772 |
} |
|
1773 |
\end{lstlisting} |
|
1774 |
||
1775 |
This model is oftenly used in the master. It combines the best aspects |
|
1776 |
of both approaches. |
|
1777 |
||
1778 |
\paragraph{Using Sub State Machines} |
|
1779 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1780 |
To avoid having too much states, certain functions of the EtherCAT master state |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1781 |
machine have been sourced out into sub state machines. This helps to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1782 |
encapsulate the related workflows and moreover avoids the ``state explosion'' |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1783 |
phenomenon described in section~\ref{sec:fsmtheory}. If the master would |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1784 |
instead use one big state machine, the number of states would be a multiple of |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1785 |
the actual number. This would increase the level of complexity to a |
369 | 1786 |
non-manageable grade. |
1787 |
||
1788 |
\paragraph{Executing Sub State Machines} |
|
1789 |
||
1790 |
If a state machine starts to execute a sub state machine, it usually |
|
1791 |
remains in one state until the sub state machine terminates. This is |
|
1792 |
usually done like in the listing below, which is taken out of the |
|
1793 |
slave configuration state machine code: |
|
1794 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1795 |
\begin{lstlisting}[gobble=2,language=C,numbers=left] |
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
1796 |
void ec_fsm_slaveconf_safeop(ec_fsm_t *fsm) |
369 | 1797 |
{ |
1798 |
fsm->change_state(fsm); // execute state change |
|
1799 |
// sub state machine |
|
1800 |
||
1801 |
if (fsm->change_state == ec_fsm_error) { |
|
1802 |
fsm->slave_state = ec_fsm_end; |
|
1803 |
return; |
|
1804 |
} |
|
1805 |
||
1806 |
if (fsm->change_state != ec_fsm_end) return; |
|
1807 |
||
1808 |
// continue state processing |
|
1809 |
... |
|
1810 |
\end{lstlisting} |
|
1811 |
||
1812 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1813 |
\item[\linenum{3}] \textit{change\_state} is the |
369 | 1814 |
state pointer of the state change state machine. The state function, |
1815 |
the pointer points on, is executed\ldots |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1816 |
\item[\linenum{6}] \ldots either until the state |
369 | 1817 |
machine terminates with the error state \ldots |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1818 |
\item[\linenum{11}] \ldots or until the state |
369 | 1819 |
machine terminates in the end state. Until then, the ``higher'' |
1820 |
state machine remains in the current state and executes the sub |
|
1821 |
state machine again in the next cycle. |
|
1822 |
\end{description} |
|
1823 |
||
1824 |
\paragraph{State Machine Descriptions} |
|
1825 |
||
1826 |
The below sections describe every state machine used in the EtherCAT |
|
1827 |
master. The textual descriptions of the state machines contain |
|
1828 |
references to the transitions in the corresponding state transition |
|
1829 |
diagrams, that are marked with an arrow followed by the name of the |
|
1830 |
successive state. Transitions caused by trivial error cases (i.~e. no |
|
1831 |
response from slave) are not described explicitly. These transitions |
|
1832 |
are drawn as dashed arrows in the diagrams. |
|
1833 |
||
1834 |
%------------------------------------------------------------------------------ |
|
1835 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1836 |
\section{The Operation State Machine} |
369 | 1837 |
\label{sec:fsm-op} |
1838 |
\index{FSM!Operation} |
|
1839 |
||
1840 |
The Operation state machine is executed by calling the |
|
1841 |
\textit{ecrt\_master\_run()} method in cyclic realtime code. Its |
|
1842 |
purpose is to monitor the bus and to reconfigure slaves after a bus |
|
1843 |
failure or power failure. Figure~\ref{fig:fsm-op} shows its transition |
|
1844 |
diagram. |
|
1845 |
||
1846 |
\begin{figure}[htbp] |
|
1847 |
\centering |
|
1848 |
\includegraphics[width=.8\textwidth]{images/fsm-op} |
|
1849 |
\caption{Transition diagram of the operation state machine} |
|
1850 |
\label{fig:fsm-op} |
|
1851 |
\end{figure} |
|
1852 |
||
1853 |
\begin{description} |
|
1854 |
\item[START] This is the beginning state of the operation state |
|
1855 |
machine. There is a datagram issued, that queries the ``AL Control |
|
1856 |
Response'' attribute \cite[section~5.3.2]{alspec} of all slaves via |
|
1857 |
broadcast. In this way, all slave states and the number of slaves |
|
379 | 1858 |
responding can be determined. $\rightarrow$~BROADCAST |
369 | 1859 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1860 |
\item[BROADCAST] The broadcast datagram is evaluated. A change in the number of |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1861 |
responding slaves is treated as a topology change. If the number of slaves is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1862 |
not as expected, the bus is marked as ``tainted''. In this state, no slave |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1863 |
reconfiguration is possible, because the assignment of known slaves and those |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1864 |
present on the bus is ambiguous. If the number of slaves is considered as |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1865 |
right, the bus is marked for validation, because it turned from tainted to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1866 |
normal state and it has to be checked, if all slaves are valid. Now, the state |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1867 |
of every single slave has to be determined. For that, a (unicast) datagram is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1868 |
issued, that queries the first slave's ``AL Control Response'' attribute. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1869 |
$\rightarrow$~READ STATES |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1870 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1871 |
\item[READ STATES] If the current slave did not respond to its configured |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1872 |
station address, it is marked as offline, and the next slave is queried. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1873 |
$\rightarrow$~READ STATES |
369 | 1874 |
|
1875 |
If the slave responded, it is marked as online and its current state |
|
379 | 1876 |
is stored. The next slave is queried. $\rightarrow$~READ STATES |
369 | 1877 |
|
1878 |
If all slaves have been queried, and the bus is marked for |
|
1879 |
validation, the validation is started by checking the first slaves |
|
379 | 1880 |
vendor ID. $\rightarrow$~VALIDATE VENDOR |
369 | 1881 |
|
1882 |
If no validation has to be done, it is checked, if all slaves are in |
|
1883 |
the state they are supposed to be. If not, the first of slave with |
|
1884 |
the wrong state is reconfigured and brought in the required state. |
|
379 | 1885 |
$\rightarrow$~CONFIGURE SLAVES |
369 | 1886 |
|
1887 |
If all slaves are in the correct state, the state machine is |
|
379 | 1888 |
restarted. $\rightarrow$~START |
369 | 1889 |
|
1890 |
\item[CONFIGURE SLAVES] The slave configuration state machine is |
|
379 | 1891 |
executed until termination. $\rightarrow$~CONFIGURE SLAVES |
369 | 1892 |
|
1893 |
If there are still slaves in the wrong state after another check, |
|
1894 |
the first of these slaves is configured and brought into the correct |
|
379 | 1895 |
state again. $\rightarrow$~CONFIGURE SLAVES |
369 | 1896 |
|
1897 |
If all slaves are in the correct state, the state machine is |
|
379 | 1898 |
restarted. $\rightarrow$~START |
369 | 1899 |
|
1900 |
\item[VALIDATE VENDOR] The SII state machine is executed until |
|
1901 |
termination. If the slave has the wrong vendor ID, the state machine |
|
379 | 1902 |
is restarted. $\rightarrow$~START |
369 | 1903 |
|
1904 |
If the slave has the correct vendor ID, its product ID is queried. |
|
379 | 1905 |
$\rightarrow$~VALIDATE PRODUCT |
369 | 1906 |
|
1907 |
\item[VALIDATE PRODUCT] The SII state machine is executed until |
|
1908 |
termination. If the slave has the wrong product ID, the state |
|
379 | 1909 |
machine is restarted. $\rightarrow$~START |
369 | 1910 |
|
1911 |
If the slave has the correct product ID, the next slave's vendor ID |
|
379 | 1912 |
is queried. $\rightarrow$~VALIDATE VENDOR |
369 | 1913 |
|
1914 |
If all slaves have the correct vendor IDs and product codes, the |
|
1915 |
configured station addresses can be safely rewritten. This is done |
|
1916 |
for the first slave marked as offline. |
|
379 | 1917 |
$\rightarrow$~REWRITE ADDRESSES |
369 | 1918 |
|
1095 | 1919 |
\item[REWRITE ADDRESSES] If the station address was successfully written, it is |
1920 |
searched for the next slave marked as offline. If there is one, its address is |
|
1921 |
reconfigured, too. $\rightarrow$~REWRITE ADDRESSES |
|
369 | 1922 |
|
1923 |
If there are no more slaves marked as offline, the state machine is |
|
379 | 1924 |
restarted. $\rightarrow$~START |
369 | 1925 |
\end{description} |
1926 |
||
1927 |
%------------------------------------------------------------------------------ |
|
1928 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1929 |
\section{The Idle State Machine} |
369 | 1930 |
\label{sec:fsm-idle} |
1931 |
\index{FSM!Idle} |
|
1932 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1933 |
The Idle state machine is executed by a kernel thread, if no application is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1934 |
connected. Its purpose is to make slave information available to user space, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1935 |
operate EoE-capable slaves, read and write SII contents and test slave |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
1936 |
functionality. Figure~\ref{fig:fsm-idle} shows its transition diagram. |
369 | 1937 |
|
1938 |
\begin{figure}[htbp] |
|
1939 |
\centering |
|
1940 |
\includegraphics[width=.8\textwidth]{images/fsm-idle} |
|
1941 |
\caption{Transition diagram of the idle state machine} |
|
1942 |
\label{fig:fsm-idle} |
|
1943 |
\end{figure} |
|
1944 |
||
1945 |
\begin{description} |
|
1946 |
\item[START] The beginning state of the idle state machine. Similar to |
|
1947 |
the operation state machine, a broadcast datagram is issued, to |
|
1948 |
query all slave states and the number of slaves. |
|
379 | 1949 |
$\rightarrow$~BROADCAST |
369 | 1950 |
|
1951 |
\item[BROADCAST] The number of responding slaves is evaluated. If it |
|
1952 |
has changed since the last time, this is treated as a topology |
|
1953 |
change and the internal list of slaves is cleared and rebuild |
|
1954 |
completely. The slave scan state machine is started for the first |
|
379 | 1955 |
slave. $\rightarrow$~SCAN FOR SLAVES |
369 | 1956 |
|
1957 |
If no topology change happened, every single slave state is fetched. |
|
379 | 1958 |
$\rightarrow$~READ STATES |
369 | 1959 |
|
1960 |
\item[SCAN FOR SLAVES] The slave scan state machine is executed until |
|
379 | 1961 |
termination. $\rightarrow$~SCAN FOR SLAVES |
369 | 1962 |
|
1963 |
If there is another slave to scan, the slave scan state machine is |
|
379 | 1964 |
started again. $\rightarrow$~SCAN FOR SLAVES |
369 | 1965 |
|
1966 |
If all slave information has been fetched, slave addresses are |
|
1967 |
calculated and EoE processing is started. Then, the state machine is |
|
379 | 1968 |
restarted. $\rightarrow$~START |
369 | 1969 |
|
1970 |
\item[READ STATES] If the slave did not respond to the query, it is |
|
1971 |
marked as offline. The next slave is queried. |
|
379 | 1972 |
$\rightarrow$~READ STATES |
369 | 1973 |
|
1974 |
If the slave responded, it is marked as online. And the next slave |
|
379 | 1975 |
is queried. $\rightarrow$~READ STATES |
369 | 1976 |
|
1977 |
If all slave states have been determined, it is checked, if any |
|
1978 |
slaves are not in the state they supposed to be. If this is true, |
|
1979 |
the slave configuration state machine is started for the first of |
|
379 | 1980 |
them. $\rightarrow$~CONFIGURE SLAVES |
369 | 1981 |
|
1982 |
If all slaves are in the correct state, it is checked, if any |
|
1983 |
E$^2$PROM write operations are pending. If this is true, the first |
|
1984 |
pending operation is executed by starting the SII state machine for |
|
379 | 1985 |
writing access. $\rightarrow$~WRITE EEPROM |
369 | 1986 |
|
1987 |
If all these conditions are false, there is nothing to do and the |
|
379 | 1988 |
state machine is restarted. $\rightarrow$~START |
369 | 1989 |
|
1990 |
\item[CONFIGURE SLAVES] The slave configuration state machine is |
|
379 | 1991 |
executed until termination. $\rightarrow$~CONFIGURE SLAVES |
369 | 1992 |
|
1993 |
After this, it is checked, if another slave needs a state change. If |
|
1994 |
this is true, the slave state change state machine is started for |
|
379 | 1995 |
this slave. $\rightarrow$~CONFIGURE SLAVES |
369 | 1996 |
|
1997 |
If all slaves are in the correct state, it is determined, if any |
|
1998 |
E$^2$PROM write operations are pending. If this is true, the first |
|
1999 |
pending operation is executed by starting the SII state machine for |
|
379 | 2000 |
writing access. $\rightarrow$~WRITE EEPROM |
369 | 2001 |
|
2002 |
If all prior conditions are false, the state machine is restarted. |
|
379 | 2003 |
$\rightarrow$~START |
369 | 2004 |
|
2005 |
\item[WRITE EEPROM] The SII state machine is executed until |
|
379 | 2006 |
termination. $\rightarrow$~WRITE EEPROM |
369 | 2007 |
|
2008 |
If the current word has been written successfully, and there are |
|
2009 |
still word to write, the SII state machine is started for the next |
|
379 | 2010 |
word. $\rightarrow$~WRITE EEPROM |
369 | 2011 |
|
2012 |
If all words have been written successfully, the new E$^2$PROM |
|
2013 |
contents are evaluated and the state machine is restarted. |
|
379 | 2014 |
$\rightarrow$~START |
369 | 2015 |
|
2016 |
\end{description} |
|
2017 |
||
2018 |
%------------------------------------------------------------------------------ |
|
2019 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2020 |
\section{The Slave Scan State Machine} |
369 | 2021 |
\label{sec:fsm-scan} |
2022 |
\index{FSM!Slave Scan} |
|
2023 |
||
2024 |
The slave scan state machine, which can be seen in |
|
2025 |
figure~\ref{fig:fsm-slavescan}, leads through the process of fetching |
|
2026 |
all slave information. |
|
2027 |
||
2028 |
\begin{figure}[htbp] |
|
2029 |
\centering |
|
2030 |
\includegraphics[width=.6\textwidth]{images/fsm-slavescan} |
|
2031 |
\caption{Transition diagram of the slave scan state machine} |
|
2032 |
\label{fig:fsm-slavescan} |
|
2033 |
\end{figure} |
|
2034 |
||
2035 |
\begin{description} |
|
2036 |
\item[START] In the beginning state of the slave scan state machine, |
|
2037 |
the station address is written to the slave, which is always the |
|
2038 |
ring position~+~$1$. In this way, the address 0x0000 (default |
|
2039 |
address) is not used, which makes it easy to detect unconfigured |
|
379 | 2040 |
slaves. $\rightarrow$~ADDRESS |
369 | 2041 |
|
2042 |
\item[ADDRESS] The writing of the station address is verified. After |
|
2043 |
that, the slave's ``AL Control Response'' attribute is queried. |
|
379 | 2044 |
$\rightarrow$~STATE |
369 | 2045 |
|
2046 |
\item[STATE] The AL state is evaluated. A warning is output, if the |
|
2047 |
slave has still the \textit{Change} bit set. After that, the slave's |
|
2048 |
``DL Information'' attribute is queried. |
|
379 | 2049 |
$\rightarrow$~BASE |
369 | 2050 |
|
2051 |
\item[BASE] The queried base data are evaluated: Slave type, revision |
|
2052 |
and build number, and even more important, the number of supported |
|
2053 |
sync managers and FMMUs are stored. After that, the slave's data |
|
2054 |
link layer information is read from the ``DL Status'' attribute at |
|
379 | 2055 |
address 0x0110. $\rightarrow$~DATALINK |
369 | 2056 |
|
2057 |
\item[DATALINK] In this state, the DL information is evaluated: This |
|
2058 |
information about the communication ports contains, if the link is |
|
2059 |
up, if the loop has been closed and if there is a carrier detected |
|
2060 |
on the RX side of each port. |
|
2061 |
||
2062 |
Then, the state machine starts measuring the size of the slave's |
|
2063 |
E$^2$PROM contents. This is done by subsequently reading out each |
|
2064 |
category header, until the last category is reached (type 0xFFFF). |
|
2065 |
This procedure is started by querying the first category header at |
|
2066 |
word address 0x0040 via the SII state machine. |
|
379 | 2067 |
$\rightarrow$~EEPROM SIZE |
369 | 2068 |
|
2069 |
\item[EEPROM SIZE] The SII state machine is executed until |
|
379 | 2070 |
termination. $\rightarrow$~EEPROM SIZE |
369 | 2071 |
|
2072 |
If the category type does not mark the end of the categories, the |
|
2073 |
position of the next category header is determined via the length of |
|
2074 |
the current category, and the SII state machine is started again. |
|
379 | 2075 |
$\rightarrow$~EEPROM SIZE |
369 | 2076 |
|
2077 |
If the size of the E$^2$PROM contents has been determined, memory is |
|
2078 |
allocated, to read all the contents. The SII state machine is |
|
379 | 2079 |
started to read the first word. $\rightarrow$~EEPROM DATA |
369 | 2080 |
|
2081 |
\item[EEPROM DATA] The SII state machine is executed until |
|
379 | 2082 |
termination. $\rightarrow$~EEPROM DATA |
369 | 2083 |
|
2084 |
Two words have been read. If more than one word is needed, the two |
|
2085 |
words are written in the allocated memory. Otherwise only one word |
|
2086 |
(the last word) is copied. If more words are to read, the SII state |
|
2087 |
machine is started again to read the next two words. |
|
379 | 2088 |
$\rightarrow$~EEPROM DATA |
369 | 2089 |
|
2090 |
The complete E$^2$PROM contents have been read. The slave's identity |
|
2091 |
object and mailbox information are evaluated. Moreover the category |
|
2092 |
types STRINGS, GENERAL, SYNC and PDO are evaluated. The slave |
|
379 | 2093 |
scanning has been completed. $\rightarrow$~END |
369 | 2094 |
|
2095 |
\item[END] Slave scanning has been finished. |
|
2096 |
||
2097 |
\end{description} |
|
2098 |
||
2099 |
%------------------------------------------------------------------------------ |
|
2100 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2101 |
\section{The Slave Configuration State Machine} |
369 | 2102 |
\label{sec:fsm-conf} |
2103 |
\index{FSM!Slave Configuration} |
|
2104 |
||
2105 |
The slave configuration state machine, which can be seen in |
|
2106 |
figure~\ref{fig:fsm-slaveconf}, leads through the process of |
|
2107 |
configuring a slave and bringing it to a certain state. |
|
2108 |
||
2109 |
\begin{figure}[htbp] |
|
2110 |
\centering |
|
2111 |
\includegraphics[width=.6\textwidth]{images/fsm-slaveconf} |
|
2112 |
\caption{Transition diagram of the slave configuration state |
|
2113 |
machine} |
|
2114 |
\label{fig:fsm-slaveconf} |
|
2115 |
\end{figure} |
|
2116 |
||
2117 |
\begin{description} |
|
2118 |
\item[INIT] The state change state machine has been initialized to |
|
379 | 2119 |
bring the slave into the INIT state. Now, the slave state change |
2120 |
state machine is executed until termination. $\rightarrow$~INIT |
|
369 | 2121 |
|
2122 |
If the slave state change failed, the configuration has to be |
|
379 | 2123 |
aborted. $\rightarrow$~END |
2124 |
||
2125 |
The slave state change succeeded and the slave is now in INIT state. |
|
2126 |
If this is the target state, the configuration is finished. |
|
2127 |
$\rightarrow$~END |
|
369 | 2128 |
|
2129 |
If the slave does not support any sync managers, the sync manager |
|
2130 |
configuration can be skipped. The state change state machine is |
|
379 | 2131 |
started to bring the slave into PREOP state. |
2132 |
$\rightarrow$~PREOP |
|
369 | 2133 |
|
2134 |
Sync managers are configured conforming to the sync manager category |
|
2135 |
information provided in the slave's E$^2$PROM. The corresponding |
|
379 | 2136 |
datagram is issued. $\rightarrow$~SYNC |
369 | 2137 |
|
2138 |
\item[SYNC] If the sync manager configuration datagram is accepted, |
|
2139 |
the sync manager configuration was successful. The slave may now |
|
379 | 2140 |
enter the PREOP state, and the state change state machine is |
2141 |
started. $\rightarrow$~PREOP |
|
369 | 2142 |
|
2143 |
\item[PREOP] The state change state machine is executed until |
|
379 | 2144 |
termination. $\rightarrow$~PREOP |
369 | 2145 |
|
2146 |
If the state change failed, the configuration has to be aborted. |
|
379 | 2147 |
$\rightarrow$~END |
2148 |
||
2149 |
If the PREOP state was the target state, the configuration is |
|
2150 |
finished. $\rightarrow$~END |
|
369 | 2151 |
|
2152 |
If the slave supports no FMMUs, the FMMU configuration can be |
|
814 | 2153 |
skipped. If the slave has Sdos to configure, it is begun with |
2154 |
sending the first Sdo. $\rightarrow$~SDO\_CONF |
|
2155 |
||
2156 |
If no Sdo configurations are provided, the slave can now directly be |
|
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2157 |
brought into the SAFEOP state and the state change state machine is |
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2158 |
started again. $\rightarrow$~SAFEOP |
369 | 2159 |
|
814 | 2160 |
Otherwise, all supported FMMUs are configured according to the Pdos |
369 | 2161 |
requested via the master's realtime interface. The appropriate |
379 | 2162 |
datagram is issued. $\rightarrow$~FMMU |
369 | 2163 |
|
2164 |
\item[FMMU] The FMMU configuration datagram was accepted. If the slave |
|
814 | 2165 |
has Sdos to configure, it is begun with sending the first Sdo. |
379 | 2166 |
$\rightarrow$~SDO\_CONF |
2167 |
||
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2168 |
Otherwise, the slave can now be brought into the SAFEOP state. The |
379 | 2169 |
state change state machine is started. |
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2170 |
$\rightarrow$~SAFEOP |
369 | 2171 |
|
2172 |
\item[SDO\_CONF] The CoE state machine is executed until termination. |
|
379 | 2173 |
$\rightarrow$~SDO\_CONF |
369 | 2174 |
|
814 | 2175 |
If another Sdo has to be configured, a new Sdo download sequence is |
379 | 2176 |
begun. $\rightarrow$~SDO\_CONF |
2177 |
||
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2178 |
Otherwise, the slave can now be brought into the SAFEOP state. The |
379 | 2179 |
state change state machine is started. |
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2180 |
$\rightarrow$~SAFEOP |
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2181 |
|
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2182 |
\item[SAFEOP] The state change state machine is executed until |
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2183 |
termination. $\rightarrow$~SAFEOP |
369 | 2184 |
|
2185 |
If the state change failed, the configuration has to be aborted. |
|
379 | 2186 |
$\rightarrow$~END |
2187 |
||
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2188 |
If the SAFEOP state was the target state, the configuration is |
379 | 2189 |
finished. $\rightarrow$~END |
2190 |
||
2191 |
The slave can now directly be brought into the OP state and the |
|
2192 |
state change state machine is started a last time. |
|
2193 |
$\rightarrow$~OP |
|
369 | 2194 |
|
2195 |
\item[OP] The state change state machine is executed until |
|
379 | 2196 |
termination. $\rightarrow$~OP |
369 | 2197 |
|
2198 |
If the state change state machine terminates, the slave |
|
2199 |
configuration is finished, regardless of its success. |
|
379 | 2200 |
$\rightarrow$~END |
369 | 2201 |
|
2202 |
\item[END] The termination state. |
|
2203 |
||
2204 |
\end{description} |
|
2205 |
||
2206 |
%------------------------------------------------------------------------------ |
|
2207 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2208 |
\section{The State Change State Machine} |
369 | 2209 |
\label{sec:fsm-change} |
2210 |
\index{FSM!State Change} |
|
2211 |
||
2212 |
The state change state machine, which can be seen in |
|
2213 |
figure~\ref{fig:fsm-change}, leads through the process of changing a |
|
2214 |
slave's state. This implements the states and transitions described in |
|
2215 |
\cite[section~6.4.1]{alspec}. |
|
2216 |
||
2217 |
\begin{figure}[htbp] |
|
2218 |
\centering |
|
2219 |
\includegraphics[width=.9\textwidth]{images/fsm-change} |
|
2220 |
\caption{Transition diagram of the state change state machine} |
|
2221 |
\label{fig:fsm-change} |
|
2222 |
\end{figure} |
|
2223 |
||
2224 |
\begin{description} |
|
2225 |
\item[START] The beginning state, where a datagram with the state |
|
2226 |
change command is written to the slave's ``AL Control Request'' |
|
379 | 2227 |
attribute. Nothing can fail. $\rightarrow$~CHECK |
369 | 2228 |
|
2229 |
\item[CHECK] After the state change datagram has been sent, the ``AL |
|
2230 |
Control Response'' attribute is queried with a second datagram. |
|
379 | 2231 |
$\rightarrow$~STATUS |
369 | 2232 |
|
2233 |
\item[STATUS] The read memory contents are evaluated: While the |
|
2234 |
parameter \textit{State} still contains the old slave state, the |
|
2235 |
slave is busy with reacting on the state change command. In this |
|
2236 |
case, the attribute has to be queried again. |
|
379 | 2237 |
$\rightarrow$~STATUS |
369 | 2238 |
|
2239 |
In case of success, the \textit{State} parameter contains the new |
|
2240 |
state and the \textit{Change} bit is cleared. The slave is in the |
|
379 | 2241 |
requested state. $\rightarrow$~END |
369 | 2242 |
|
2243 |
If the slave can not process the state change, the \textit{Change} |
|
2244 |
bit is set: Now the master tries to get the reason for this by |
|
2245 |
querying the \textit{AL Status Code} parameter. |
|
379 | 2246 |
$\rightarrow$~CODE |
369 | 2247 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2248 |
\item[END] If the state machine ends in this state, the slave's state |
369 | 2249 |
change has been successful. |
2250 |
||
2251 |
\item[CODE] The status code query has been sent. Reading the |
|
2252 |
\textit{AL Status Code} might fail, because not all slaves support |
|
2253 |
this parameter. Anyway, the master has to acknowledge the state |
|
2254 |
change error by writing the current slave state to the ``AL Control |
|
2255 |
Request'' attribute with the \textit{Acknowledge} bit set. |
|
379 | 2256 |
$\rightarrow$~ACK |
369 | 2257 |
|
2258 |
\item[ACK] After that, the ``AL Control Response'' attribute is |
|
2259 |
queried for the state of the acknowledgement. |
|
379 | 2260 |
$\rightarrow$~CHECK ACK |
369 | 2261 |
|
2262 |
\item[CHECK ACK] If the acknowledgement has been accepted by the |
|
2263 |
slave, the old state is kept. Still, the state change was |
|
379 | 2264 |
unsuccessful. $\rightarrow$~ERROR |
369 | 2265 |
|
2266 |
If the acknowledgement is ignored by the slave, a timeout happens. |
|
2267 |
In any case, the overall state change was unsuccessful. |
|
379 | 2268 |
$\rightarrow$~ERROR |
369 | 2269 |
|
2270 |
If there is still now response from the slave, but the timer did not |
|
2271 |
run out yet, the slave's ``AL Control Response'' attribute is |
|
379 | 2272 |
queried again. $\rightarrow$~CHECK ACK |
369 | 2273 |
|
2274 |
\item[ERROR] If the state machine ends in this state, the slave's |
|
2275 |
state change was unsuccessful. |
|
2276 |
||
2277 |
\end{description} |
|
2278 |
||
2279 |
%------------------------------------------------------------------------------ |
|
2280 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2281 |
\section{The SII State Machine} |
369 | 2282 |
\label{sec:fsm-sii} |
2283 |
\index{FSM!SII} |
|
2284 |
||
2285 |
The SII\index{SII} state machine (shown in figure~\ref{fig:fsm-sii}) |
|
2286 |
implements the process of reading or writing E$^2$PROM data via the |
|
2287 |
Slave Information Interface described in \cite[section~5.4]{alspec}. |
|
2288 |
||
2289 |
\begin{figure}[htbp] |
|
2290 |
\centering |
|
2291 |
\includegraphics[width=.9\textwidth]{images/fsm-sii} |
|
2292 |
\caption{Transition diagram of the SII state machine} |
|
2293 |
\label{fig:fsm-sii} |
|
2294 |
\end{figure} |
|
2295 |
||
2296 |
\begin{description} |
|
2297 |
\item[READ\_START] The beginning state for reading access, where the |
|
2298 |
read request and the requested address are written to the SII |
|
2299 |
attribute. Nothing can fail up to now. |
|
379 | 2300 |
$\rightarrow$~READ\_CHECK |
369 | 2301 |
|
2302 |
\item[READ\_CHECK] When the SII read request has been sent |
|
2303 |
successfully, a timer is started. A check/fetch datagram is issued, |
|
2304 |
that reads out the SII attribute for state and data. |
|
379 | 2305 |
$\rightarrow$~READ\_FETCH |
369 | 2306 |
|
2307 |
\item[READ\_FETCH] Upon reception of the check/fetch datagram, the |
|
2308 |
\textit{Read Operation} and \textit{Busy} parameters are checked: |
|
2309 |
\begin{itemize} |
|
2310 |
\item If the slave is still busy with fetching E$^2$PROM data into |
|
2311 |
the interface, the timer is checked. If it timed out, the reading |
|
379 | 2312 |
is aborted ($\rightarrow$~ERROR), if not, the check/fetch datagram |
2313 |
is issued again. $\rightarrow$~READ\_FETCH |
|
369 | 2314 |
|
2315 |
\item If the slave is ready with reading data, these are copied from |
|
2316 |
the datagram and the read cycle is completed. |
|
379 | 2317 |
$\rightarrow$~END |
369 | 2318 |
\end{itemize} |
2319 |
\end{description} |
|
2320 |
||
2321 |
The write access states behave nearly the same: |
|
2322 |
||
2323 |
\begin{description} |
|
2324 |
\item[WRITE\_START] The beginning state for writing access, |
|
2325 |
respectively. A write request, the target address and the data word |
|
2326 |
are written to the SII attribute. Nothing can fail. |
|
379 | 2327 |
$\rightarrow$~WRITE\_CHECK |
369 | 2328 |
|
2329 |
\item[WRITE\_CHECK] When the SII write request has been sent |
|
2330 |
successfully, the timer is started. A check datagram is issued, that |
|
2331 |
reads out the SII attribute for the state of the write operation. |
|
379 | 2332 |
$\rightarrow$~WRITE\_CHECK2 |
369 | 2333 |
|
2334 |
\item[WRITE\_CHECK2] Upon reception of the check datagram, the |
|
2335 |
\textit{Write Operation} and \textit{Busy} parameters are checked: |
|
2336 |
\begin{itemize} |
|
2337 |
\item If the slave is still busy with writing E$^2$PROM data, the |
|
2338 |
timer is checked. If it timed out, the operation is aborted |
|
379 | 2339 |
($\rightarrow$~ERROR), if not, the check datagram is issued again. |
2340 |
$\rightarrow$~WRITE\_CHECK2 |
|
369 | 2341 |
\item If the slave is ready with writing data, the write cycle is |
379 | 2342 |
completed. $\rightarrow$~END |
369 | 2343 |
\end{itemize} |
2344 |
\end{description} |
|
2345 |
||
2346 |
%------------------------------------------------------------------------------ |
|
2347 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2348 |
\chapter{Mailbox Protocol Implementations} |
369 | 2349 |
\index{Mailbox} |
2350 |
||
2351 |
The EtherCAT master implements the EoE and the CoE mailbox |
|
2352 |
protocols. See the below section for details. |
|
2353 |
||
2354 |
%------------------------------------------------------------------------------ |
|
2355 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2356 |
\section{Ethernet-over-EtherCAT (EoE)} |
369 | 2357 |
\label{sec:eoeimp} |
2358 |
\index{EoE} |
|
2359 |
||
2360 |
The EtherCAT master implements the Ethernet-over-EtherCAT mailbox |
|
2361 |
protocol to enable the tunneling of Ethernet frames to special slaves, |
|
2362 |
that can either have physical Ethernet ports to forward the frames to, |
|
2363 |
or have an own IP stack to receive the frames. |
|
2364 |
||
2365 |
\paragraph{Virtual Network Interfaces} |
|
2366 |
||
2367 |
The master creates a virtual EoE network interface for every |
|
2368 |
EoE-capable slave. These interfaces are called \textit{eoeX}, where X |
|
2369 |
is a number provided by the kernel on interface registration. Frames |
|
2370 |
sent to these interfaces are forwarded to the associated slaves by the |
|
2371 |
master. Frames, that are received by the slaves, are fetched by the |
|
2372 |
master and forwarded to the virtual interfaces. |
|
2373 |
||
2374 |
This bears the following advantages: |
|
2375 |
||
2376 |
\begin{itemize} |
|
2377 |
\item Flexibility: The user can decide, how the EoE-capable slaves are |
|
2378 |
interconnected with the rest of the world. |
|
2379 |
\item Standard tools can be used to monitor the EoE activity and to |
|
2380 |
configure the EoE interfaces. |
|
2381 |
\item The Linux kernel's layer-2-bridging implementation (according to |
|
2382 |
the IEEE 802.1D MAC Bridging standard) can be used natively to |
|
2383 |
bridge Ethernet traffic between EoE-capable slaves. |
|
2384 |
\item The Linux kernel's network stack can be used to route packets |
|
2385 |
between EoE-capable slaves and to track security issues, just like |
|
2386 |
having physical network interfaces. |
|
2387 |
\end{itemize} |
|
2388 |
||
2389 |
\paragraph{EoE Handlers} |
|
2390 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2391 |
The virtual EoE interfaces and the related functionality is encapsulated in the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2392 |
\textit{ec\_eoe\_t} class (see section~\ref{sec:class-eoe}). So the master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2393 |
does not create the network interfaces directly: This is done inside the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2394 |
constructor of the \textit{ec\_eoe\_t} class. An object of this class is called |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2395 |
``EoE handler'' below. An EoE handler additionally contains a frame queue. Each |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2396 |
time, the kernel passes a new socket buffer for sending via the interface's |
369 | 2397 |
\textit{hard\_start\_xmit()} callback, the socket buffer is queued for |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2398 |
transmission by the EoE state machine (see below). If the queue gets filled up, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2399 |
the passing of new socket buffers is suspended with a call to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2400 |
\textit{netif\_stop\_queue()}. |
369 | 2401 |
|
2402 |
\paragraph{Static Handler Creation} |
|
2403 |
||
2404 |
The master creates a pool of EoE handlers at startup, that are coupled |
|
2405 |
to EoE-capable slaves on demand. The lifetime of the corresponding |
|
2406 |
network interfaces is equal to the lifetime of the master module. |
|
2407 |
This approach is opposed to creating the virtual network interfaces on |
|
2408 |
demand (i.~e. on running across a new EoE-capable slave). The latter |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2409 |
approach was considered as difficult, because of several reasons: |
369 | 2410 |
|
2411 |
\begin{itemize} |
|
2412 |
\item The \textit{alloc\_netdev()} function can sleep and must be |
|
2413 |
called from a non-interrupt context. This reduces the flexibility of |
|
2414 |
choosing an appropriate method for cyclic EoE processing. |
|
2415 |
\item Unregistering network interfaces requires them to be ``down'', |
|
2416 |
which can not be guaranteed upon sudden disappearing of an |
|
2417 |
EoE-capable slave. |
|
2418 |
\item The connection to the EoE-capable slaves must be as continuous |
|
2419 |
as possible. Especially the transition from idle to operation mode |
|
2420 |
(and vice versa) causes the rebuilding of the internal data |
|
2421 |
structures. These transitions must be as transparent as possible for |
|
2422 |
the instances using the network interfaces. |
|
2423 |
\end{itemize} |
|
2424 |
||
1095 | 2425 |
\paragraph{Number of Handlers} % FIXME |
369 | 2426 |
|
2427 |
The master module has a parameter \textit{ec\_eoeif\_count} to specify |
|
2428 |
the number of EoE interfaces (and handlers) per master to create. This |
|
2429 |
parameter can either be specified when manually loading the master |
|
2430 |
module, or (when using the init script) by setting the |
|
379 | 2431 |
\$EOE\_INTERFACES variable in the sysconfig file (see |
369 | 2432 |
section~\ref{sec:sysconfig}). Upon loading of the master module, the |
2433 |
virtual interfaces become available: |
|
2434 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2435 |
\begin{lstlisting}[gobble=2] |
379 | 2436 |
# `\textbf{ifconfig -a}` |
369 | 2437 |
eoe0 Link encap:Ethernet HWaddr 00:11:22:33:44:06 |
2438 |
BROADCAST MULTICAST MTU:1500 Metric:1 |
|
2439 |
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 |
|
2440 |
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 |
|
2441 |
collisions:0 txqueuelen:1000 |
|
2442 |
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) |
|
2443 |
||
2444 |
eoe1 Link encap:Ethernet HWaddr 00:11:22:33:44:07 |
|
2445 |
BROADCAST MULTICAST MTU:1500 Metric:1 |
|
2446 |
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 |
|
2447 |
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 |
|
2448 |
collisions:0 txqueuelen:1000 |
|
2449 |
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) |
|
2450 |
... |
|
2451 |
\end{lstlisting} |
|
2452 |
||
2453 |
\paragraph{Coupling of EoE Slaves} |
|
2454 |
||
2455 |
During execution of the slave scan state machine (see |
|
2456 |
section~\ref{sec:fsm-scan}), the master determines the supported |
|
2457 |
mailbox protocols. This is done by examining the ``Supported Mailbox |
|
2458 |
Protocols'' mask field at word address 0x001C of the SII\index{SII}. |
|
2459 |
If bit 1 is set, the slave supports the EoE protocol. After slave |
|
2460 |
scanning, the master runs through all slaves again and couples each |
|
2461 |
EoE-capable slave to a free EoE handler. It can happen, that there are |
|
2462 |
not enough EoE handlers to cover all EoE-capable slaves. In this case, |
|
2463 |
the number of EoE handlers must be increased accordingly. |
|
2464 |
||
2465 |
\paragraph{EoE State Machine} |
|
2466 |
\index{FSM!EoE} |
|
2467 |
||
2468 |
Every EoE handler owns an EoE state machine, that is used to send |
|
2469 |
frames to the coupled slave and receive frames from the it via the EoE |
|
2470 |
communication primitives. This state machine is showed in |
|
2471 |
figure~\ref{fig:fsm-eoe}. |
|
2472 |
||
2473 |
\begin{figure}[htbp] |
|
2474 |
\centering |
|
2475 |
\includegraphics[width=.7\textwidth]{images/fsm-eoe} |
|
2476 |
\caption{Transition diagram of the EoE state machine} |
|
2477 |
\label{fig:fsm-eoe} |
|
2478 |
\end{figure} |
|
2479 |
||
2480 |
\begin{description} |
|
2481 |
\item[RX\_START] The beginning state of the EoE state machine. A |
|
2482 |
mailbox check datagram is sent, to query the slave's mailbox for new |
|
379 | 2483 |
frames. $\rightarrow$~RX\_CHECK |
369 | 2484 |
|
2485 |
\item[RX\_CHECK] The mailbox check datagram is received. If the |
|
2486 |
slave's mailbox did not contain data, a transmit cycle is started. |
|
379 | 2487 |
$\rightarrow$~TX\_START |
369 | 2488 |
|
2489 |
If there are new data in the mailbox, a datagram is sent to fetch |
|
379 | 2490 |
the new data. $\rightarrow$~RX\_FETCH |
369 | 2491 |
|
2492 |
\item[RX\_FETCH] The fetch datagram is received. If the mailbox data |
|
2493 |
do not contain a ``EoE Fragment request'' command, the data are |
|
2494 |
dropped and a transmit sequence is started. |
|
379 | 2495 |
$\rightarrow$~TX\_START |
369 | 2496 |
|
2497 |
If the received Ethernet frame fragment is the first fragment, a new |
|
2498 |
socket buffer is allocated. In either case, the data are copied into |
|
2499 |
the correct position of the socket buffer. |
|
2500 |
||
2501 |
If the fragment is the last fragment, the socket buffer is forwarded |
|
2502 |
to the network stack and a transmit sequence is started. |
|
379 | 2503 |
$\rightarrow$~TX\_START |
369 | 2504 |
|
2505 |
Otherwise, a new receive sequence is started to fetch the next |
|
379 | 2506 |
fragment. $\rightarrow$~RX\_\-START |
369 | 2507 |
|
2508 |
\item[TX\_START] The beginning state of a transmit sequence. It is |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2509 |
checked, if the transmission queue contains a frame to send. If not, |
379 | 2510 |
a receive sequence is started. $\rightarrow$~RX\_START |
369 | 2511 |
|
2512 |
If there is a frame to send, it is dequeued. If the queue was |
|
2513 |
inactive before (because it was full), the queue is woken up with a |
|
2514 |
call to \textit{netif\_wake\_queue()}. The first fragment of the |
|
379 | 2515 |
frame is sent. $\rightarrow$~TX\_SENT |
369 | 2516 |
|
2517 |
\item[TX\_SENT] It is checked, if the first fragment was sent |
|
2518 |
successfully. If the current frame consists of further fragments, |
|
379 | 2519 |
the next one is sent. $\rightarrow$~TX\_SENT |
369 | 2520 |
|
2521 |
If the last fragment was sent, a new receive sequence is started. |
|
379 | 2522 |
$\rightarrow$~RX\_START |
369 | 2523 |
\end{description} |
2524 |
||
2525 |
\paragraph{EoE Processing} |
|
2526 |
||
2527 |
To execute the EoE state machine of every active EoE handler, there |
|
2528 |
must be a cyclic process. The easiest thing would be to execute the |
|
2529 |
EoE state machines synchronously to the operation state machine (see |
|
2530 |
section~\ref{sec:fsm-op}) with every realtime cycle. This approach has |
|
2531 |
the following disadvantages: |
|
2532 |
||
2533 |
\begin{itemize} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2534 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2535 |
\item Only one EoE fragment can be sent or received every few cycles. This |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2536 |
causes the data rate to be very low, because the EoE state machines are not |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2537 |
executed in the time between the application cycles. Moreover, the data rate |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2538 |
would be dependent on the period of the application task. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2539 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2540 |
\item The receiving and forwarding of frames to the kernel requires the dynamic |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2541 |
allocation of frames. Some realtime extensions do not support calling memory |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2542 |
allocation functions in realtime context, so the EoE state machine may not be |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2543 |
executed with each application cycle. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2544 |
|
369 | 2545 |
\end{itemize} |
2546 |
||
2547 |
To overcome these problems, an own cyclic process is needed to |
|
2548 |
asynchronously execute the EoE state machines. For that, the master |
|
2549 |
owns a kernel timer, that is executed each timer interrupt. This |
|
2550 |
guarantees a constant bandwidth, but poses the new problem of |
|
2551 |
concurrent access to the master. The locking mechanisms needed for |
|
2552 |
this are introduced in section~\ref{sec:concurr}. |
|
2553 |
Section~\ref{sec:concurrency} gives practical implementation examples. |
|
2554 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2555 |
\paragraph{Idle phase} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2556 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2557 |
EoE data must also be exchanged in idle phase, to guarantee the continuous |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2558 |
availability of the connection to the EoE-capable slaves. Although there is no |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2559 |
application connected in this case, the master is still accessed by the master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2560 |
state machine (see section~\ref{sec:fsm-master}). With the EoE timer running in |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2561 |
addition, there is still concurrency, that has to be protected by a lock. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2562 |
Therefore the master owns an internal spinlock that is used protect master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2563 |
access during idle phase. |
369 | 2564 |
|
2565 |
\paragraph{Automatic Configuration} |
|
2566 |
||
379 | 2567 |
By default, slaves are left in INIT state during idle mode. If an EoE |
2568 |
interface is set to running state (i.~e. with the \textit{ifconfig up} |
|
2569 |
command), the requested slave state of the related slave is |
|
2570 |
automatically set to OP, whereupon the idle state machine will attempt |
|
2571 |
to configure the slave and put it into operation. |
|
369 | 2572 |
|
2573 |
%------------------------------------------------------------------------------ |
|
2574 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2575 |
\section{CANopen-over-EtherCAT (CoE)} |
369 | 2576 |
\label{sec:coeimp} |
2577 |
\index{CoE} |
|
2578 |
||
2579 |
The CANopen-over-EtherCAT protocol \cite[section~5.6]{alspec} is used |
|
2580 |
to configure slaves on application level. Each CoE-capable slave |
|
814 | 2581 |
provides a list of Sdos for this reason. |
2582 |
||
2583 |
\paragraph{Sdo Configuration} |
|
2584 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2585 |
The Sdo configurations have to be provided by the application. This is done |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2586 |
via the \textit{ecrt\_slave\_conf\_sdo*()} methods (see |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2587 |
section~\ref{sec:ecrt-slave}), that are part of the realtime interface. The |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2588 |
slave stores the Sdo configurations in a linked list, but does not apply them |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2589 |
at once. |
369 | 2590 |
|
814 | 2591 |
\paragraph{Sdo Download State Machine} |
2592 |
||
2593 |
The best time to apply Sdo configurations is during the slave's PREOP |
|
379 | 2594 |
state, because mailbox communication is already possible and slave's |
2595 |
application will start with updating input data in the succeeding |
|
814 | 2596 |
SAFEOP state. Therefore the Sdo configuration has to be part of the |
379 | 2597 |
slave configuration state machine (see section~\ref{sec:fsm-conf}): It |
814 | 2598 |
is implemented via an Sdo download state machine, that is executed |
813
bfc3f1ab52de
Fixed typo SAVEOP -> SAFEOP.
Florian Pose <fp@igh-essen.com>
parents:
487
diff
changeset
|
2599 |
just before entering the slave's SAFEOP state. In this way, it is |
814 | 2600 |
guaranteed that the Sdo configurations are applied each time, the |
379 | 2601 |
slave is reconfigured. |
369 | 2602 |
|
814 | 2603 |
The transition diagram of the Sdo Download state machine can be seen |
369 | 2604 |
in figure~\ref{fig:fsm-coedown}. |
2605 |
||
2606 |
\begin{figure}[htbp] |
|
2607 |
\centering |
|
2608 |
\includegraphics[width=.9\textwidth]{images/fsm-coedown} |
|
2609 |
\caption{Transition diagram of the CoE download state machine} |
|
2610 |
\label{fig:fsm-coedown} |
|
2611 |
\end{figure} |
|
2612 |
||
2613 |
\begin{description} |
|
2614 |
\item[START] The beginning state of the CoE download state |
|
814 | 2615 |
machine. The ``Sdo Download Normal Request'' mailbox command is |
379 | 2616 |
sent. $\rightarrow$~REQUEST |
369 | 2617 |
|
2618 |
\item[REQUEST] It is checked, if the CoE download request has been |
|
2619 |
received by the slave. After that, a mailbox check command is issued |
|
379 | 2620 |
and a timer is started. $\rightarrow$~CHECK |
369 | 2621 |
|
2622 |
\item[CHECK] If no mailbox data is available, the timer is checked. |
|
2623 |
\begin{itemize} |
|
814 | 2624 |
\item If it timed out, the Sdo download is aborted. |
379 | 2625 |
$\rightarrow$~ERROR |
369 | 2626 |
\item Otherwise, the mailbox is queried again. |
379 | 2627 |
$\rightarrow$~CHECK |
369 | 2628 |
\end{itemize} |
2629 |
||
2630 |
If the mailbox contains new data, the response is fetched. |
|
379 | 2631 |
$\rightarrow$~RESPONSE |
369 | 2632 |
|
2633 |
\item[RESPONSE] If the mailbox response could not be fetched, the data |
|
814 | 2634 |
is invalid, the wrong protocol was received, or a ``Abort Sdo |
2635 |
Transfer Request'' was received, the Sdo download is aborted. |
|
379 | 2636 |
$\rightarrow$~ERROR |
369 | 2637 |
|
814 | 2638 |
If a ``Sdo Download Normal Response'' acknowledgement was received, |
2639 |
the Sdo download was successful. $\rightarrow$~END |
|
2640 |
||
2641 |
\item[END] The Sdo download was successful. |
|
2642 |
||
2643 |
\item[ERROR] The Sdo download was aborted due to an error. |
|
369 | 2644 |
|
2645 |
\end{description} |
|
2646 |
||
2647 |
%------------------------------------------------------------------------------ |
|
2648 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2649 |
\chapter{User Space} |
369 | 2650 |
\label{sec:user} |
2651 |
\index{User space} |
|
2652 |
||
2653 |
For the master runs as a kernel module, accessing it is natively |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2654 |
limited to analyzing Syslog messages and controlling using modutils. |
369 | 2655 |
|
2656 |
It is necessary to implement further interfaces, that make it easier |
|
2657 |
to access the master from user space and allow a finer influence. It |
|
2658 |
should be possible to view and to change special parameters at runtime. |
|
2659 |
||
2660 |
Bus visualization is a second point: For development and debugging |
|
2661 |
purposes it would be nice, if one could show the connected slaves with |
|
2662 |
a single command. |
|
2663 |
||
2664 |
Another aspect is automatic startup and configuration. If the master |
|
2665 |
is to be integrated into a running system, it must be able to |
|
2666 |
automatically start with a persistent configuration. |
|
2667 |
||
2668 |
A last thing is monitoring EtherCAT communication. For debugging |
|
2669 |
purposes, there had to be a way to analyze EtherCAT datagrams. The |
|
2670 |
best way would be with a popular network analyzer, like Wireshark |
|
2671 |
\cite{wireshark} (the former Ethereal) or others. |
|
2672 |
||
2673 |
This section covers all those points and introduces the interfaces and |
|
2674 |
tools to make all that possible. |
|
2675 |
||
2676 |
%------------------------------------------------------------------------------ |
|
2677 |
||
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2678 |
\section{Command-line Tool} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2679 |
\label{sec:ethercat} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2680 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2681 |
% --master |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2682 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2683 |
\subsection{Character devices} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2684 |
\label{sec:cdev} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2685 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2686 |
Each master instance will get a character device as a user-space interface. |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2687 |
The devices are named \textit{/dev/EtherCATX}, where $X$ is the index of the |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2688 |
master. |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2689 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2690 |
% FIXME |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2691 |
% udev |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2692 |
% rights |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2693 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2694 |
%------------------------------------------------------------------------------ |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2695 |
|
1140
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2696 |
\subsection{Setting alias addresses} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2697 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2698 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_alias} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2699 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2700 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2701 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2702 |
\subsection{Displaying the bus configuration} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2703 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2704 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_config} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2705 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2706 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2707 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2708 |
\subsection{Displaying process data} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2709 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2710 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_data} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2711 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2712 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2713 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2714 |
\subsection{Setting a master's debug level} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2715 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2716 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_debug} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2717 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2718 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2719 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2720 |
\subsection{Configured domains} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2721 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2722 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_domains} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2723 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2724 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2725 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2726 |
\subsection{Master and Ethernet device information} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2727 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2728 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_master} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2729 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2730 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2731 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2732 |
\subsection{Showing slaves' sync managers, Pdos and Pdo entries} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2733 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2734 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_pdos} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2735 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2736 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2737 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2738 |
\subsection{Displaying the Sdo dictionary} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2739 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2740 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sdos} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2741 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2742 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2743 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2744 |
\subsection{Sdo access} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2745 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2746 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_download} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2747 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2748 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_upload} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2749 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2750 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2751 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2752 |
\subsection{Displaying slaves on the bus} |
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2753 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2754 |
Slave information can be gathered with the subcommand \lstinline+slaves+: |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2755 |
|
1140
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2756 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_slaves} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2757 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2758 |
Below is a typical output: |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2759 |
|
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2760 |
\begin{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2761 |
$ `\textbf{ethercat slaves}` |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2762 |
0 0:0 PREOP + EK1100 Ethernet Kopplerklemme (2A E-Bus) |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2763 |
1 5555:0 PREOP + EL3162 2K. Ana. Eingang 0-10V |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2764 |
2 5555:1 PREOP + EL4102 2K. Ana. Ausgang 0-10V |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2765 |
3 5555:2 PREOP + EL2004 4K. Dig. Ausgang 24V, 0,5A |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2766 |
\end{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2767 |
|
369 | 2768 |
%------------------------------------------------------------------------------ |
2769 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2770 |
\subsection{SII Access} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2771 |
\label{sec:siiaccess} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2772 |
\index{SII!Access} |
369 | 2773 |
|
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2774 |
It is possible to directly read or write the complete SII contents of the |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2775 |
slaves. This was introduced for the reasons below: |
369 | 2776 |
|
2777 |
\begin{itemize} |
|
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2778 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2779 |
\item The format of the SII data is still in development and categories can be |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2780 |
added in the future. With read and write access, the complete memory contents |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2781 |
can be easily backed up and restored. |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2782 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2783 |
\item Some SII data fields have to be altered (like the alias address). A quick |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2784 |
writing must be possible for that. |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2785 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2786 |
\item Through reading access, analyzing category data is possible from user |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2787 |
space. |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2788 |
|
369 | 2789 |
\end{itemize} |
2790 |
||
1140
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2791 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sii_read} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2792 |
|
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2793 |
Reading out SII data is as easy as other commands. Though the data are in |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2794 |
binary format, analysis is easier with a tool like \textit{hexdump}: |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2795 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2796 |
\begin{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2797 |
$ `\textbf{ethercat sii\_read --slave 3 | hexdump}` |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2798 |
0000000 0103 0000 0000 0000 0000 0000 0000 008c |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2799 |
0000010 0002 0000 3052 07f0 0000 0000 0000 0000 |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2800 |
0000020 0000 0000 0000 0000 0000 0000 0000 0000 |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2801 |
... |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2802 |
\end{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2803 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2804 |
Backing up SII contents can easily done with a redirection: |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2805 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2806 |
\begin{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2807 |
$ `\textbf{ethercat sii\_read --slave 3 > sii-of-slave3.bin}` |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2808 |
\end{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2809 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2810 |
To download SII contents to a slave, writing access to the master's character |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2811 |
device is necessary (see section~\ref{sec:cdev}). |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2812 |
|
1140
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2813 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sii_write} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2814 |
|
1087
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2815 |
\begin{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2816 |
# `\textbf{ethercat sii\_write --slave 3 sii-of-slave3.bin}` |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2817 |
\end{lstlisting} |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2818 |
|
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2819 |
The SII contents will be checked for validity and then sent to the slave. The |
f1417824cee5
prepared command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1086
diff
changeset
|
2820 |
write operation may take a few seconds. |
369 | 2821 |
|
2822 |
%------------------------------------------------------------------------------ |
|
2823 |
||
1140
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2824 |
\subsection{Requesting application-layer states} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2825 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2826 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_states} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2827 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2828 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2829 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2830 |
\subsection{Generating slave description XML} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2831 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2832 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_xml} |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2833 |
|
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2834 |
%------------------------------------------------------------------------------ |
cc779f7d2496
Command-line help in the docs.
Florian Pose <fp@igh-essen.com>
parents:
1107
diff
changeset
|
2835 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2836 |
\section{System Integration} |
369 | 2837 |
\label{sec:system} |
2838 |
||
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2839 |
To integrate the EtherCAT master as a service into a running system, it comes |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2840 |
with an init script and a sysconfig file, that are described below. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2841 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2842 |
\subsection{Init Script} |
369 | 2843 |
\label{sec:init} |
2844 |
\index{Init script} |
|
2845 |
||
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2846 |
The EtherCAT master init script conforms to the requirements of the ``Linux |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2847 |
Standard Base'' (LSB\index{LSB}, \cite{lsb}). The script is installed to |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2848 |
\textit{etc/init.d/ethercat} below the installation prefix and has to be copied |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2849 |
(or better: linked) to the appropriate location (see |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2850 |
section~\ref{sec:install}), before the master can be inserted as a service. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2851 |
Please note, that the init script depends on the sysconfig file described |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2852 |
below. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2853 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2854 |
To provide service dependencies (i.~e. which services have to be started before |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2855 |
others) inside the init script code, LSB defines a special comment block. |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2856 |
System tools can extract this information to insert the EtherCAT init script at |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2857 |
the correct place in the startup sequence: |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2858 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2859 |
\lstinputlisting[firstline=38,lastline=48] |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2860 |
{../script/init.d/ethercat} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2861 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2862 |
\subsection{Sysconfig} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2863 |
\label{sec:sysconfig} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2864 |
\index{Sysconfig file} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2865 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2866 |
For persistent configuration, the init script uses a sysconfig file installed |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2867 |
to \textit{etc/sysconfig/ethercat} (below the installation prefix), that is |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2868 |
mandatory for the init script. The sysconfig file contains all configuration |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2869 |
variables needed to operate one or more masters. The documentation is inside |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2870 |
the file and included below: |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2871 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2872 |
\lstinputlisting[numbers=left,firstline=9,basicstyle=\ttfamily\scriptsize] |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2873 |
{../script/sysconfig/ethercat} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2874 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2875 |
\subsection{Service} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2876 |
\label{sec:service} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2877 |
\index{Service} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2878 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2879 |
After the init script and the sysconfig file are placed into the right |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2880 |
location, the EtherCAT master can be inserted as a service. The different Linux |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2881 |
distributions offer different ways to mark a service for starting and stopping |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2882 |
in certain runlevels. For example, SUSE Linux provides the \textit{insserv} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2883 |
command: |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2884 |
|
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2885 |
\begin{lstlisting} |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
2886 |
# `\textbf{insserv ethercat}` |
369 | 2887 |
\end{lstlisting} |
2888 |
||
2889 |
The init script can also be used for manually starting and stopping |
|
2890 |
the EtherCAT master. It has to be executed with one of the parameters |
|
379 | 2891 |
\texttt{start}, \texttt{stop}, \texttt{restart} or \texttt{status}. |
369 | 2892 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2893 |
\begin{lstlisting}[gobble=2] |
379 | 2894 |
# `\textbf{/etc/init.d/ethercat restart}` |
369 | 2895 |
Shutting down EtherCAT master done |
2896 |
Starting EtherCAT master done |
|
2897 |
\end{lstlisting} |
|
2898 |
||
2899 |
%------------------------------------------------------------------------------ |
|
2900 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2901 |
\section{Monitoring and Debugging} |
369 | 2902 |
\label{sec:debug} |
2903 |
\index{Monitoring} |
|
2904 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2905 |
For debugging purposes, every EtherCAT master registers a read-only network |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2906 |
interface \textit{ecX}, where X is a number, provided by the kernel on device |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2907 |
registration. While it is ``up'', the master forwards every frame sent and |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2908 |
received to this interface. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2909 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2910 |
This makes it possible to connect an network monitor (like Wireshark or |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2911 |
tcpdump) to the debug interface and monitor the EtherCAT frames. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2912 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2913 |
% FIXME schedule() |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2914 |
It has to be considered, that can be frame rate can be very high. The master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2915 |
state machine usually runs every kernel timer interrupt (usually up to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2916 |
\unit{1}{\kilo\hertz}) and with a connected application, the rate can be even |
369 | 2917 |
higher. |
2918 |
||
2919 |
\paragraph{Attention:} The socket buffers needed for the operation of |
|
2920 |
the debugging interface have to be allocated dynamically. Some Linux |
|
2921 |
realtime extensions do not allow this in realtime context! |
|
2922 |
||
2923 |
%------------------------------------------------------------------------------ |
|
2924 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2925 |
\chapter{Timing Aspects} |
369 | 2926 |
\label{sec:timing} |
2927 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2928 |
Although EtherCAT's timing is highly deterministic and therefore timing issues |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2929 |
are rare, there are a few aspects that can (and should be) dealt with. |
369 | 2930 |
|
2931 |
%------------------------------------------------------------------------------ |
|
2932 |
||
2933 |
\subsection{Realtime Interface Profiling} |
|
2934 |
\label{sec:timing-profile} |
|
2935 |
\index{Realtime!Profiling} |
|
2936 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2937 |
One of the most important timing aspects are the execution times of the |
369 | 2938 |
realtime interface functions, that are called in cyclic context. These |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2939 |
functions make up an important part of the overall timing of the application. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2940 |
To measure the timing of the functions, the following code was used: |
369 | 2941 |
|
2942 |
\begin{lstlisting}[gobble=2,language=C] |
|
2943 |
c0 = get_cycles(); |
|
2944 |
ecrt_master_receive(master); |
|
2945 |
c1 = get_cycles(); |
|
2946 |
ecrt_domain_process(domain1); |
|
2947 |
c2 = get_cycles(); |
|
2948 |
ecrt_master_run(master); |
|
2949 |
c3 = get_cycles(); |
|
2950 |
ecrt_master_send(master); |
|
2951 |
c4 = get_cycles(); |
|
2952 |
\end{lstlisting} |
|
2953 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2954 |
Between each call of an interface function, the CPU timestamp counter is read. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2955 |
The counter differences are converted to \micro\second\ with help of the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2956 |
\lstinline+cpu_khz+ variable, that contains the number of increments per |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2957 |
\milli\second. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2958 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2959 |
For the actual measuring, a system with a \unit{2.0}{\giga\hertz} CPU was used, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2960 |
that ran the above code in an RTAI thread with a period of |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2961 |
\unit{100}{\micro\second}. The measuring was repeated $n = 100$ times and the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2962 |
results were averaged. These can be seen in table~\ref{tab:profile}. |
369 | 2963 |
|
2964 |
\begin{table}[htpb] |
|
2965 |
\centering |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2966 |
\caption{Profiling of a Realtime Cycle on a \unit{2.0}{\giga\hertz} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2967 |
Processor} |
369 | 2968 |
\label{tab:profile} |
2969 |
\vspace{2mm} |
|
2970 |
\begin{tabular}{l|r|r} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2971 |
Element & Mean Duration [\second] & Standard Deviancy [\micro\second] \\ |
369 | 2972 |
\hline |
2973 |
\textit{ecrt\_master\_receive()} & 8.04 & 0.48\\ |
|
2974 |
\textit{ecrt\_domain\_process()} & 0.14 & 0.03\\ |
|
2975 |
\textit{ecrt\_master\_run()} & 0.29 & 0.12\\ |
|
2976 |
\textit{ecrt\_master\_send()} & 2.18 & 0.17\\ \hline |
|
2977 |
Complete Cycle & 10.65 & 0.69\\ \hline |
|
2978 |
\end{tabular} |
|
2979 |
\end{table} |
|
2980 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2981 |
It is obvious, that the functions accessing hardware make up the |
369 | 2982 |
lion's share. The \textit{ec\_master\_receive()} executes the ISR of |
2983 |
the Ethernet device, analyzes datagrams and copies their contents into |
|
2984 |
the memory of the datagram objects. The \textit{ec\_master\_send()} |
|
2985 |
assembles a frame out of different datagrams and copies it to the |
|
2986 |
hardware buffers. Interestingly, this makes up only a quarter of the |
|
2987 |
receiving time. |
|
2988 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2989 |
The functions that only operate on the masters internal data structures are |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2990 |
very fast ($\Delta t < \unit{1}{\micro\second}$). Interestingly the runtime of |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2991 |
\textit{ec\_domain\_process()} has a small standard deviancy relative to the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2992 |
mean value, while this ratio is about twice as big for |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2993 |
\textit{ec\_master\_run()}: This probably results from the latter function |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2994 |
having to execute code depending on the current state and the different state |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2995 |
functions are more or less complex. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2996 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2997 |
For a realtime cycle makes up about \unit{10}{\micro\second}, the theoretical |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
2998 |
frequency can be up to \unit{100}{\kilo\hertz}. For two reasons, this frequency |
369 | 2999 |
keeps being theoretical: |
3000 |
||
3001 |
\begin{enumerate} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3002 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3003 |
\item The processor must still be able to run the operating system between the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3004 |
realtime cycles. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3005 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3006 |
\item The EtherCAT frame must be sent and received, before the next realtime |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3007 |
cycle begins. The determination of the bus cycle time is difficult and covered |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3008 |
in section~\ref{sec:timing-bus}. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3009 |
|
369 | 3010 |
\end{enumerate} |
3011 |
||
3012 |
%------------------------------------------------------------------------------ |
|
3013 |
||
3014 |
\subsection{Bus Cycle Measuring} |
|
3015 |
\label{sec:timing-bus} |
|
3016 |
\index{Bus cycle} |
|
3017 |
||
3018 |
For measuring the time, a frame is ``on the wire'', two timestamps |
|
3019 |
must be be taken: |
|
3020 |
||
3021 |
\begin{enumerate} |
|
3022 |
\item The time, the Ethernet hardware begins with physically sending |
|
3023 |
the frame. |
|
3024 |
\item The time, the frame is completely received by the Ethernet |
|
3025 |
hardware. |
|
3026 |
\end{enumerate} |
|
3027 |
||
3028 |
Both times are difficult to determine. The first reason is, that the |
|
3029 |
interrupts are disabled and the master is not notified, when a frame |
|
3030 |
is sent or received (polling would distort the results). The second |
|
3031 |
reason is, that even with interrupts enabled, the time from the event |
|
3032 |
to the notification is unknown. Therefore the only way to confidently |
|
3033 |
determine the bus cycle time is an electrical measuring. |
|
3034 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3035 |
Anyway, the bus cycle time is an important factor when designing realtime code, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3036 |
because it limits the maximum frequency for the cyclic task of the application. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3037 |
In practice, these timing parameters are highly dependent on the hardware and |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3038 |
often a trial and error method must be used to determine the limits of the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3039 |
system. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3040 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3041 |
The central question is: What happens, if the cycle frequency is too high? The |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3042 |
answer is, that the EtherCAT frames that have been sent at the end of the cycle |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3043 |
are not yet received, when the next cycle starts. First this is noticed by |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3044 |
\textit{ecrt\_domain\_process()}, because the working counter of the process |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3045 |
data datagrams were not increased. The function will notify the user via |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3046 |
Syslog\footnote{To limit Syslog output, a mechanism has been implemented, that |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3047 |
outputs a summarized notification at maximum once a second.}. In this case, the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3048 |
process data keeps being the same as in the last cycle, because it is not |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3049 |
erased by the domain. When the domain datagrams are queued again, the master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3050 |
notices, that they are already queued (and marked as sent). The master will |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3051 |
mark them as unsent again and output a warning, that datagrams were |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3052 |
``skipped''. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3053 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3054 |
On the mentioned \unit{2.0}{\giga\hertz} system, the possible cycle frequency |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3055 |
can be up to \unit{25}{\kilo\hertz} without skipped frames. This value can |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3056 |
surely be increased by choosing faster hardware. Especially the RealTek network |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3057 |
hardware could be replaced by a faster one. Besides, implementing a dedicated |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3058 |
ISR for EtherCAT devices would also contribute to increasing the latency. These |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3059 |
are two points on the author's to-do list. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3060 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3061 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3062 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3063 |
\chapter{Installation} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3064 |
\label{sec:installation} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3065 |
\index{Master!Installation} |
369 | 3066 |
|
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3067 |
\section{Building the software} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3068 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3069 |
The current EtherCAT master code is available at~\cite{etherlab} or can be |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3070 |
obtained from the EtherLab CD. The \textit{tar.bz2} file has to be unpacked |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3071 |
with the commands below (or similar): |
369 | 3072 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3073 |
\begin{lstlisting}[gobble=2] |
487 | 3074 |
`\$` `\textbf{tar xjf ethercat-\masterversion.tar.bz2}` |
3075 |
`\$` `\textbf{cd ethercat-\masterversion/}` |
|
374
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3076 |
\end{lstlisting} |
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3077 |
|
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3078 |
The tarball was created with GNU Autotools, so the build process |
487 | 3079 |
follows the below commands: |
369 | 3080 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3081 |
\begin{lstlisting}[gobble=2] |
379 | 3082 |
`\$` `\textbf{./configure}` |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3083 |
`\$` `\textbf{make}` |
487 | 3084 |
`\$` `\textbf{make modules}` |
374
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3085 |
\end{lstlisting} |
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3086 |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3087 |
Table~\ref{tab:config} lists important configuration switches and options. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3088 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3089 |
\begin{table} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3090 |
\caption{Configuration options} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3091 |
\label{tab:config} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3092 |
\vspace{2mm} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3093 |
\begin{tabular}{l|p{.3\textwidth}|l} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3094 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3095 |
\bf Option/Switch & \bf Description & \bf Default\\\hline |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3096 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3097 |
\lstinline+--prefix+ & Installation prefix & \textit{/opt/etherlab}\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3098 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3099 |
\lstinline+--with-linux-dir+ & Linux kernel sources & Use running kernel\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3100 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3101 |
\lstinline+--with-rtai-dir+ & RTAI path (only for RTAI example) & \\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3102 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3103 |
\hline |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3104 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3105 |
\lstinline+--enable-eoe+ & Enable EoE support & yes\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3106 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3107 |
\lstinline+--enable-cycles+ & Use CPU timestamp counter. Enable this on Intel |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3108 |
architecture to get finer timing calculation. & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3109 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3110 |
\lstinline+--enable-debug-if+ & Create a debug interface for each master & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3111 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3112 |
\lstinline+--enable-debug-ring+ & Create a debug ring to record frames & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3113 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3114 |
\hline |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3115 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3116 |
\lstinline+--enable-8139too+ & Build the 8139too driver & yes\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3117 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3118 |
\lstinline+--with-8139too-kernel+ & 8139too kernel & $\dagger$\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3119 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3120 |
\lstinline+--enable-e100+ & Build the e100 driver & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3121 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3122 |
\lstinline+--with-e100-kernel+ & e100 kernel & $\dagger$\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3123 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3124 |
\lstinline+--enable-forcedeth+ & Enable forcedeth driver & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3125 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3126 |
\lstinline+--with-forcedeth-kernel+ & forcedeth kernel & $\dagger$\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3127 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3128 |
\lstinline+--enable-e1000+ & Enable e1000 driver & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3129 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3130 |
\lstinline+--with-e1000-kernel+ & e1000 kernel & $\dagger$\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3131 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3132 |
\lstinline+--enable-r8169+ & Enable r8169 driver & no\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3133 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3134 |
\lstinline+--with-r8169-kernel+ & r8169 kernel & $\dagger$\\ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3135 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3136 |
\end{tabular} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3137 |
\vspace{2mm} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3138 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3139 |
\begin{description} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3140 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3141 |
\item[$\dagger$] If this option is not specified, the kernel version to use is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3142 |
extracted from the Linux kernel sources. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3143 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3144 |
\end{description} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3145 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3146 |
\end{table} |
487 | 3147 |
|
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3148 |
\section{Building the documentation} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3149 |
\label{sec:gendoc} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3150 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3151 |
The source code is documented using Doxygen~\cite{doxygen}. To build the HTML |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3152 |
documentation, you must have the Doxygen software installed. The below command |
1095 | 3153 |
will generate the documents in the subdirectory \textit{doxygen-output}: |
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3154 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3155 |
\begin{lstlisting} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3156 |
$ `\textbf{make doc}` |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3157 |
\end{lstlisting} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3158 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3159 |
To view them, point your browser to \textit{doxygen-output/html/index.html}. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3160 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3161 |
\section{Installation} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3162 |
|
1106
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3163 |
The below commands have to be entered as \textit{root}: The first one will |
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3164 |
install the EtherCAT header, init script, sysconfig file and the user space |
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3165 |
tools to the prefix path. The second one will install the kernel modules to the |
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3166 |
kernel's modules directory. The following \lstinline+depmod+ call is necessary |
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3167 |
to include the kernel modules into the \textit{modules.dep} file to make it |
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3168 |
available to the \lstinline+modprobe+ command, used in the init script. |
369 | 3169 |
|
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3170 |
\begin{lstlisting} |
1106
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3171 |
# `\textbf{make install}` |
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3172 |
# `\textbf{make modules\_install}` |
1106
745a0cc03143
Added depmod call to docs.
Florian Pose <fp@igh-essen.com>
parents:
1095
diff
changeset
|
3173 |
# `\textbf{depmod}` |
369 | 3174 |
\end{lstlisting} |
3175 |
||
1095 | 3176 |
If the target kernel's modules directory is not under \textit{/lib/modules}, a |
3177 |
different destination directory can be specified with the \lstinline+DESTDIR+ |
|
3178 |
make variable. For example: |
|
487 | 3179 |
|
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3180 |
\begin{lstlisting} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3181 |
# `\textbf{make DESTDIR=/vol/nfs/root modules\_install}` |
487 | 3182 |
\end{lstlisting} |
3183 |
||
3184 |
This command will install the compiled kernel modules to |
|
3185 |
\textit{/vol/nfs/root/lib/modules}, prepended by the kernel release. |
|
3186 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3187 |
If the EtherCAT master shall be run as a service\footnote{Even if the EtherCAT |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3188 |
master shall not be loaded on system startup, the use of the init script is |
1086
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
3189 |
recommended for manual (un-)loading.} (see section~\ref{sec:system}), the init |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
3190 |
script and the sysconfig file have to be copied (or linked) to the appropriate |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
3191 |
locations. The below example is suitable for SUSE Linux. It may vary for other |
722ead4ecc22
Doc: Architecture, master module, system integration.
Florian Pose <fp@igh-essen.com>
parents:
1085
diff
changeset
|
3192 |
distributions. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3193 |
|
1107 | 3194 |
% FIXME relative ln -s? |
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3195 |
\begin{lstlisting} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3196 |
# `\textbf{cd /opt/etherlab}` |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3197 |
# `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}` |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3198 |
# `\textbf{ln -s etc/init.d/ethercat /etc/init.d/}` |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3199 |
# `\textbf{insserv ethercat}` |
374
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3200 |
\end{lstlisting} |
e43a29f9079e
Updated documentation concerning autotools/installation.
Florian Pose <fp@igh-essen.com>
parents:
371
diff
changeset
|
3201 |
|
376
d1441d87f5c1
Documentation: EtherLab-CD; obtaining the DEVICE_INDEX.
Florian Pose <fp@igh-essen.com>
parents:
374
diff
changeset
|
3202 |
Now the sysconfig file \texttt{/etc/sysconfig/ethercat} (see |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3203 |
section~\ref{sec:sysconfig}) has to be customized. The minimal customization |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3204 |
is to set the \lstinline+MASTER0_DEVICE+ variable to the MAC address of the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3205 |
Ethernet device to use (or \lstinline+ff:ff:ff:ff:ff:ff+ to use the first |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3206 |
device offered) and selecting the driver(s) to load via the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3207 |
\lstinline+DEVICE_MODULES+ variable. |
369 | 3208 |
|
3209 |
After the basic configuration is done, the master can be started with |
|
3210 |
the below command: |
|
3211 |
||
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3212 |
\begin{lstlisting} |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3213 |
# `\textbf{/etc/init.d/ethercat start}` |
369 | 3214 |
\end{lstlisting} |
3215 |
||
3216 |
The operation of the master can be observed by looking at the |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3217 |
Syslog\index{Syslog} messages, which should look like the ones below. If |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3218 |
EtherCAT slaves are connected to the master's EtherCAT device, the activity |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3219 |
indicators should begin to flash. |
369 | 3220 |
|
3221 |
\begin{lstlisting}[numbers=left] |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3222 |
EtherCAT: Master driver `\masterversion` |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3223 |
EtherCAT: 1 master waiting for devices. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3224 |
EtherCAT Intel(R) PRO/1000 Network Driver - version 6.0.60-k2 |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3225 |
Copyright (c) 1999-2005 Intel Corporation. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3226 |
PCI: Found IRQ 12 for device 0000:01:01.0 |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3227 |
PCI: Sharing IRQ 12 with 0000:00:1d.2 |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3228 |
PCI: Sharing IRQ 12 with 0000:00:1f.1 |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3229 |
EtherCAT: Accepting device 00:0E:0C:DA:A2:20 for master 0. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3230 |
EtherCAT: Starting master thread. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3231 |
ec_e1000: ec0: e1000_probe: Intel(R) PRO/1000 Network |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3232 |
Connection |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3233 |
ec_e1000: ec0: e1000_watchdog_task: NIC Link is Up 100 Mbps |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3234 |
Full Duplex |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3235 |
EtherCAT: Link state changed to UP. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3236 |
EtherCAT: 7 slave(s) responding. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3237 |
EtherCAT: Slave states: PREOP. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3238 |
EtherCAT: Scanning bus. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3239 |
EtherCAT: Bus scanning completed in 431 ms. |
369 | 3240 |
\end{lstlisting} |
3241 |
||
3242 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3243 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3244 |
\item[\linenum{1} -- \linenum{2}] The master module is loading, and one master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3245 |
is initialized. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3246 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3247 |
\item[\linenum{3} -- \linenum{8}] The EtherCAT-capable e1000 driver is |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3248 |
loading. The master accepts the device with the address |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3249 |
\lstinline+00:0E:0C:DA:A2:20+. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3250 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3251 |
\item[\linenum{9} -- \linenum{16}] The master goes to idle phase, starts its |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3252 |
state machine and begins scanning the bus. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3253 |
|
369 | 3254 |
\end{description} |
3255 |
||
3256 |
%------------------------------------------------------------------------------ |
|
3257 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3258 |
\chapter{Application examples} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3259 |
\label{chapter:examples} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3260 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3261 |
This chapter will give practical examples of how to use the EtherCAT master via |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3262 |
the realtime interface by writing an application module. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3263 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3264 |
%------------------------------------------------------------------------------ |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3265 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3266 |
\section{Minimal Example} |
369 | 3267 |
\label{sec:mini} |
3268 |
\index{Examples!Minimal} |
|
3269 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3270 |
This section will explain the use of the EtherCAT master from a minimal kernel |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3271 |
module. The complete module code is obtainable as a part of the EtherCAT master |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3272 |
code release (see~\cite{etherlab}, file \textit{examples/mini/mini.c}). |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3273 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3274 |
The minimal example uses a kernel timer (software interrupt) to generate a |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3275 |
cyclic task. After the timer function is executed, it re-adds itself with a |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3276 |
delay of one \textit{jiffy}\index{jiffies}, which results in a timer frequency |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3277 |
of \textit{HZ}\nomenclature{HZ}{Kernel macro containing the timer interrupt |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3278 |
frequency} |
369 | 3279 |
|
3280 |
The module-global variables, needed to operate the master can be seen |
|
3281 |
in listing~\ref{lst:minivar}. |
|
3282 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3283 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Minimal |
369 | 3284 |
variables},label=lst:minivar] |
3285 |
struct timer_list timer; |
|
3286 |
||
3287 |
ec_master_t *master = NULL; |
|
3288 |
ec_domain_t *domain1 = NULL; |
|
3289 |
||
3290 |
void *r_dig_in, *r_ana_out; |
|
3291 |
||
3292 |
ec_pdo_reg_t domain1_pdos[] = { |
|
3293 |
{"1", Beckhoff_EL1014_Inputs, &r_dig_in}, |
|
3294 |
{"2", Beckhoff_EL4132_Ouput1, &r_ana_out}, |
|
3295 |
{} |
|
3296 |
}; |
|
3297 |
\end{lstlisting} |
|
3298 |
||
3299 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3300 |
\item[\linenum{1}] There is a timer object |
369 | 3301 |
declared, that is needed to tell the kernel to install a timer and |
3302 |
execute a certain function, if it runs out. This is done by a |
|
3303 |
variable of the \textit{timer\_list} structure. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3304 |
\item[\linenum{3} -- \linenum{4}] There |
369 | 3305 |
is a pointer declared, that will later point to a requested EtherCAT |
3306 |
master. Additionally there is a pointer to a domain object needed, |
|
3307 |
that will manage process data IO. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3308 |
\item[\linenum{6}] The pointers \textit{r\_*} |
369 | 3309 |
will later point to the \underline{r}aw process data values inside |
3310 |
the domain memory. The addresses they point to will be set during a |
|
3311 |
call to \textit{ec\_\-master\_\-activate()}, that will create the |
|
3312 |
domain memory and configure the mapped process data image. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3313 |
\item[\linenum{8} -- \linenum{12}] The |
814 | 3314 |
configuration of the mapping of certain Pdos in a domain can easily |
369 | 3315 |
be done with the help of an initialization array of the |
3316 |
\textit{ec\_pdo\_reg\_t} type, defined as part of the realtime |
|
3317 |
interface. Each record must contain the ASCII bus-address of the |
|
3318 |
slave (see section~\ref{sec:addr}), the slave's vendor ID and |
|
814 | 3319 |
product code, and the index and subindex of the Pdo to map (these |
369 | 3320 |
four fields can be specified in junction, by using one of the |
3321 |
defines out of the \textit{include/ecdb.h} header). The last field |
|
3322 |
has to be the address of the process data pointer, so it can later |
|
3323 |
be redirected appropriately. Attention: The initialization array |
|
3324 |
must end with an empty record (\textit{\{\}})! |
|
3325 |
\end{description} |
|
3326 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3327 |
The initialization of the minimal application is done by the ``Minimal init |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3328 |
function'' in listing~\ref{lst:miniinit}. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3329 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3330 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Minimal init |
369 | 3331 |
function},label={lst:miniinit}] |
3332 |
int __init init_mini_module(void) |
|
3333 |
{ |
|
3334 |
if (!(master = ecrt_request_master(0))) { |
|
3335 |
goto out_return; |
|
3336 |
} |
|
3337 |
||
3338 |
if (!(domain1 = ecrt_master_create_domain(master))) { |
|
3339 |
goto out_release_master; |
|
3340 |
} |
|
3341 |
||
3342 |
if (ecrt_domain_register_pdo_list(domain1, |
|
3343 |
domain1_pdos)) { |
|
3344 |
goto out_release_master; |
|
3345 |
} |
|
3346 |
||
3347 |
if (ecrt_master_activate(master)) { |
|
3348 |
goto out_release_master; |
|
3349 |
} |
|
3350 |
||
3351 |
ecrt_master_prepare(master); |
|
3352 |
||
3353 |
init_timer(&timer); |
|
3354 |
timer.function = run; |
|
3355 |
timer.expires = jiffies + 10; |
|
3356 |
add_timer(&timer); |
|
3357 |
||
3358 |
return 0; |
|
3359 |
||
3360 |
out_release_master: |
|
3361 |
ecrt_release_master(master); |
|
3362 |
out_return: |
|
3363 |
return -1; |
|
3364 |
} |
|
3365 |
\end{lstlisting} |
|
3366 |
||
3367 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3368 |
\item[\linenum{3}] It is tried to request the |
369 | 3369 |
first EtherCAT master (index 0). On success, the |
3370 |
\textit{ecrt\_\-request\_\-master()} function returns a pointer to |
|
3371 |
the reserved master, that can be used as an object to following |
|
3372 |
functions calls. On failure, the function returns \textit{NULL}. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3373 |
\item[\linenum{7}] In order to exchange process |
369 | 3374 |
data, a domain object has to be created. The |
3375 |
\textit{ecrt\_\-master\_\-create\_domain()} function also returns a |
|
3376 |
pointer to the created domain, or \textit{NULL} in error case. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3377 |
\item[\linenum{11}] The registration of domain |
814 | 3378 |
Pdos with an initialization array results in a single function call. |
369 | 3379 |
Alternatively the data fields could be registered with individual |
3380 |
calls of \textit{ecrt\_domain\_register\_pdo()}. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3381 |
\item[\linenum{16}] After the configuration of |
369 | 3382 |
process data mapping, the master can be activated for cyclic |
3383 |
operation. This will configure all slaves and bring them into |
|
379 | 3384 |
OP state. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3385 |
\item[\linenum{20}] This call is needed to avoid |
369 | 3386 |
a case differentiation in cyclic operation: The first operation in |
3387 |
cyclic mode is a receive call. Due to the fact, that there is |
|
3388 |
nothing to receive during the first cycle, there had to be an |
|
3389 |
\textit{if}-statement to avoid a warning. A call to |
|
3390 |
\textit{ec\_master\_prepare()} sends a first datagram containing a |
|
3391 |
process data exchange datagram, so that the first receive call will |
|
3392 |
not fail. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3393 |
\item[\linenum{22} -- \linenum{25}] The |
369 | 3394 |
master is now ready for cyclic operation. The kernel timer that |
3395 |
cyclically executes the \textit{run()} function is initialized and |
|
3396 |
started. |
|
3397 |
\end{description} |
|
3398 |
||
3399 |
The coding of a cleanup function fo the minimal module can be seen in |
|
3400 |
listing~\ref{lst:miniclean}. |
|
3401 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3402 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Minimal cleanup |
369 | 3403 |
function},label={lst:miniclean}] |
3404 |
void __exit cleanup_mini_module(void) |
|
3405 |
{ |
|
3406 |
del_timer_sync(&timer); |
|
3407 |
ecrt_master_deactivate(master); |
|
3408 |
ecrt_release_master(master); |
|
3409 |
} |
|
3410 |
\end{lstlisting} |
|
3411 |
||
3412 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3413 |
\item[\linenum{3}] To cleanup the module, it it |
369 | 3414 |
necessary to stop the cyclic processing. This is done by a call to |
3415 |
\textit{del\_timer\_sync()} which safely removes a queued timer |
|
3416 |
object. It is assured, that no cyclic work will be done after this |
|
3417 |
call returns. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3418 |
\item[\linenum{4}] This call deactivates the |
379 | 3419 |
master, which results in all slaves being brought to their INIT |
3420 |
state again. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3421 |
\item[\linenum{5}] This call releases the master, |
369 | 3422 |
removes any existing configuration and silently starts the idle |
3423 |
mode. The value of the master pointer is invalid after this call and |
|
3424 |
the module can be safely unloaded. |
|
3425 |
\end{description} |
|
3426 |
||
3427 |
The final part of the minimal module is that for the cyclic work. Its |
|
3428 |
coding can be seen in listing~\ref{lst:minirun}. |
|
3429 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3430 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Minimal cyclic |
369 | 3431 |
function},label={lst:minirun}] |
3432 |
void run(unsigned long data) |
|
3433 |
{ |
|
3434 |
static uint8_t dig_in_0; |
|
3435 |
||
3436 |
ecrt_master_receive(master); |
|
3437 |
ecrt_domain_process(domain1); |
|
3438 |
||
3439 |
dig_in_0 = EC_READ_BIT(r_dig_in, 0); |
|
3440 |
EC_WRITE_S16(r_ana_out, dig_in_0 * 0x3FFF); |
|
3441 |
||
3442 |
ecrt_master_run(master); |
|
3443 |
ecrt_master_send(master); |
|
3444 |
||
3445 |
timer.expires += 1; // frequency = HZ |
|
3446 |
add_timer(&timer); |
|
3447 |
} |
|
3448 |
\end{lstlisting} |
|
3449 |
||
3450 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3451 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3452 |
\item[\linenum{5}] The cyclic processing starts with receiving datagrams, that |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3453 |
were sent in the last cycle. The frames containing these datagrams have to be |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3454 |
received by the network interface card prior to this call. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3455 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3456 |
\item[\linenum{6}] The process data of domain 1 has been automatically copied |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3457 |
into domain memory while datagram reception. This call checks the working |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3458 |
counter for changes and re-queues the domain's datagram for sending. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3459 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3460 |
\item[\linenum{8}] This is an example for reading out a bit-oriented process |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3461 |
data value (i.~e. bit 0) via the \textit{EC\_READ\_BIT()} macro. See |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3462 |
section~\ref{sec:macros} for more information about those macros. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3463 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3464 |
\item[\linenum{9}] This line shows how to write a signed, 16-bit process data |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3465 |
value. In this case, the slave is able to output voltages of |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3466 |
\unit{-10--+10}{\volt} with a resolution of \unit{16}{bit}. This write command |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3467 |
outputs either \unit{0}{\volt} or \unit{+5}{\volt}, depending of the value of |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3468 |
\textit{dig\_in\_0}. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3469 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3470 |
\item[\linenum{11}] This call runs the master's operation state machine (see |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3471 |
section~\ref{sec:fsm-op}). A single state is processed, and datagrams are |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3472 |
queued. Mainly bus observation is done: The bus state is determined and in case |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3473 |
of slaves that lost their configuration, reconfiguration is tried. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3474 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3475 |
\item[\linenum{12}] This method sends all queued datagrams, in this case the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3476 |
domain's datagram and one of the master state machine. In best case, all |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3477 |
datagrams fit into one frame. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3478 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3479 |
\item[\linenum{14} -- \linenum{15}] Kernel timers are implemented as |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3480 |
``one-shot'' timers, so they have to be re-added after each execution. The time |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3481 |
of the next execution is specified in \textit{jiffies} and will happen at the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3482 |
time of the next system timer interrupt. This results in the \textit{run()} |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3483 |
function being executed with a frequency of \textit{HZ}. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3484 |
|
369 | 3485 |
\end{description} |
3486 |
||
3487 |
%------------------------------------------------------------------------------ |
|
3488 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3489 |
\section{RTAI Example} |
369 | 3490 |
\label{sec:rtai} |
3491 |
\index{Examples!RTAI} |
|
3492 |
||
3493 |
The whole code can be seen in the EtherCAT master code release |
|
3494 |
(see~\cite{etherlab}, file \textit{examples/rtai/rtai\_sample.c}). |
|
3495 |
||
3496 |
Listing~\ref{lst:rtaivar} shows the defines and global variables |
|
3497 |
needed for a minimal RTAI module with EtherCAT processing. |
|
3498 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3499 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI task |
369 | 3500 |
declaration},label={lst:rtaivar}] |
3501 |
#define FREQUENCY 10000 |
|
3502 |
#define TIMERTICKS (1000000000 / FREQUENCY) |
|
3503 |
||
3504 |
RT_TASK task; |
|
3505 |
\end{lstlisting} |
|
3506 |
||
3507 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3508 |
\item[\linenum{1} -- \linenum{2}] RTAI |
369 | 3509 |
takes the cycle period as nanoseconds, so the easiest way is to |
3510 |
define a frequency and convert it to a cycle time in nanoseconds. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3511 |
\item[\linenum{4}] The \textit{task} variable |
369 | 3512 |
later contains information about the running RTAI task. |
3513 |
\end{description} |
|
3514 |
||
3515 |
Listing~\ref{lst:rtaiinit} shows the module init function for the RTAI |
|
3516 |
module. Most lines are the same as in listing~\ref{lst:miniinit}, |
|
3517 |
differences come up when starting the cyclic code. |
|
3518 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3519 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI module init |
369 | 3520 |
function},label={lst:rtaiinit}] |
3521 |
int __init init_mod(void) |
|
3522 |
{ |
|
3523 |
RTIME requested_ticks, tick_period, now; |
|
3524 |
||
3525 |
if (!(master = ecrt_request_master(0))) { |
|
3526 |
goto out_return; |
|
3527 |
} |
|
3528 |
||
3529 |
if (!(domain1 = ecrt_master_create_domain(master))) { |
|
3530 |
goto out_release_master; |
|
3531 |
} |
|
3532 |
||
3533 |
if (ecrt_domain_register_pdo_list(domain1, |
|
3534 |
domain1_pdos)) { |
|
3535 |
goto out_release_master; |
|
3536 |
} |
|
3537 |
||
3538 |
if (ecrt_master_activate(master)) { |
|
3539 |
goto out_release_master; |
|
3540 |
} |
|
3541 |
||
3542 |
ecrt_master_prepare(master); |
|
3543 |
||
3544 |
requested_ticks = nano2count(TIMERTICKS); |
|
3545 |
tick_period = start_rt_timer(requested_ticks); |
|
3546 |
||
3547 |
if (rt_task_init(&task, run, 0, 2000, 0, 1, NULL)) { |
|
3548 |
goto out_stop_timer; |
|
3549 |
} |
|
3550 |
||
3551 |
now = rt_get_time(); |
|
3552 |
if (rt_task_make_periodic(&task, now + tick_period, |
|
3553 |
tick_period)) { |
|
3554 |
goto out_stop_task; |
|
3555 |
} |
|
3556 |
||
3557 |
return 0; |
|
3558 |
||
3559 |
out_stop_task: |
|
3560 |
rt_task_delete(&task); |
|
3561 |
out_stop_timer: |
|
3562 |
stop_rt_timer(); |
|
3563 |
out_deactivate: |
|
3564 |
ecrt_master_deactivate(master); |
|
3565 |
out_release_master: |
|
3566 |
ecrt_release_master(master); |
|
3567 |
out_return: |
|
3568 |
return -1; |
|
3569 |
} |
|
3570 |
\end{lstlisting} |
|
3571 |
||
3572 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3573 |
\item[\linenum{24} -- \linenum{25}] The |
369 | 3574 |
nanoseconds are converted to RTAI timer ticks and an RTAI timer is |
3575 |
started. \textit{tick\_period} will be the ``real'' number of ticks |
|
3576 |
used for the timer period (which can be different to the requested |
|
3577 |
one). |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3578 |
\item[\linenum{27}] The RTAI task is initialized |
369 | 3579 |
by specifying the cyclic function, the parameter to hand over, the |
3580 |
stack size, priority, a flag that tells, if the function will use |
|
3581 |
floating point operations and a signal handler. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3582 |
\item[\linenum{32}] The task is made periodic by |
369 | 3583 |
specifying a start time and a period. |
3584 |
\end{description} |
|
3585 |
||
3586 |
The cleanup function of the RTAI module in listing~\ref{lst:rtaiclean} |
|
3587 |
is nearly as simple as that of the minimal module. |
|
3588 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3589 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI module |
369 | 3590 |
cleanup function},label={lst:rtaiclean}] |
3591 |
void __exit cleanup_mod(void) |
|
3592 |
{ |
|
3593 |
rt_task_delete(&task); |
|
3594 |
stop_rt_timer(); |
|
3595 |
ecrt_master_deactivate(master); |
|
3596 |
ecrt_release_master(master); |
|
3597 |
rt_sem_delete(&master_sem); |
|
3598 |
} |
|
3599 |
\end{lstlisting} |
|
3600 |
||
3601 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3602 |
\item[\linenum{2}] The RTAI task will be stopped |
369 | 3603 |
and deleted. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3604 |
\item[\linenum{3}] After that, the RTAI timer can |
369 | 3605 |
be stopped. |
3606 |
\end{description} |
|
3607 |
||
3608 |
The rest is the same as for the minimal module. |
|
3609 |
||
3610 |
Worth to mention is, that the cyclic function of the RTAI module |
|
3611 |
(listing~\ref{lst:rtairun}) has a slightly different architecture. The |
|
3612 |
function is not executed until returning for every cycle, but has an |
|
3613 |
infinite loop in it, that is placed in a waiting state for the rest of |
|
3614 |
each cycle. |
|
3615 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3616 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI module cyclic |
369 | 3617 |
function},label={lst:rtairun}] |
3618 |
void run(long data) |
|
3619 |
{ |
|
3620 |
while (1) { |
|
3621 |
ecrt_master_receive(master); |
|
3622 |
ecrt_domain_process(domain1); |
|
3623 |
||
3624 |
k_pos = EC_READ_U32(r_ssi_input); |
|
3625 |
||
3626 |
ecrt_master_run(master); |
|
3627 |
ecrt_master_send(master); |
|
3628 |
||
3629 |
rt_task_wait_period(); |
|
3630 |
} |
|
3631 |
} |
|
3632 |
\end{lstlisting} |
|
3633 |
||
3634 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3635 |
\item[\linenum{3}] The \textit{while (1)} loop |
369 | 3636 |
executes for the lifetime of the RTAI task. |
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3637 |
\item[\linenum{12}] The |
369 | 3638 |
\textit{rt\_task\_wait\_period()} function sets the process into a |
3639 |
sleeping state until the beginning of the next cycle. It also |
|
3640 |
checks, if the cyclic function has to be terminated. |
|
3641 |
\end{description} |
|
3642 |
||
3643 |
%------------------------------------------------------------------------------ |
|
3644 |
||
3645 |
\section{Concurrency Example} |
|
3646 |
\label{sec:concurrency} |
|
3647 |
\index{Examples!Concurrency} |
|
3648 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3649 |
As mentioned before, there can be concurrent access to the EtherCAT master. The |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3650 |
application and a EoE\index{EoE} process can compete for master access, for |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3651 |
example. In this case, the module has to provide the locking mechanism, because |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3652 |
it depends on the module's architecture which lock has to be used. The module |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3653 |
makes this locking mechanism available to the master through the master's |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3654 |
locking callbacks. |
369 | 3655 |
|
3656 |
In case of RTAI, the lock can be an RTAI semaphore, as shown in |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3657 |
listing~\ref{lst:convar}. A normal Linux semaphore would not be appropriate, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3658 |
because it could not block the RTAI task due to RTAI running in a higher domain |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3659 |
than the Linux kernel (see~\cite{rtai}). |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3660 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3661 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI semaphore for |
369 | 3662 |
concurrent access},label={lst:convar}] |
3663 |
SEM master_sem; |
|
3664 |
\end{lstlisting} |
|
3665 |
||
3666 |
The module has to implement the two callbacks for requesting and |
|
3667 |
releasing the master lock. An exemplary coding can be seen in |
|
3668 |
listing~\ref{lst:conlock}. |
|
3669 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3670 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI locking |
369 | 3671 |
callbacks for concurrent access},label={lst:conlock}] |
3672 |
int request_lock(void *data) |
|
3673 |
{ |
|
3674 |
rt_sem_wait(&master_sem); |
|
3675 |
return 0; |
|
3676 |
} |
|
3677 |
||
3678 |
void release_lock(void *data) |
|
3679 |
{ |
|
3680 |
rt_sem_signal(&master_sem); |
|
3681 |
} |
|
3682 |
\end{lstlisting} |
|
3683 |
||
3684 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3685 |
\item[\linenum{1}] The \textit{request\_lock()} |
369 | 3686 |
function has a data parameter. The master always passes the value, |
3687 |
that was specified when registering the callback function. This can |
|
3688 |
be used for handing the master pointer. Notice, that it has an |
|
3689 |
integer return value (see line 4). |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3690 |
\item[\linenum{3}] The call to |
369 | 3691 |
\textit{rt\_sem\_wait()} either returns at once, when the semaphore |
3692 |
was free, or blocks until the semaphore is freed again. In any case, |
|
3693 |
the semaphore finally is reserved for the process calling the |
|
3694 |
request function. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3695 |
\item[\linenum{4}] When the lock was requested |
369 | 3696 |
successfully, the function should return 0. The module can prohibit |
3697 |
requesting the lock by returning non-zero (see paragraph ``Tuning |
|
3698 |
the jitter'' below). |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3699 |
\item[\linenum{7}] The \textit{release\_lock()} |
369 | 3700 |
function gets the same argument passed, but has a void return value, |
3701 |
because is always succeeds. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3702 |
\item[\linenum{9}] The \textit{rt\_sem\_signal()} |
369 | 3703 |
function frees the semaphore, that was prior reserved with |
3704 |
\textit{rt\_sem\_wait()}. |
|
3705 |
\end{description} |
|
3706 |
||
3707 |
In the module's init function, the semaphore must be initialized, and |
|
3708 |
the callbacks must be passed to the EtherCAT master: |
|
3709 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3710 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Module init |
369 | 3711 |
function for concurrent access},label={lst:coninit}] |
3712 |
int __init init_mod(void) |
|
3713 |
{ |
|
3714 |
RTIME tick_period, requested_ticks, now; |
|
3715 |
||
3716 |
rt_sem_init(&master_sem, 1); |
|
3717 |
||
3718 |
if (!(master = ecrt_request_master(0))) { |
|
3719 |
goto out_return; |
|
3720 |
} |
|
3721 |
||
3722 |
ecrt_master_callbacks(master, request_lock, |
|
3723 |
release_lock, NULL); |
|
3724 |
// ... |
|
3725 |
\end{lstlisting} |
|
3726 |
||
3727 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3728 |
\item[\linenum{5}] The call to |
369 | 3729 |
\textit{rt\_sem\_init()} initializes the semaphore and sets its |
3730 |
value to 1, meaning that only one process can reserve the semaphore |
|
3731 |
without blocking. |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3732 |
\item[\linenum{11}] The callbacks are passed to |
369 | 3733 |
the master with a call to \textit{ecrt\_master\_callbacks()}. The |
3734 |
last parameter is the argument, that the master should pass with |
|
3735 |
each call to a callback function. Here it is not used and set to |
|
3736 |
\textit{NULL}. |
|
3737 |
\end{description} |
|
3738 |
||
3739 |
For the cyclic function being only one competitor for master access, |
|
3740 |
it has to request the lock like any other process. There is no need to |
|
3741 |
use the callbacks (which are meant for processes of lower priority), |
|
3742 |
so it can access the semaphore directly: |
|
3743 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3744 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI cyclic |
369 | 3745 |
function for concurrent access},label={lst:conrun}] |
3746 |
void run(long data) |
|
3747 |
{ |
|
3748 |
while (1) { |
|
3749 |
rt_sem_wait(&master_sem); |
|
3750 |
||
3751 |
ecrt_master_receive(master); |
|
3752 |
ecrt_domain_process(domain1); |
|
3753 |
||
3754 |
k_pos = EC_READ_U32(r_ssi_input); |
|
3755 |
||
3756 |
ecrt_master_run(master); |
|
3757 |
ecrt_master_send(master); |
|
3758 |
||
3759 |
rt_sem_signal(&master_sem); |
|
3760 |
rt_task_wait_period(); |
|
3761 |
} |
|
3762 |
} |
|
3763 |
\end{lstlisting} |
|
3764 |
||
3765 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3766 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3767 |
\item[\linenum{4}] Every access to the master has to be preceded by a call to |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3768 |
\textit{rt\_sem\_wait()}, because another instance might currently access the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3769 |
master. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3770 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3771 |
\item[\linenum{14}] When cyclic processing finished, the semaphore has to be |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3772 |
freed again, so that other processes have the possibility to access the master. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3773 |
|
369 | 3774 |
\end{description} |
3775 |
||
3776 |
A little change has to be made to the cleanup function in case of |
|
3777 |
concurrent master access. |
|
3778 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3779 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={RTAI module |
369 | 3780 |
cleanup function for concurrent access},label={lst:conclean}] |
3781 |
void __exit cleanup_mod(void) |
|
3782 |
{ |
|
3783 |
rt_task_delete(&task); |
|
3784 |
stop_rt_timer(); |
|
3785 |
ecrt_master_deactivate(master); |
|
3786 |
ecrt_release_master(master); |
|
3787 |
rt_sem_delete(&master_sem); |
|
3788 |
} |
|
3789 |
\end{lstlisting} |
|
3790 |
||
3791 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3792 |
\item[\linenum{7}] Upon module cleanup, the |
369 | 3793 |
semaphore has to be deleted, so that memory can be freed. |
3794 |
\end{description} |
|
3795 |
||
3796 |
\paragraph{Tuning the Jitter} |
|
3797 |
\index{Jitter} |
|
3798 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3799 |
Concurrent access leads to higher jitter for the application task, because |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3800 |
there are situations, in which the task has to wait for a process of lower |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3801 |
priority to finish accessing the master. In most cases this is acceptable, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3802 |
because a master access cycle (receive/process/send) only takes |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3803 |
\unit{10-20}{\micro\second} on recent systems, what would be the maximum |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3804 |
additional jitter. However some applications demand a minimum jitter. For this |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3805 |
reason the master access can be prohibited by the application: If the time, |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3806 |
another process wants to access the master, is to close to the beginning of the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3807 |
next application cycle, the module can disallow, that the lock is taken. In |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3808 |
this case, the request callback has to return $1$, meaning that the lock has |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3809 |
not been taken. The foreign process must abort its master access and try again |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3810 |
next time. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3811 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3812 |
This measure helps to significantly reducing the jitter produced by concurrent |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3813 |
master access. Below are excerpts of an example coding: |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3814 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3815 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Variables for |
369 | 3816 |
jitter reduction},label={lst:redvar}] |
3817 |
#define FREQUENCY 10000 // RTAI task frequency in Hz |
|
3818 |
// ... |
|
3819 |
cycles_t t_last_cycle = 0; |
|
3820 |
const cycles_t t_critical = cpu_khz * 1000 / FREQUENCY |
|
3821 |
- cpu_khz * 30 / 1000; |
|
3822 |
\end{lstlisting} |
|
3823 |
||
3824 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3825 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3826 |
\item[\linenum{3}] The variable \textit{t\_last\_cycle} holds the timer ticks |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3827 |
at the beginning of the last realtime cycle. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3828 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3829 |
\item[\linenum{4}] \textit{t\_critical} contains the number of ticks, that may |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3830 |
have passed since the beginning of the last cycle, until there is no more |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3831 |
foreign access possible. It is calculated by subtracting the ticks for |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3832 |
\unit{30}{\micro\second} from the ticks for a complete cycle. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3833 |
|
369 | 3834 |
\end{description} |
3835 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3836 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Cyclic function |
369 | 3837 |
with reduced jitter},label={lst:redrun}] |
3838 |
void run(long data) |
|
3839 |
{ |
|
3840 |
while (1) { |
|
3841 |
t_last_cycle = get_cycles(); |
|
3842 |
rt_sem_wait(&master_sem); |
|
3843 |
// ... |
|
3844 |
\end{lstlisting} |
|
3845 |
||
3846 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3847 |
\item[\linenum{4}] The ticks of the beginning of |
369 | 3848 |
the current realtime cycle are taken before reserving the semaphore. |
3849 |
\end{description} |
|
3850 |
||
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3851 |
\begin{lstlisting}[gobble=2,language=C,numbers=left,caption={Request callback |
369 | 3852 |
for reduced jitter},label={lst:redreq}] |
3853 |
int request_lock(void *data) |
|
3854 |
{ |
|
3855 |
// too close to the next RT cycle: deny access. |
|
3856 |
if (get_cycles() - t_last_cycle > t_critical) |
|
3857 |
return -1; |
|
3858 |
||
3859 |
// allow access |
|
3860 |
rt_sem_wait(&master_sem); |
|
3861 |
return 0; |
|
3862 |
} |
|
3863 |
\end{lstlisting} |
|
3864 |
||
3865 |
\begin{description} |
|
1085
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3866 |
|
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3867 |
\item[\linenum{4}] If the time of request is too close to the next realtime |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3868 |
cycle (here: \unit{<30}{\micro\second} before the estimated beginning), the |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3869 |
locking is denied. The requesting process must abort its cycle. |
c75cdcc5ce87
Started to re-write the documentation.
Florian Pose <fp@igh-essen.com>
parents:
917
diff
changeset
|
3870 |
|
369 | 3871 |
\end{description} |
3872 |
||
3873 |
%------------------------------------------------------------------------------ |
|
3874 |
||
3875 |
\begin{thebibliography}{99} |
|
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3876 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3877 |
\bibitem{etherlab} Ingenieurgemeinschaft IgH: EtherLab -- Open Source Toolkit |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3878 |
for rapid realtime code generation under Linux with Simulink/RTW and EtherCAT |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3879 |
technology. \url{http://etherlab.org/en}, 2008. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3880 |
|
369 | 3881 |
\bibitem{dlspec} IEC 61158-4-12: Data-link Protocol Specification. |
1095 | 3882 |
International Electrotechnical Commission (IEC), 2005. |
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3883 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3884 |
\bibitem{alspec} IEC 61158-6-12: Application Layer Protocol Specification. |
1095 | 3885 |
International Electrotechnical Commission (IEC), 2005. |
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3886 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3887 |
\bibitem{gpl} GNU General Public License, Version 2. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3888 |
\url{http://www.gnu.org/licenses/gpl.txt}. August~9, 2006. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3889 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3890 |
\bibitem{lsb} Linux Standard Base. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3891 |
\url{http://www.linuxfoundation.org/en/LSB}. August~9, 2006. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3892 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3893 |
\bibitem{wireshark} Wireshark. \url{http://www.wireshark.org}. 2008. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3894 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3895 |
\bibitem{automata} {\it Hopcroft, J.~E. / Ullman, J.~D.}: Introduction to |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3896 |
Automata Theory, Languages and Computation. Adison-Wesley, Reading, |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3897 |
Mass.~1979. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3898 |
|
369 | 3899 |
\bibitem{fsmmis} {\it Wagner, F. / Wolstenholme, P.}: State machine |
1094
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3900 |
misunderstandings. In: IEE journal ``Computing and Control Engineering'', |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3901 |
2004. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3902 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3903 |
\bibitem{rtai} RTAI. The RealTime Application Interface for Linux from DIAPM. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3904 |
\url{http://www.rtai.org}, 2006. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3905 |
|
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3906 |
\bibitem{doxygen} Doxygen. Source code documentation generator tool. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3907 |
\url{http://www.stack.nl/~dimitri/doxygen}, 2008. |
eb0258e53236
App interface; doxygen; bib.
Florian Pose <fp@igh-essen.com>
parents:
1087
diff
changeset
|
3908 |
|
369 | 3909 |
\end{thebibliography} |
3910 |
||
917
07b0ad9722a1
Fixed bug concerning listings package.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
3911 |
\printnomenclature |
369 | 3912 |
\addcontentsline{toc}{chapter}{\nomname} |
3913 |
\markleft{\nomname} |
|
3914 |
||
3915 |
\printindex |
|
3916 |
\markleft{Index} |
|
3917 |
||
3918 |
%------------------------------------------------------------------------------ |
|
3919 |
||
3920 |
\end{document} |
|
3921 |
||
3922 |
%------------------------------------------------------------------------------ |