18 \usepackage{listings} |
18 \usepackage{listings} |
19 \usepackage{svn} |
19 \usepackage{svn} |
20 \usepackage{textcomp} |
20 \usepackage{textcomp} |
21 \usepackage{url} |
21 \usepackage{url} |
22 \usepackage{SIunits} |
22 \usepackage{SIunits} |
23 \usepackage[pdfpagelabels,plainpages=false]{hyperref} |
23 \usepackage{hyperref} |
|
24 |
|
25 \hypersetup{pdfpagelabels,plainpages=false} |
|
26 \hypersetup{linkcolor=blue,colorlinks=true,urlcolor=blue} |
24 |
27 |
25 \setlength{\parskip}{0.8ex plus 0.8ex minus 0.5ex} |
28 \setlength{\parskip}{0.8ex plus 0.8ex minus 0.5ex} |
26 \setlength{\parindent}{0mm} |
29 \setlength{\parindent}{0mm} |
27 |
30 |
28 \setcounter{secnumdepth}{\subsubsectionlevel} |
31 \setcounter{secnumdepth}{\subsubsectionlevel} |
285 %------------------------------------------------------------------------------ |
288 %------------------------------------------------------------------------------ |
286 |
289 |
287 \section{License} |
290 \section{License} |
288 \label{sec:license} |
291 \label{sec:license} |
289 |
292 |
290 The master code is released under the terms and conditions of the GNU |
293 The master code is released under the terms and conditions of the GNU General |
291 General Public License\index{GPL} \cite{gpl} (version 2). Other |
294 Public License (GPL \cite{gpl})\index{GPL}, version 2. Other developers, that |
292 developers, that want to use EtherCAT with Linux systems, are invited |
295 want to use EtherCAT with Linux systems, are invited to use the master code or |
293 to use the master code or even participate on development. |
296 even participate on development. |
294 |
297 |
295 %------------------------------------------------------------------------------ |
298 %------------------------------------------------------------------------------ |
296 |
299 |
297 \chapter{Architecture} |
300 \chapter{Architecture} |
298 \label{sec:arch} |
301 \label{sec:arch} |
301 The EtherCAT master is integrated into the Linux 2.6 kernel. This was |
304 The EtherCAT master is integrated into the Linux 2.6 kernel. This was |
302 an early design decision, which has been made for several reasons: |
305 an early design decision, which has been made for several reasons: |
303 |
306 |
304 \begin{itemize} |
307 \begin{itemize} |
305 |
308 |
306 \item Kernel code has significantly better realtime characteristics, i.~e. |
309 \item Kernel code has significantly better realtime characteristics, |
307 less latency than user space code. It was foreseeable, that a fieldbus master |
310 i.\,e.~less latency than userspace code. It was foreseeable, that a fieldbus |
308 has a lot of cyclic work to do. Cyclic work is usually triggered by timer |
311 master has a lot of cyclic work to do. Cyclic work is usually triggered by |
309 interrupts inside the kernel. The execution delay of a function that processes |
312 timer interrupts inside the kernel. The execution delay of a function that |
310 timer interrupts is less, when it resides in kernel space, because there is no |
313 processes timer interrupts is less, when it resides in kernelspace, because |
311 need of time-consuming context switches to a user space process. |
314 there is no need of time-consuming context switches to a userspace process. |
312 |
315 |
313 \item It was also foreseeable, that the master code has to directly |
316 \item It was also foreseeable, that the master code has to directly |
314 communicate with the Ethernet hardware. This has to be done in the kernel |
317 communicate with the Ethernet hardware. This has to be done in the kernel |
315 anyway (through network device drivers), which is one more reason for the |
318 anyway (through network device drivers), which is one more reason for the |
316 master code being in kernel space. |
319 master code being in kernelspace. |
317 |
320 |
318 \end{itemize} |
321 \end{itemize} |
319 |
322 |
320 Figure~\ref{fig:arch} gives a general overview of the master architecture. |
323 Figure~\ref{fig:arch} gives a general overview of the master architecture. |
321 |
324 |
377 possible until then. |
380 possible until then. |
378 |
381 |
379 \item[Idle phase]\index{Idle phase} takes effect when the master has accepted |
382 \item[Idle phase]\index{Idle phase} takes effect when the master has accepted |
380 an Ethernet device, but is not requested by any application yet. The master |
383 an Ethernet device, but is not requested by any application yet. The master |
381 runs its state machine (see section~\ref{sec:fsm-master}), that automatically |
384 runs its state machine (see section~\ref{sec:fsm-master}), that automatically |
382 scans the bus for slaves and executes pending operations from the user space |
385 scans the bus for slaves and executes pending operations from the userspace |
383 interface (for example Sdo access). The command-line tool can be used to access |
386 interface (for example Sdo access). The command-line tool can be used to |
384 the bus, but there is no process data exchange because of the missing bus |
387 access the bus, but there is no process data exchange because of the missing |
385 configuration. |
388 bus configuration. |
386 |
389 |
387 \item[Operation phase]\index{Operation phase} The master is requested by an |
390 \item[Operation phase]\index{Operation phase} The master is requested by an |
388 application that can provide a bus configuration and exchange process data. |
391 application that can provide a bus configuration and exchange process data. |
389 |
392 |
390 \end{description} |
393 \end{description} |
719 \paragraph{The \lstinline+net_device+ Structure} |
722 \paragraph{The \lstinline+net_device+ Structure} |
720 \index{net\_device} |
723 \index{net\_device} |
721 |
724 |
722 The driver registers a \lstinline+net_device+ structure for each device to |
725 The driver registers a \lstinline+net_device+ structure for each device to |
723 communicate with the network stack and to create a ``network interface''. In |
726 communicate with the network stack and to create a ``network interface''. In |
724 case of an Ethernet driver, this interface appears as \textit{ethX}, where X is |
727 case of an Ethernet driver, this interface appears as \textit{ethX}, where X |
725 a number assigned by the kernel on registration. The \lstinline+net_device+ |
728 is a number assigned by the kernel on registration. The \lstinline+net_device+ |
726 structure receives events (either from user space or from the network stack) |
729 structure receives events (either from userspace or from the network stack) |
727 via several callbacks, which have to be set before registration. Not every |
730 via several callbacks, which have to be set before registration. Not every |
728 callback is mandatory, but for reasonable operation the ones below are needed |
731 callback is mandatory, but for reasonable operation the ones below are needed |
729 in any case: |
732 in any case: |
730 |
733 |
731 \newsavebox\boxopen |
734 \newsavebox\boxopen |
738 \sbox\boxstats{\lstinline+get_stats()+} |
741 \sbox\boxstats{\lstinline+get_stats()+} |
739 |
742 |
740 \begin{description} |
743 \begin{description} |
741 |
744 |
742 \item[\usebox\boxopen] This function is called when network communication has |
745 \item[\usebox\boxopen] This function is called when network communication has |
743 to be started, for example after a command \lstinline+ip link set ethX up+ from |
746 to be started, for example after a command \lstinline+ip link set ethX up+ |
744 user space. Frame reception has to be enabled by the driver. |
747 from userspace. Frame reception has to be enabled by the driver. |
745 |
748 |
746 \item[\usebox\boxstop] The purpose of this callback is to ``close'' the device, |
749 \item[\usebox\boxstop] The purpose of this callback is to ``close'' the device, |
747 i.~e. make the hardware stop receiving frames. |
750 i.~e. make the hardware stop receiving frames. |
748 |
751 |
749 \item[\usebox\boxxmit] This function is called for each frame that has to be |
752 \item[\usebox\boxxmit] This function is called for each frame that has to be |
1869 |
1872 |
1870 \end{description} |
1873 \end{description} |
1871 |
1874 |
1872 %------------------------------------------------------------------------------ |
1875 %------------------------------------------------------------------------------ |
1873 |
1876 |
1874 \chapter{User Space} |
1877 \chapter{Userspace Interfaces} |
1875 \label{sec:user} |
1878 \label{sec:user} |
1876 \index{User space} |
1879 \index{Userspace} |
1877 |
|
1878 % FIXME |
|
1879 |
1880 |
1880 For the master runs as a kernel module, accessing it is natively limited to |
1881 For the master runs as a kernel module, accessing it is natively limited to |
1881 analyzing Syslog messages and controlling using modutils. |
1882 analyzing Syslog messages and controlling using \textit{modutils}. |
1882 |
1883 |
1883 It is necessary to implement further interfaces, that make it easier to access |
1884 It was necessary to implement further interfaces, that make it easier to access |
1884 the master from user space and allow a finer influence. It should be possible |
1885 the master from userspace and allow a finer influence. It should be possible |
1885 to view and to change special parameters at runtime. |
1886 to view and to change special parameters at runtime. |
1886 |
1887 |
1887 Bus visualization is a second point: For development and debugging purposes it |
1888 Bus visualization is another point: For development and debugging purposes it |
1888 would be nice, if one could show the connected slaves with a single command. |
1889 is necessary to show the connected slaves with a single command, for instance |
1889 |
1890 (see sec.~\ref{sec:ethercat}). |
1890 Another aspect is automatic startup and configuration. If the master is to be |
1891 |
1891 integrated into a running system, it must be able to automatically start with |
1892 Another aspect is automatic startup and configuration. The master must be able |
1892 a persistent configuration. |
1893 to automatically start up with a persistent configuration (see |
|
1894 sec.~\ref{sec:system}). |
1893 |
1895 |
1894 A last thing is monitoring EtherCAT communication. For debugging purposes, |
1896 A last thing is monitoring EtherCAT communication. For debugging purposes, |
1895 there had to be a way to analyze EtherCAT datagrams. The best way would be |
1897 there had to be a way to analyze EtherCAT datagrams. The best way would be |
1896 with a popular network analyzer, like Wireshark \cite{wireshark} (the former |
1898 with a popular network analyzer, like Wireshark \cite{wireshark} (the former |
1897 Ethereal) or others. |
1899 Ethereal) or others (see sec.~\ref{sec:debug}). |
1898 |
1900 |
1899 This section covers all those points and introduces the interfaces and tools |
1901 This chapter covers all these points and introduces the interfaces and tools |
1900 to make all that possible. |
1902 to make all that possible. |
1901 |
1903 |
1902 %------------------------------------------------------------------------------ |
1904 %------------------------------------------------------------------------------ |
1903 |
1905 |
1904 \section{Command-line Tool} |
1906 \section{Command-line Tool} |
2008 can be easily backed up and restored. |
2010 can be easily backed up and restored. |
2009 |
2011 |
2010 \item Some SII data fields have to be altered (like the alias address). A quick |
2012 \item Some SII data fields have to be altered (like the alias address). A quick |
2011 writing must be possible for that. |
2013 writing must be possible for that. |
2012 |
2014 |
2013 \item Through reading access, analyzing category data is possible from user |
2015 \item Through reading access, analyzing category data is possible from |
2014 space. |
2016 userspace. |
2015 |
2017 |
2016 \end{itemize} |
2018 \end{itemize} |
2017 |
2019 |
2018 \lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sii_read} |
2020 \lstinputlisting[basicstyle=\ttfamily\footnotesize]{external/ethercat_sii_read} |
2019 |
2021 |
2378 \textit{doxygen-output/html/index.html}. |
2380 \textit{doxygen-output/html/index.html}. |
2379 |
2381 |
2380 \section{Installing the Software} |
2382 \section{Installing the Software} |
2381 |
2383 |
2382 The below commands have to be entered as \textit{root}: The first one will |
2384 The below commands have to be entered as \textit{root}: The first one will |
2383 install the EtherCAT header, init script, sysconfig file and the user space |
2385 install the EtherCAT header, init script, sysconfig file and the userspace |
2384 tool to the prefix path. The second one will install the kernel modules to the |
2386 tool to the prefix path. The second one will install the kernel modules to the |
2385 kernel's modules directory. The final \lstinline+depmod+ call is necessary to |
2387 kernel's modules directory. The final \lstinline+depmod+ call is necessary to |
2386 include the kernel modules into the \textit{modules.dep} file to make it |
2388 include the kernel modules into the \textit{modules.dep} file to make it |
2387 available to the \lstinline+modprobe+ command, used in the init script. |
2389 available to the \lstinline+modprobe+ command, used in the init script. |
2388 |
2390 |
2515 |
2517 |
2516 \bibitem{alspec} IEC 61158-6-12: Application Layer Protocol Specification. |
2518 \bibitem{alspec} IEC 61158-6-12: Application Layer Protocol Specification. |
2517 International Electrotechnical Commission (IEC), 2005. |
2519 International Electrotechnical Commission (IEC), 2005. |
2518 |
2520 |
2519 \bibitem{gpl} GNU General Public License, Version 2. |
2521 \bibitem{gpl} GNU General Public License, Version 2. |
2520 \url{http://www.gnu.org/licenses/gpl.txt}. August~9, 2006. |
2522 \url{http://www.gnu.org/licenses/gpl-2.0.html}. October~15, 2008. |
2521 |
2523 |
2522 \bibitem{lsb} Linux Standard Base. |
2524 \bibitem{lsb} Linux Standard Base. |
2523 \url{http://www.linuxfoundation.org/en/LSB}. August~9, 2006. |
2525 \url{http://www.linuxfoundation.org/en/LSB}. August~9, 2006. |
2524 |
2526 |
2525 \bibitem{wireshark} Wireshark. \url{http://www.wireshark.org}. 2008. |
2527 \bibitem{wireshark} Wireshark. \url{http://www.wireshark.org}. 2008. |