documentation/ethercat_doc.tex
changeset 379 7db3d4f573fa
parent 376 d1441d87f5c1
child 487 448b0b23b905
equal deleted inserted replaced
378:8fe6cd43787a 379:7db3d4f573fa
   112 empty parentheses, this does not mean, that it has no parameters.
   112 empty parentheses, this does not mean, that it has no parameters.
   113 
   113 
   114 If shell commands have to be entered, this is marked by a prompt:
   114 If shell commands have to be entered, this is marked by a prompt:
   115 
   115 
   116 \begin{lstlisting}[gobble=2]
   116 \begin{lstlisting}[gobble=2]
   117   host>
   117   `\$`
   118 \end{lstlisting}
   118 \end{lstlisting}
   119 
   119 
   120 Further, if a shell command has to be entered as the superuser, the
   120 Further, if a shell command has to be entered as the superuser, the
   121 prompt ends with a mesh:
   121 prompt ends with a mesh:
   122 
   122 
   123 \begin{lstlisting}[gobble=2]
   123 \begin{lstlisting}[gobble=2]
   124   host#
   124   #
   125 \end{lstlisting}
   125 \end{lstlisting}
   126 
   126 
   127 %------------------------------------------------------------------------------
   127 %------------------------------------------------------------------------------
   128 
   128 
   129 \chapter{The IgH EtherCAT Master}
   129 \chapter{The IgH EtherCAT Master}
   732 The following command loads the EtherCAT-capable RTL8139 device
   732 The following command loads the EtherCAT-capable RTL8139 device
   733 driver, telling it to handle the second device as an EtherCAT device
   733 driver, telling it to handle the second device as an EtherCAT device
   734 and connecting it to the first master:
   734 and connecting it to the first master:
   735 
   735 
   736 \begin{lstlisting}
   736 \begin{lstlisting}
   737   host# `\textbf{modprobe ec\_8139too ec\_device\_index=1}`
   737   # `\textbf{modprobe ec\_8139too ec\_device\_index=1}`
   738 \end{lstlisting}
   738 \end{lstlisting}
   739 
   739 
   740 Usually, this command does not have to be entered manually, but is
   740 Usually, this command does not have to be entered manually, but is
   741 called by the EtherCAT init script. See section~\ref{sec:init} for
   741 called by the EtherCAT init script. See section~\ref{sec:init} for
   742 more information.
   742 more information.
  1270 the module with the parameter \textit{ec\_master\_count}, that
  1270 the module with the parameter \textit{ec\_master\_count}, that
  1271 defaults to $1$. A certain master can later be addressed by its index.
  1271 defaults to $1$. A certain master can later be addressed by its index.
  1272 For example, if the master module has been loaded with the command
  1272 For example, if the master module has been loaded with the command
  1273 
  1273 
  1274 \begin{lstlisting}
  1274 \begin{lstlisting}
  1275   host# `\textbf{modprobe ec\_master ec\_master\_count=2}`
  1275   # `\textbf{modprobe ec\_master ec\_master\_count=2}`
  1276 \end{lstlisting}
  1276 \end{lstlisting}
  1277 
  1277 
  1278 the two masters can be addressed by their indices 0 and 1 respectively
  1278 the two masters can be addressed by their indices 0 and 1 respectively
  1279 (see figure~\ref{fig:masters}). This master index mandatory for
  1279 (see figure~\ref{fig:masters}). This master index mandatory for
  1280 certain functions of the master interfaces.
  1280 certain functions of the master interfaces.
  2135   void ecrt_master_deactivate(ec_master_t *master);
  2135   void ecrt_master_deactivate(ec_master_t *master);
  2136 \end{lstlisting}
  2136 \end{lstlisting}
  2137 
  2137 
  2138 By calling the \textit{ecrt\_master\_activate()} method, all slaves
  2138 By calling the \textit{ecrt\_master\_activate()} method, all slaves
  2139 are configured according to the prior method calls and are brought
  2139 are configured according to the prior method calls and are brought
  2140 into \textit{OP} state. In this case, the method has a return value of
  2140 into OP state. In this case, the method has a return value of 0.
  2141 0. Otherwise (wrong configuration or bus failure) the method returns
  2141 Otherwise (wrong configuration or bus failure) the method returns
  2142 non-zero.
  2142 non-zero.
  2143 
  2143 
  2144 The \textit{ecrt\_master\_deactivate()} method is the counterpart to
  2144 The \textit{ecrt\_master\_deactivate()} method is the counterpart to
  2145 the activate call: It brings all slaves back into \textit{INIT} state
  2145 the activate call: It brings all slaves back into INIT state again.
  2146 again. This method should be called prior to
  2146 This method should be called prior to
  2147 \textit{ecrt\_\-master\_\-release()}.
  2147 \textit{ecrt\_\-master\_\-release()}.
  2148 
  2148 
  2149 \paragraph{Locking Callbacks}
  2149 \paragraph{Locking Callbacks}
  2150 
  2150 
  2151 For concurrent master access, the realtime module has to provide a
  2151 For concurrent master access, the realtime module has to provide a
  2885 \begin{description}
  2885 \begin{description}
  2886 \item[START] This is the beginning state of the operation state
  2886 \item[START] This is the beginning state of the operation state
  2887   machine. There is a datagram issued, that queries the ``AL Control
  2887   machine. There is a datagram issued, that queries the ``AL Control
  2888   Response'' attribute \cite[section~5.3.2]{alspec} of all slaves via
  2888   Response'' attribute \cite[section~5.3.2]{alspec} of all slaves via
  2889   broadcast. In this way, all slave states and the number of slaves
  2889   broadcast. In this way, all slave states and the number of slaves
  2890   responding can be determined.  $\rightarrow$~\textit{BROADCAST}
  2890   responding can be determined.  $\rightarrow$~BROADCAST
  2891 
  2891 
  2892 \item[BROADCAST] The broadcast datagram is evaluated. A change in the
  2892 \item[BROADCAST] The broadcast datagram is evaluated. A change in the
  2893   number of responding slaves is treates as a topology change. If the
  2893   number of responding slaves is treates as a topology change. If the
  2894   number of slaves is not as expected, the bus is marked as
  2894   number of slaves is not as expected, the bus is marked as
  2895   ``tainted''. In this state, no slave reconfiguration is possible,
  2895   ``tainted''. In this state, no slave reconfiguration is possible,
  2897   is ambiguous. If the number of slaves is considered as right, the
  2897   is ambiguous. If the number of slaves is considered as right, the
  2898   bus is marked for validation, because it turned from tainted to
  2898   bus is marked for validation, because it turned from tainted to
  2899   normal state and it has to be checked, if all slaves are valid. Now,
  2899   normal state and it has to be checked, if all slaves are valid. Now,
  2900   the state of every single slave has to be determined. For that, a
  2900   the state of every single slave has to be determined. For that, a
  2901   (unicast) datagram is issued, that queries the first slave's ``AL
  2901   (unicast) datagram is issued, that queries the first slave's ``AL
  2902   Control Response'' attribute. $\rightarrow$~\textit{READ STATES}
  2902   Control Response'' attribute. $\rightarrow$~READ STATES
  2903 
  2903 
  2904 \item[READ STATES] If the current slave did not respond to its
  2904 \item[READ STATES] If the current slave did not respond to its
  2905   configured station address, it is marked as offline, and the next
  2905   configured station address, it is marked as offline, and the next
  2906   slave is queried. $\rightarrow$~\textit{READ STATES}
  2906   slave is queried. $\rightarrow$~READ STATES
  2907 
  2907 
  2908   If the slave responded, it is marked as online and its current state
  2908   If the slave responded, it is marked as online and its current state
  2909   is stored. The next slave is queried. $\rightarrow$~\textit{READ
  2909   is stored. The next slave is queried. $\rightarrow$~READ STATES
  2910     STATES}
       
  2911 
  2910 
  2912   If all slaves have been queried, and the bus is marked for
  2911   If all slaves have been queried, and the bus is marked for
  2913   validation, the validation is started by checking the first slaves
  2912   validation, the validation is started by checking the first slaves
  2914   vendor ID. $\rightarrow$~\textit{VALIDATE VENDOR}
  2913   vendor ID. $\rightarrow$~VALIDATE VENDOR
  2915 
  2914 
  2916   If no validation has to be done, it is checked, if all slaves are in
  2915   If no validation has to be done, it is checked, if all slaves are in
  2917   the state they are supposed to be. If not, the first of slave with
  2916   the state they are supposed to be. If not, the first of slave with
  2918   the wrong state is reconfigured and brought in the required state.
  2917   the wrong state is reconfigured and brought in the required state.
  2919   $\rightarrow$~\textit{CONFIGURE SLAVES}
  2918   $\rightarrow$~CONFIGURE SLAVES
  2920 
  2919 
  2921   If all slaves are in the correct state, the state machine is
  2920   If all slaves are in the correct state, the state machine is
  2922   restarted. $\rightarrow$~\textit{START}
  2921   restarted. $\rightarrow$~START
  2923 
  2922 
  2924 \item[CONFIGURE SLAVES] The slave configuration state machine is
  2923 \item[CONFIGURE SLAVES] The slave configuration state machine is
  2925   executed until termination. $\rightarrow$~\textit{CONFIGURE SLAVES}
  2924   executed until termination. $\rightarrow$~CONFIGURE SLAVES
  2926 
  2925 
  2927   If there are still slaves in the wrong state after another check,
  2926   If there are still slaves in the wrong state after another check,
  2928   the first of these slaves is configured and brought into the correct
  2927   the first of these slaves is configured and brought into the correct
  2929   state again. $\rightarrow$~\textit{CONFIGURE SLAVES}
  2928   state again. $\rightarrow$~CONFIGURE SLAVES
  2930 
  2929 
  2931   If all slaves are in the correct state, the state machine is
  2930   If all slaves are in the correct state, the state machine is
  2932   restarted. $\rightarrow$~\textit{START}
  2931   restarted. $\rightarrow$~START
  2933 
  2932 
  2934 \item[VALIDATE VENDOR] The SII state machine is executed until
  2933 \item[VALIDATE VENDOR] The SII state machine is executed until
  2935   termination. If the slave has the wrong vendor ID, the state machine
  2934   termination. If the slave has the wrong vendor ID, the state machine
  2936   is restarted. $\rightarrow$~\textit{START}
  2935   is restarted. $\rightarrow$~START
  2937 
  2936 
  2938   If the slave has the correct vendor ID, its product ID is queried.
  2937   If the slave has the correct vendor ID, its product ID is queried.
  2939   $\rightarrow$~\textit{VALIDATE PRODUCT}
  2938   $\rightarrow$~VALIDATE PRODUCT
  2940 
  2939 
  2941 \item[VALIDATE PRODUCT] The SII state machine is executed until
  2940 \item[VALIDATE PRODUCT] The SII state machine is executed until
  2942   termination. If the slave has the wrong product ID, the state
  2941   termination. If the slave has the wrong product ID, the state
  2943   machine is restarted. $\rightarrow$~\textit{START}
  2942   machine is restarted. $\rightarrow$~START
  2944 
  2943 
  2945   If the slave has the correct product ID, the next slave's vendor ID
  2944   If the slave has the correct product ID, the next slave's vendor ID
  2946   is queried. $\rightarrow$~\textit{VALIDATE VENDOR}
  2945   is queried. $\rightarrow$~VALIDATE VENDOR
  2947 
  2946 
  2948   If all slaves have the correct vendor IDs and product codes, the
  2947   If all slaves have the correct vendor IDs and product codes, the
  2949   configured station addresses can be safely rewritten. This is done
  2948   configured station addresses can be safely rewritten. This is done
  2950   for the first slave marked as offline.
  2949   for the first slave marked as offline.
  2951   $\rightarrow$~\textit{REWRITE ADDRESSES}
  2950   $\rightarrow$~REWRITE ADDRESSES
  2952 
  2951 
  2953 \item[REWRITE ADDRESSES] If the station address was successfully
  2952 \item[REWRITE ADDRESSES] If the station address was successfully
  2954   written, it is sear\-ched for the next slave marked as offline. If
  2953   written, it is sear\-ched for the next slave marked as offline. If
  2955   there is one, its address is reconfigured, too.
  2954   there is one, its address is reconfigured, too.
  2956   $\rightarrow$~\textit{REWRITE ADDRESSES}
  2955   $\rightarrow$~REWRITE ADDRESSES
  2957 
  2956 
  2958   If there are no more slaves marked as offline, the state machine is
  2957   If there are no more slaves marked as offline, the state machine is
  2959   restarted. $\rightarrow$~\textit{START}
  2958   restarted. $\rightarrow$~START
  2960 \end{description}
  2959 \end{description}
  2961 
  2960 
  2962 %------------------------------------------------------------------------------
  2961 %------------------------------------------------------------------------------
  2963 
  2962 
  2964 \subsection{The Idle State Machine}
  2963 \subsection{The Idle State Machine}
  2980 
  2979 
  2981 \begin{description}
  2980 \begin{description}
  2982 \item[START] The beginning state of the idle state machine. Similar to
  2981 \item[START] The beginning state of the idle state machine. Similar to
  2983   the operation state machine, a broadcast datagram is issued, to
  2982   the operation state machine, a broadcast datagram is issued, to
  2984   query all slave states and the number of slaves.
  2983   query all slave states and the number of slaves.
  2985   $\rightarrow$~\textit{BROADCAST}
  2984   $\rightarrow$~BROADCAST
  2986 
  2985 
  2987 \item[BROADCAST] The number of responding slaves is evaluated. If it
  2986 \item[BROADCAST] The number of responding slaves is evaluated. If it
  2988   has changed since the last time, this is treated as a topology
  2987   has changed since the last time, this is treated as a topology
  2989   change and the internal list of slaves is cleared and rebuild
  2988   change and the internal list of slaves is cleared and rebuild
  2990   completely. The slave scan state machine is started for the first
  2989   completely. The slave scan state machine is started for the first
  2991   slave. $\rightarrow$~\textit{SCAN FOR SLAVES}
  2990   slave. $\rightarrow$~SCAN FOR SLAVES
  2992 
  2991 
  2993   If no topology change happened, every single slave state is fetched.
  2992   If no topology change happened, every single slave state is fetched.
  2994   $\rightarrow$~\textit{READ STATES}
  2993   $\rightarrow$~READ STATES
  2995 
  2994 
  2996 \item[SCAN FOR SLAVES] The slave scan state machine is executed until
  2995 \item[SCAN FOR SLAVES] The slave scan state machine is executed until
  2997   termination. $\rightarrow$~\textit{SCAN FOR SLAVES}
  2996   termination. $\rightarrow$~SCAN FOR SLAVES
  2998 
  2997 
  2999   If there is another slave to scan, the slave scan state machine is
  2998   If there is another slave to scan, the slave scan state machine is
  3000   started again. $\rightarrow$~\textit{SCAN FOR SLAVES}
  2999   started again. $\rightarrow$~SCAN FOR SLAVES
  3001 
  3000 
  3002   If all slave information has been fetched, slave addresses are
  3001   If all slave information has been fetched, slave addresses are
  3003   calculated and EoE processing is started. Then, the state machine is
  3002   calculated and EoE processing is started. Then, the state machine is
  3004   restarted. $\rightarrow$~\textit{START}
  3003   restarted. $\rightarrow$~START
  3005 
  3004 
  3006 \item[READ STATES] If the slave did not respond to the query, it is
  3005 \item[READ STATES] If the slave did not respond to the query, it is
  3007   marked as offline. The next slave is queried.
  3006   marked as offline. The next slave is queried.
  3008   $\rightarrow$~\textit{READ STATES}
  3007   $\rightarrow$~READ STATES
  3009 
  3008 
  3010   If the slave responded, it is marked as online. And the next slave
  3009   If the slave responded, it is marked as online. And the next slave
  3011   is queried. $\rightarrow$~\textit{READ STATES}
  3010   is queried. $\rightarrow$~READ STATES
  3012 
  3011 
  3013   If all slave states have been determined, it is checked, if any
  3012   If all slave states have been determined, it is checked, if any
  3014   slaves are not in the state they supposed to be. If this is true,
  3013   slaves are not in the state they supposed to be. If this is true,
  3015   the slave configuration state machine is started for the first of
  3014   the slave configuration state machine is started for the first of
  3016   them. $\rightarrow$~\textit{CONFIGURE SLAVES}
  3015   them. $\rightarrow$~CONFIGURE SLAVES
  3017 
  3016 
  3018   If all slaves are in the correct state, it is checked, if any
  3017   If all slaves are in the correct state, it is checked, if any
  3019   E$^2$PROM write operations are pending. If this is true, the first
  3018   E$^2$PROM write operations are pending. If this is true, the first
  3020   pending operation is executed by starting the SII state machine for
  3019   pending operation is executed by starting the SII state machine for
  3021   writing access. $\rightarrow$~\textit{WRITE EEPROM}
  3020   writing access. $\rightarrow$~WRITE EEPROM
  3022 
  3021 
  3023   If all these conditions are false, there is nothing to do and the
  3022   If all these conditions are false, there is nothing to do and the
  3024   state machine is restarted. $\rightarrow$~\textit{START}
  3023   state machine is restarted. $\rightarrow$~START
  3025 
  3024 
  3026 \item[CONFIGURE SLAVES] The slave configuration state machine is
  3025 \item[CONFIGURE SLAVES] The slave configuration state machine is
  3027   executed until termination. $\rightarrow$~\textit{CONFIGURE SLAVES}
  3026   executed until termination. $\rightarrow$~CONFIGURE SLAVES
  3028 
  3027 
  3029   After this, it is checked, if another slave needs a state change. If
  3028   After this, it is checked, if another slave needs a state change. If
  3030   this is true, the slave state change state machine is started for
  3029   this is true, the slave state change state machine is started for
  3031   this slave. $\rightarrow$~\textit{CONFIGURE SLAVES}
  3030   this slave. $\rightarrow$~CONFIGURE SLAVES
  3032 
  3031 
  3033   If all slaves are in the correct state, it is determined, if any
  3032   If all slaves are in the correct state, it is determined, if any
  3034   E$^2$PROM write operations are pending. If this is true, the first
  3033   E$^2$PROM write operations are pending. If this is true, the first
  3035   pending operation is executed by starting the SII state machine for
  3034   pending operation is executed by starting the SII state machine for
  3036   writing access. $\rightarrow$~\textit{WRITE EEPROM}
  3035   writing access. $\rightarrow$~WRITE EEPROM
  3037 
  3036 
  3038   If all prior conditions are false, the state machine is restarted.
  3037   If all prior conditions are false, the state machine is restarted.
  3039   $\rightarrow$~\textit{START}
  3038   $\rightarrow$~START
  3040 
  3039 
  3041 \item[WRITE EEPROM] The SII state machine is executed until
  3040 \item[WRITE EEPROM] The SII state machine is executed until
  3042   termination. $\rightarrow$~\textit{WRITE EEPROM}
  3041   termination. $\rightarrow$~WRITE EEPROM
  3043 
  3042 
  3044   If the current word has been written successfully, and there are
  3043   If the current word has been written successfully, and there are
  3045   still word to write, the SII state machine is started for the next
  3044   still word to write, the SII state machine is started for the next
  3046   word. $\rightarrow$~\textit{WRITE EEPROM}
  3045   word. $\rightarrow$~WRITE EEPROM
  3047 
  3046 
  3048   If all words have been written successfully, the new E$^2$PROM
  3047   If all words have been written successfully, the new E$^2$PROM
  3049   contents are evaluated and the state machine is restarted.
  3048   contents are evaluated and the state machine is restarted.
  3050   $\rightarrow$~\textit{START}
  3049   $\rightarrow$~START
  3051 
  3050 
  3052 \end{description}
  3051 \end{description}
  3053 
  3052 
  3054 %------------------------------------------------------------------------------
  3053 %------------------------------------------------------------------------------
  3055 
  3054 
  3071 \begin{description}
  3070 \begin{description}
  3072 \item[START] In the beginning state of the slave scan state machine,
  3071 \item[START] In the beginning state of the slave scan state machine,
  3073   the station address is written to the slave, which is always the
  3072   the station address is written to the slave, which is always the
  3074   ring position~+~$1$. In this way, the address 0x0000 (default
  3073   ring position~+~$1$. In this way, the address 0x0000 (default
  3075   address) is not used, which makes it easy to detect unconfigured
  3074   address) is not used, which makes it easy to detect unconfigured
  3076   slaves.  $\rightarrow$~\textit{ADDRESS}
  3075   slaves.  $\rightarrow$~ADDRESS
  3077 
  3076 
  3078 \item[ADDRESS] The writing of the station address is verified. After
  3077 \item[ADDRESS] The writing of the station address is verified. After
  3079   that, the slave's ``AL Control Response'' attribute is queried.
  3078   that, the slave's ``AL Control Response'' attribute is queried.
  3080   $\rightarrow$~\textit{STATE}
  3079   $\rightarrow$~STATE
  3081 
  3080 
  3082 \item[STATE] The AL state is evaluated. A warning is output, if the
  3081 \item[STATE] The AL state is evaluated. A warning is output, if the
  3083   slave has still the \textit{Change} bit set. After that, the slave's
  3082   slave has still the \textit{Change} bit set. After that, the slave's
  3084   ``DL Information'' attribute is queried.
  3083   ``DL Information'' attribute is queried.
  3085   $\rightarrow$~\textit{BASE}
  3084   $\rightarrow$~BASE
  3086 
  3085 
  3087 \item[BASE] The queried base data are evaluated: Slave type, revision
  3086 \item[BASE] The queried base data are evaluated: Slave type, revision
  3088   and build number, and even more important, the number of supported
  3087   and build number, and even more important, the number of supported
  3089   sync managers and FMMUs are stored. After that, the slave's data
  3088   sync managers and FMMUs are stored. After that, the slave's data
  3090   link layer information is read from the ``DL Status'' attribute at
  3089   link layer information is read from the ``DL Status'' attribute at
  3091   address 0x0110. $\rightarrow$~\textit{DATALINK}
  3090   address 0x0110. $\rightarrow$~DATALINK
  3092 
  3091 
  3093 \item[DATALINK] In this state, the DL information is evaluated: This
  3092 \item[DATALINK] In this state, the DL information is evaluated: This
  3094   information about the communication ports contains, if the link is
  3093   information about the communication ports contains, if the link is
  3095   up, if the loop has been closed and if there is a carrier detected
  3094   up, if the loop has been closed and if there is a carrier detected
  3096   on the RX side of each port.
  3095   on the RX side of each port.
  3098   Then, the state machine starts measuring the size of the slave's
  3097   Then, the state machine starts measuring the size of the slave's
  3099   E$^2$PROM contents. This is done by subsequently reading out each
  3098   E$^2$PROM contents. This is done by subsequently reading out each
  3100   category header, until the last category is reached (type 0xFFFF).
  3099   category header, until the last category is reached (type 0xFFFF).
  3101   This procedure is started by querying the first category header at
  3100   This procedure is started by querying the first category header at
  3102   word address 0x0040 via the SII state machine.
  3101   word address 0x0040 via the SII state machine.
  3103   $\rightarrow$~\textit{EEPROM SIZE}
  3102   $\rightarrow$~EEPROM SIZE
  3104 
  3103 
  3105 \item[EEPROM SIZE] The SII state machine is executed until
  3104 \item[EEPROM SIZE] The SII state machine is executed until
  3106   termination. $\rightarrow$~\textit{EEPROM SIZE}
  3105   termination. $\rightarrow$~EEPROM SIZE
  3107 
  3106 
  3108   If the category type does not mark the end of the categories, the
  3107   If the category type does not mark the end of the categories, the
  3109   position of the next category header is determined via the length of
  3108   position of the next category header is determined via the length of
  3110   the current category, and the SII state machine is started again.
  3109   the current category, and the SII state machine is started again.
  3111   $\rightarrow$~\textit{EEPROM SIZE}
  3110   $\rightarrow$~EEPROM SIZE
  3112 
  3111 
  3113   If the size of the E$^2$PROM contents has been determined, memory is
  3112   If the size of the E$^2$PROM contents has been determined, memory is
  3114   allocated, to read all the contents. The SII state machine is
  3113   allocated, to read all the contents. The SII state machine is
  3115   started to read the first word. $\rightarrow$~\textit{EEPROM DATA}
  3114   started to read the first word. $\rightarrow$~EEPROM DATA
  3116 
  3115 
  3117 \item[EEPROM DATA] The SII state machine is executed until
  3116 \item[EEPROM DATA] The SII state machine is executed until
  3118   termination. $\rightarrow$~\textit{EEPROM DATA}
  3117   termination. $\rightarrow$~EEPROM DATA
  3119 
  3118 
  3120   Two words have been read. If more than one word is needed, the two
  3119   Two words have been read. If more than one word is needed, the two
  3121   words are written in the allocated memory. Otherwise only one word
  3120   words are written in the allocated memory. Otherwise only one word
  3122   (the last word) is copied. If more words are to read, the SII state
  3121   (the last word) is copied. If more words are to read, the SII state
  3123   machine is started again to read the next two words.
  3122   machine is started again to read the next two words.
  3124   $\rightarrow$~\textit{EEPROM DATA}
  3123   $\rightarrow$~EEPROM DATA
  3125 
  3124 
  3126   The complete E$^2$PROM contents have been read. The slave's identity
  3125   The complete E$^2$PROM contents have been read. The slave's identity
  3127   object and mailbox information are evaluated. Moreover the category
  3126   object and mailbox information are evaluated. Moreover the category
  3128   types STRINGS, GENERAL, SYNC and PDO are evaluated. The slave
  3127   types STRINGS, GENERAL, SYNC and PDO are evaluated. The slave
  3129   scanning has been completed. $\rightarrow$~\textit{END}
  3128   scanning has been completed. $\rightarrow$~END
  3130 
  3129 
  3131 \item[END] Slave scanning has been finished.
  3130 \item[END] Slave scanning has been finished.
  3132 
  3131 
  3133 \end{description}
  3132 \end{description}
  3134 
  3133 
  3150   \label{fig:fsm-slaveconf}
  3149   \label{fig:fsm-slaveconf}
  3151 \end{figure}
  3150 \end{figure}
  3152 
  3151 
  3153 \begin{description}
  3152 \begin{description}
  3154 \item[INIT] The state change state machine has been initialized to
  3153 \item[INIT] The state change state machine has been initialized to
  3155   bring the slave into the \textit{INIT} state. Now, the slave state
  3154   bring the slave into the INIT state. Now, the slave state change
  3156   change state machine is executed until termination.
  3155   state machine is executed until termination. $\rightarrow$~INIT
  3157   $\rightarrow$~\textit{INIT}
       
  3158 
  3156 
  3159   If the slave state change failed, the configuration has to be
  3157   If the slave state change failed, the configuration has to be
  3160   aborted. $\rightarrow$~\textit{END}
  3158   aborted. $\rightarrow$~END
  3161 
  3159 
  3162   The slave state change succeeded and the slave is now in
  3160   The slave state change succeeded and the slave is now in INIT state.
  3163   \textit{INIT} state. If this is the target state, the configuration
  3161   If this is the target state, the configuration is finished.
  3164   is finished. $\rightarrow$~\textit{END}
  3162   $\rightarrow$~END
  3165 
  3163 
  3166   If the slave does not support any sync managers, the sync manager
  3164   If the slave does not support any sync managers, the sync manager
  3167   configuration can be skipped. The state change state machine is
  3165   configuration can be skipped. The state change state machine is
  3168   started to bring the slave into \textit{PREOP} state.
  3166   started to bring the slave into PREOP state.
  3169   $\rightarrow$~\textit{PREOP}
  3167   $\rightarrow$~PREOP
  3170 
  3168 
  3171   Sync managers are configured conforming to the sync manager category
  3169   Sync managers are configured conforming to the sync manager category
  3172   information provided in the slave's E$^2$PROM. The corresponding
  3170   information provided in the slave's E$^2$PROM. The corresponding
  3173   datagram is issued. $\rightarrow$~\textit{SYNC}
  3171   datagram is issued. $\rightarrow$~SYNC
  3174 
  3172 
  3175 \item[SYNC] If the sync manager configuration datagram is accepted,
  3173 \item[SYNC] If the sync manager configuration datagram is accepted,
  3176   the sync manager configuration was successful. The slave may now
  3174   the sync manager configuration was successful. The slave may now
  3177   enter the \textit{PREOP} state, and the state change state machine
  3175   enter the PREOP state, and the state change state machine is
  3178   is started. $\rightarrow$~\textit{PREOP}
  3176   started. $\rightarrow$~PREOP
  3179 
  3177 
  3180 \item[PREOP] The state change state machine is executed until
  3178 \item[PREOP] The state change state machine is executed until
  3181   termination. $\rightarrow$~\textit{PREOP}
  3179   termination. $\rightarrow$~PREOP
  3182 
  3180 
  3183   If the state change failed, the configuration has to be aborted.
  3181   If the state change failed, the configuration has to be aborted.
  3184   $\rightarrow$~\textit{END}
  3182   $\rightarrow$~END
  3185 
  3183 
  3186   If the \textit{PREOP} state was the target state, the configuration
  3184   If the PREOP state was the target state, the configuration is
  3187   is finished. $\rightarrow$~\textit{END}
  3185   finished. $\rightarrow$~END
  3188 
  3186 
  3189   If the slave supports no FMMUs, the FMMU configuration can be
  3187   If the slave supports no FMMUs, the FMMU configuration can be
  3190   skipped. If the slave has SDOs to configure, it is begun with
  3188   skipped. If the slave has SDOs to configure, it is begun with
  3191   sending the first SDO. $\rightarrow$~\textit{SDO\_CONF}
  3189   sending the first SDO. $\rightarrow$~SDO\_CONF
  3192 
  3190 
  3193   If no SDO configurations are provided, the slave can now directly be
  3191   If no SDO configurations are provided, the slave can now directly be
  3194   brought into the \textit{SAVEOP} state and the state change state
  3192   brought into the SAVEOP state and the state change state machine is
  3195   machine is started again. $\rightarrow$~\textit{SAVEOP}
  3193   started again. $\rightarrow$~SAVEOP
  3196 
  3194 
  3197   Otherwise, all supported FMMUs are configured according to the PDOs
  3195   Otherwise, all supported FMMUs are configured according to the PDOs
  3198   requested via the master's realtime interface. The appropriate
  3196   requested via the master's realtime interface. The appropriate
  3199   datagram is issued. $\rightarrow$~\textit{FMMU}
  3197   datagram is issued. $\rightarrow$~FMMU
  3200 
  3198 
  3201 \item[FMMU] The FMMU configuration datagram was accepted. If the slave
  3199 \item[FMMU] The FMMU configuration datagram was accepted. If the slave
  3202   has SDOs to configure, it is begun with sending the first SDO.
  3200   has SDOs to configure, it is begun with sending the first SDO.
  3203   $\rightarrow$~\textit{SDO\_CONF}
  3201   $\rightarrow$~SDO\_CONF
  3204 
  3202 
  3205   Otherwise, the slave can now be brought into the \textit{SAVEOP}
  3203   Otherwise, the slave can now be brought into the SAVEOP state. The
  3206   state. The state change state machine is started.
  3204   state change state machine is started.
  3207   $\rightarrow$~\textit{SAVEOP}
  3205   $\rightarrow$~SAVEOP
  3208 
  3206 
  3209 \item[SDO\_CONF] The CoE state machine is executed until termination.
  3207 \item[SDO\_CONF] The CoE state machine is executed until termination.
  3210   $\rightarrow$~\textit{SDO\_CONF}
  3208   $\rightarrow$~SDO\_CONF
  3211 
  3209 
  3212   If another SDO has to be configured, a new SDO download sequence is
  3210   If another SDO has to be configured, a new SDO download sequence is
  3213   begun. $\rightarrow$~\textit{SDO\_CONF}
  3211   begun. $\rightarrow$~SDO\_CONF
  3214 
  3212 
  3215   Otherwise, the slave can now be brought into the \textit{SAVEOP}
  3213   Otherwise, the slave can now be brought into the SAVEOP state. The
  3216   state. The state change state machine is started.
  3214   state change state machine is started.
  3217   $\rightarrow$~\textit{SAVEOP}
  3215   $\rightarrow$~SAVEOP
  3218 
  3216 
  3219 \item[SAVEOP] The state change state machine is executed until
  3217 \item[SAVEOP] The state change state machine is executed until
  3220   termination. $\rightarrow$~\textit{SAVEOP}
  3218   termination. $\rightarrow$~SAVEOP
  3221 
  3219 
  3222   If the state change failed, the configuration has to be aborted.
  3220   If the state change failed, the configuration has to be aborted.
  3223   $\rightarrow$~\textit{END}
  3221   $\rightarrow$~END
  3224 
  3222 
  3225   If the \textit{SAVEOP} state was the target state, the configuration
  3223   If the SAVEOP state was the target state, the configuration is
  3226   is finished. $\rightarrow$~\textit{END}
  3224   finished. $\rightarrow$~END
  3227 
  3225 
  3228   The slave can now directly be brought into the \textit{OP} state and
  3226   The slave can now directly be brought into the OP state and the
  3229   the state change state machine is started a last time.
  3227   state change state machine is started a last time.
  3230   $\rightarrow$~\textit{OP}
  3228   $\rightarrow$~OP
  3231 
  3229 
  3232 \item[OP] The state change state machine is executed until
  3230 \item[OP] The state change state machine is executed until
  3233   termination. $\rightarrow$~\textit{OP}
  3231   termination. $\rightarrow$~OP
  3234 
  3232 
  3235   If the state change state machine terminates, the slave
  3233   If the state change state machine terminates, the slave
  3236   configuration is finished, regardless of its success.
  3234   configuration is finished, regardless of its success.
  3237   $\rightarrow$~\textit{END}
  3235   $\rightarrow$~END
  3238 
  3236 
  3239 \item[END] The termination state.
  3237 \item[END] The termination state.
  3240 
  3238 
  3241 \end{description}
  3239 \end{description}
  3242 
  3240 
  3259 \end{figure}
  3257 \end{figure}
  3260 
  3258 
  3261 \begin{description}
  3259 \begin{description}
  3262 \item[START] The beginning state, where a datagram with the state
  3260 \item[START] The beginning state, where a datagram with the state
  3263   change command is written to the slave's ``AL Control Request''
  3261   change command is written to the slave's ``AL Control Request''
  3264   attribute. Nothing can fail. $\rightarrow$~\textit{CHECK}
  3262   attribute. Nothing can fail. $\rightarrow$~CHECK
  3265 
  3263 
  3266 \item[CHECK] After the state change datagram has been sent, the ``AL
  3264 \item[CHECK] After the state change datagram has been sent, the ``AL
  3267   Control Response'' attribute is queried with a second datagram.
  3265   Control Response'' attribute is queried with a second datagram.
  3268   $\rightarrow$~\textit{STATUS}
  3266   $\rightarrow$~STATUS
  3269 
  3267 
  3270 \item[STATUS] The read memory contents are evaluated: While the
  3268 \item[STATUS] The read memory contents are evaluated: While the
  3271   parameter \textit{State} still contains the old slave state, the
  3269   parameter \textit{State} still contains the old slave state, the
  3272   slave is busy with reacting on the state change command. In this
  3270   slave is busy with reacting on the state change command. In this
  3273   case, the attribute has to be queried again.
  3271   case, the attribute has to be queried again.
  3274   $\rightarrow$~\textit{STATUS}
  3272   $\rightarrow$~STATUS
  3275 
  3273 
  3276   In case of success, the \textit{State} parameter contains the new
  3274   In case of success, the \textit{State} parameter contains the new
  3277   state and the \textit{Change} bit is cleared. The slave is in the
  3275   state and the \textit{Change} bit is cleared. The slave is in the
  3278   requested state.  $\rightarrow$~\textit{END}
  3276   requested state.  $\rightarrow$~END
  3279 
  3277 
  3280   If the slave can not process the state change, the \textit{Change}
  3278   If the slave can not process the state change, the \textit{Change}
  3281   bit is set: Now the master tries to get the reason for this by
  3279   bit is set: Now the master tries to get the reason for this by
  3282   querying the \textit{AL Status Code} parameter.
  3280   querying the \textit{AL Status Code} parameter.
  3283   $\rightarrow$~\textit{CODE}
  3281   $\rightarrow$~CODE
  3284 
  3282 
  3285 \item[END] If the state machine ends in this state, the slaves's state
  3283 \item[END] If the state machine ends in this state, the slaves's state
  3286   change has been successful.
  3284   change has been successful.
  3287 
  3285 
  3288 \item[CODE] The status code query has been sent. Reading the
  3286 \item[CODE] The status code query has been sent. Reading the
  3289   \textit{AL Status Code} might fail, because not all slaves support
  3287   \textit{AL Status Code} might fail, because not all slaves support
  3290   this parameter. Anyway, the master has to acknowledge the state
  3288   this parameter. Anyway, the master has to acknowledge the state
  3291   change error by writing the current slave state to the ``AL Control
  3289   change error by writing the current slave state to the ``AL Control
  3292   Request'' attribute with the \textit{Acknowledge} bit set.
  3290   Request'' attribute with the \textit{Acknowledge} bit set.
  3293   $\rightarrow$~\textit{ACK}
  3291   $\rightarrow$~ACK
  3294 
  3292 
  3295 \item[ACK] After that, the ``AL Control Response'' attribute is
  3293 \item[ACK] After that, the ``AL Control Response'' attribute is
  3296   queried for the state of the acknowledgement.
  3294   queried for the state of the acknowledgement.
  3297   $\rightarrow$~\textit{CHECK ACK}
  3295   $\rightarrow$~CHECK ACK
  3298 
  3296 
  3299 \item[CHECK ACK] If the acknowledgement has been accepted by the
  3297 \item[CHECK ACK] If the acknowledgement has been accepted by the
  3300   slave, the old state is kept. Still, the state change was
  3298   slave, the old state is kept. Still, the state change was
  3301   unsuccessful. $\rightarrow$~\textit{ERROR}
  3299   unsuccessful. $\rightarrow$~ERROR
  3302 
  3300 
  3303   If the acknowledgement is ignored by the slave, a timeout happens.
  3301   If the acknowledgement is ignored by the slave, a timeout happens.
  3304   In any case, the overall state change was unsuccessful.
  3302   In any case, the overall state change was unsuccessful.
  3305   $\rightarrow$~\textit{ERROR}
  3303   $\rightarrow$~ERROR
  3306 
  3304 
  3307   If there is still now response from the slave, but the timer did not
  3305   If there is still now response from the slave, but the timer did not
  3308   run out yet, the slave's ``AL Control Response'' attribute is
  3306   run out yet, the slave's ``AL Control Response'' attribute is
  3309   queried again.  $\rightarrow$~\textit{CHECK ACK}
  3307   queried again.  $\rightarrow$~CHECK ACK
  3310 
  3308 
  3311 \item[ERROR] If the state machine ends in this state, the slave's
  3309 \item[ERROR] If the state machine ends in this state, the slave's
  3312   state change was unsuccessful.
  3310   state change was unsuccessful.
  3313 
  3311 
  3314 \end{description}
  3312 \end{description}
  3332 
  3330 
  3333 \begin{description}
  3331 \begin{description}
  3334 \item[READ\_START] The beginning state for reading access, where the
  3332 \item[READ\_START] The beginning state for reading access, where the
  3335   read request and the requested address are written to the SII
  3333   read request and the requested address are written to the SII
  3336   attribute. Nothing can fail up to now.
  3334   attribute. Nothing can fail up to now.
  3337   $\rightarrow$~\textit{READ\_CHECK}
  3335   $\rightarrow$~READ\_CHECK
  3338 
  3336 
  3339 \item[READ\_CHECK] When the SII read request has been sent
  3337 \item[READ\_CHECK] When the SII read request has been sent
  3340   successfully, a timer is started. A check/fetch datagram is issued,
  3338   successfully, a timer is started. A check/fetch datagram is issued,
  3341   that reads out the SII attribute for state and data.
  3339   that reads out the SII attribute for state and data.
  3342   $\rightarrow$~\textit{READ\_FETCH}
  3340   $\rightarrow$~READ\_FETCH
  3343 
  3341 
  3344 \item[READ\_FETCH] Upon reception of the check/fetch datagram, the
  3342 \item[READ\_FETCH] Upon reception of the check/fetch datagram, the
  3345   \textit{Read Operation} and \textit{Busy} parameters are checked:
  3343   \textit{Read Operation} and \textit{Busy} parameters are checked:
  3346   \begin{itemize}
  3344   \begin{itemize}
  3347   \item If the slave is still busy with fetching E$^2$PROM data into
  3345   \item If the slave is still busy with fetching E$^2$PROM data into
  3348     the interface, the timer is checked. If it timed out, the reading
  3346     the interface, the timer is checked. If it timed out, the reading
  3349     is aborted ($\rightarrow$~\textit{ERROR}), if not, the check/fetch
  3347     is aborted ($\rightarrow$~ERROR), if not, the check/fetch datagram
  3350     datagram is issued again. $\rightarrow$~\textit{READ\_FETCH}
  3348     is issued again. $\rightarrow$~READ\_FETCH
  3351 
  3349 
  3352   \item If the slave is ready with reading data, these are copied from
  3350   \item If the slave is ready with reading data, these are copied from
  3353     the datagram and the read cycle is completed.
  3351     the datagram and the read cycle is completed.
  3354     $\rightarrow$~\textit{END}
  3352     $\rightarrow$~END
  3355   \end{itemize}
  3353   \end{itemize}
  3356 \end{description}
  3354 \end{description}
  3357 
  3355 
  3358 The write access states behave nearly the same:
  3356 The write access states behave nearly the same:
  3359 
  3357 
  3360 \begin{description}
  3358 \begin{description}
  3361 \item[WRITE\_START] The beginning state for writing access,
  3359 \item[WRITE\_START] The beginning state for writing access,
  3362   respectively. A write request, the target address and the data word
  3360   respectively. A write request, the target address and the data word
  3363   are written to the SII attribute. Nothing can fail.
  3361   are written to the SII attribute. Nothing can fail.
  3364   $\rightarrow$~\textit{WRITE\_CHECK}
  3362   $\rightarrow$~WRITE\_CHECK
  3365 
  3363 
  3366 \item[WRITE\_CHECK] When the SII write request has been sent
  3364 \item[WRITE\_CHECK] When the SII write request has been sent
  3367   successfully, the timer is started. A check datagram is issued, that
  3365   successfully, the timer is started. A check datagram is issued, that
  3368   reads out the SII attribute for the state of the write operation.
  3366   reads out the SII attribute for the state of the write operation.
  3369   $\rightarrow$~\textit{WRITE\_CHECK2}
  3367   $\rightarrow$~WRITE\_CHECK2
  3370 
  3368 
  3371 \item[WRITE\_CHECK2] Upon reception of the check datagram, the
  3369 \item[WRITE\_CHECK2] Upon reception of the check datagram, the
  3372   \textit{Write Operation} and \textit{Busy} parameters are checked:
  3370   \textit{Write Operation} and \textit{Busy} parameters are checked:
  3373   \begin{itemize}
  3371   \begin{itemize}
  3374   \item If the slave is still busy with writing E$^2$PROM data, the
  3372   \item If the slave is still busy with writing E$^2$PROM data, the
  3375     timer is checked. If it timed out, the operation is aborted
  3373     timer is checked. If it timed out, the operation is aborted
  3376     ($\rightarrow$~\textit{ERROR}), if not, the check datagram is
  3374     ($\rightarrow$~ERROR), if not, the check datagram is issued again.
  3377     issued again. $\rightarrow$~\textit{WRITE\_CHECK2}
  3375     $\rightarrow$~WRITE\_CHECK2
  3378   \item If the slave is ready with writing data, the write cycle is
  3376   \item If the slave is ready with writing data, the write cycle is
  3379     completed. $\rightarrow$~\textit{END}
  3377     completed. $\rightarrow$~END
  3380   \end{itemize}
  3378   \end{itemize}
  3381 \end{description}
  3379 \end{description}
  3382 
  3380 
  3383 %------------------------------------------------------------------------------
  3381 %------------------------------------------------------------------------------
  3384 
  3382 
  3464 
  3462 
  3465 The master module has a parameter \textit{ec\_eoeif\_count} to specify
  3463 The master module has a parameter \textit{ec\_eoeif\_count} to specify
  3466 the number of EoE interfaces (and handlers) per master to create. This
  3464 the number of EoE interfaces (and handlers) per master to create. This
  3467 parameter can either be specified when manually loading the master
  3465 parameter can either be specified when manually loading the master
  3468 module, or (when using the init script) by setting the
  3466 module, or (when using the init script) by setting the
  3469 \textit{EOE\_INTERFACES} variable in the sysconfig file (see
  3467 \$EOE\_INTERFACES variable in the sysconfig file (see
  3470 section~\ref{sec:sysconfig}). Upon loading of the master module, the
  3468 section~\ref{sec:sysconfig}). Upon loading of the master module, the
  3471 virtual interfaces become available:
  3469 virtual interfaces become available:
  3472 
  3470 
  3473 \begin{lstlisting}
  3471 \begin{lstlisting}
  3474   host# `\textbf{ifconfig -a}`
  3472   # `\textbf{ifconfig -a}`
  3475   eoe0      Link encap:Ethernet  HWaddr 00:11:22:33:44:06
  3473   eoe0      Link encap:Ethernet  HWaddr 00:11:22:33:44:06
  3476             BROADCAST MULTICAST  MTU:1500  Metric:1
  3474             BROADCAST MULTICAST  MTU:1500  Metric:1
  3477             RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  3475             RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  3478             TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  3476             TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  3479             collisions:0 txqueuelen:1000
  3477             collisions:0 txqueuelen:1000
  3516 \end{figure}
  3514 \end{figure}
  3517 
  3515 
  3518 \begin{description}
  3516 \begin{description}
  3519 \item[RX\_START] The beginning state of the EoE state machine. A
  3517 \item[RX\_START] The beginning state of the EoE state machine. A
  3520   mailbox check datagram is sent, to query the slave's mailbox for new
  3518   mailbox check datagram is sent, to query the slave's mailbox for new
  3521   frames. $\rightarrow$~\textit{RX\_CHECK}
  3519   frames. $\rightarrow$~RX\_CHECK
  3522 
  3520 
  3523 \item[RX\_CHECK] The mailbox check datagram is received. If the
  3521 \item[RX\_CHECK] The mailbox check datagram is received. If the
  3524   slave's mailbox did not contain data, a transmit cycle is started.
  3522   slave's mailbox did not contain data, a transmit cycle is started.
  3525   $\rightarrow$~\textit{TX\_START}
  3523   $\rightarrow$~TX\_START
  3526 
  3524 
  3527   If there are new data in the mailbox, a datagram is sent to fetch
  3525   If there are new data in the mailbox, a datagram is sent to fetch
  3528   the new data. $\rightarrow$~\textit{RX\_FETCH}
  3526   the new data. $\rightarrow$~RX\_FETCH
  3529 
  3527 
  3530 \item[RX\_FETCH] The fetch datagram is received. If the mailbox data
  3528 \item[RX\_FETCH] The fetch datagram is received. If the mailbox data
  3531   do not contain a ``EoE Fragment request'' command, the data are
  3529   do not contain a ``EoE Fragment request'' command, the data are
  3532   dropped and a transmit sequence is started.
  3530   dropped and a transmit sequence is started.
  3533   $\rightarrow$~\textit{TX\_START}
  3531   $\rightarrow$~TX\_START
  3534 
  3532 
  3535   If the received Ethernet frame fragment is the first fragment, a new
  3533   If the received Ethernet frame fragment is the first fragment, a new
  3536   socket buffer is allocated. In either case, the data are copied into
  3534   socket buffer is allocated. In either case, the data are copied into
  3537   the correct position of the socket buffer.
  3535   the correct position of the socket buffer.
  3538 
  3536 
  3539   If the fragment is the last fragment, the socket buffer is forwarded
  3537   If the fragment is the last fragment, the socket buffer is forwarded
  3540   to the network stack and a transmit sequence is started.
  3538   to the network stack and a transmit sequence is started.
  3541   $\rightarrow$~\textit{TX\_START}
  3539   $\rightarrow$~TX\_START
  3542 
  3540 
  3543   Otherwise, a new receive sequence is started to fetch the next
  3541   Otherwise, a new receive sequence is started to fetch the next
  3544   fragment. $\rightarrow$~\textit{RX\_\-START}
  3542   fragment. $\rightarrow$~RX\_\-START
  3545 
  3543 
  3546 \item[TX\_START] The beginning state of a transmit sequence. It is
  3544 \item[TX\_START] The beginning state of a transmit sequence. It is
  3547   checked, if the transmittion queue contains a frame to send. If not,
  3545   checked, if the transmittion queue contains a frame to send. If not,
  3548   a receive sequence is started. $\rightarrow$~\textit{RX\_START}
  3546   a receive sequence is started. $\rightarrow$~RX\_START
  3549 
  3547 
  3550   If there is a frame to send, it is dequeued. If the queue was
  3548   If there is a frame to send, it is dequeued. If the queue was
  3551   inactive before (because it was full), the queue is woken up with a
  3549   inactive before (because it was full), the queue is woken up with a
  3552   call to \textit{netif\_wake\_queue()}. The first fragment of the
  3550   call to \textit{netif\_wake\_queue()}. The first fragment of the
  3553   frame is sent. $\rightarrow$~\textit{TX\_SENT}
  3551   frame is sent. $\rightarrow$~TX\_SENT
  3554 
  3552 
  3555 \item[TX\_SENT] It is checked, if the first fragment was sent
  3553 \item[TX\_SENT] It is checked, if the first fragment was sent
  3556   successfully. If the current frame consists of further fragments,
  3554   successfully. If the current frame consists of further fragments,
  3557   the next one is sent. $\rightarrow$~\textit{TX\_SENT}
  3555   the next one is sent. $\rightarrow$~TX\_SENT
  3558 
  3556 
  3559   If the last fragment was sent, a new receive sequence is started.
  3557   If the last fragment was sent, a new receive sequence is started.
  3560   $\rightarrow$~\textit{RX\_START}
  3558   $\rightarrow$~RX\_START
  3561 \end{description}
  3559 \end{description}
  3562 
  3560 
  3563 \paragraph{EoE Processing}
  3561 \paragraph{EoE Processing}
  3564 
  3562 
  3565 To execute the EoE state machine of every active EoE handler, there
  3563 To execute the EoE state machine of every active EoE handler, there
  3600 owns an internal spinlock that is used protect master access during
  3598 owns an internal spinlock that is used protect master access during
  3601 idle mode.
  3599 idle mode.
  3602 
  3600 
  3603 \paragraph{Automatic Configuration}
  3601 \paragraph{Automatic Configuration}
  3604 
  3602 
  3605 By default, slaves are left in \textit{INIT} state during idle mode.
  3603 By default, slaves are left in INIT state during idle mode. If an EoE
  3606 If an EoE interface is set to running state (i.~e. with the
  3604 interface is set to running state (i.~e. with the \textit{ifconfig up}
  3607 \textit{ifconfig up} command), the requested slave state of the
  3605 command), the requested slave state of the related slave is
  3608 related slave is automatically set to \textit{OP}, whereupon the idle
  3606 automatically set to OP, whereupon the idle state machine will attempt
  3609 state machine will attempt to configure the slave and put it into
  3607 to configure the slave and put it into operation.
  3610 operation.
       
  3611 
  3608 
  3612 %------------------------------------------------------------------------------
  3609 %------------------------------------------------------------------------------
  3613 
  3610 
  3614 \subsection{CANopen-over-EtherCAT (CoE)}
  3611 \subsection{CANopen-over-EtherCAT (CoE)}
  3615 \label{sec:coeimp}
  3612 \label{sec:coeimp}
  3627 interface. The slave stores the SDO configurations in a linked list,
  3624 interface. The slave stores the SDO configurations in a linked list,
  3628 but does not apply them at once.
  3625 but does not apply them at once.
  3629 
  3626 
  3630 \paragraph{SDO Download State Machine}
  3627 \paragraph{SDO Download State Machine}
  3631 
  3628 
  3632 The best time to apply SDO configurations is during the slave's
  3629 The best time to apply SDO configurations is during the slave's PREOP
  3633 \textit{PREOP} state, because mailbox communication is already
  3630 state, because mailbox communication is already possible and slave's
  3634 possible and slave's application will start with updating input data
  3631 application will start with updating input data in the succeeding
  3635 in the succeeding \textit{SAVEOP} state. Therefore the SDO
  3632 SAVEOP state. Therefore the SDO configuration has to be part of the
  3636 configuration has to be part of the slave configuration state machine
  3633 slave configuration state machine (see section~\ref{sec:fsm-conf}): It
  3637 (see section~\ref{sec:fsm-conf}): It is implemented via an SDO
  3634 is implemented via an SDO download state machine, that is executed
  3638 download state machine, that is executed just before entering the
  3635 just before entering the slave's SAVEOP state. In this way, it is
  3639 slave's \textit{SAVEOP} state. In this way, it is guaranteed that the
  3636 guaranteed that the SDO configurations are applied each time, the
  3640 SDO configurations are applied each time, the slave is reconfigured.
  3637 slave is reconfigured.
  3641 
  3638 
  3642 The transition diagram of the SDO Download state machine can be seen
  3639 The transition diagram of the SDO Download state machine can be seen
  3643 in figure~\ref{fig:fsm-coedown}.
  3640 in figure~\ref{fig:fsm-coedown}.
  3644 
  3641 
  3645 \begin{figure}[htbp]
  3642 \begin{figure}[htbp]
  3650 \end{figure}
  3647 \end{figure}
  3651 
  3648 
  3652 \begin{description}
  3649 \begin{description}
  3653 \item[START] The beginning state of the CoE download state
  3650 \item[START] The beginning state of the CoE download state
  3654   machine. The ``SDO Download Normal Request'' mailbox command is
  3651   machine. The ``SDO Download Normal Request'' mailbox command is
  3655   sent. $\rightarrow$~\textit{REQUEST}
  3652   sent. $\rightarrow$~REQUEST
  3656 
  3653 
  3657 \item[REQUEST] It is checked, if the CoE download request has been
  3654 \item[REQUEST] It is checked, if the CoE download request has been
  3658   received by the slave. After that, a mailbox check command is issued
  3655   received by the slave. After that, a mailbox check command is issued
  3659   and a timer is started. $\rightarrow$~\textit{CHECK}
  3656   and a timer is started. $\rightarrow$~CHECK
  3660 
  3657 
  3661 \item[CHECK] If no mailbox data is available, the timer is checked.
  3658 \item[CHECK] If no mailbox data is available, the timer is checked.
  3662   \begin{itemize}
  3659   \begin{itemize}
  3663   \item If it timed out, the SDO download is aborted.
  3660   \item If it timed out, the SDO download is aborted.
  3664     $\rightarrow$~\textit{ERROR}
  3661     $\rightarrow$~ERROR
  3665   \item Otherwise, the mailbox is queried again.
  3662   \item Otherwise, the mailbox is queried again.
  3666     $\rightarrow$~\textit{CHECK}
  3663     $\rightarrow$~CHECK
  3667   \end{itemize}
  3664   \end{itemize}
  3668 
  3665 
  3669   If the mailbox contains new data, the response is fetched.
  3666   If the mailbox contains new data, the response is fetched.
  3670   $\rightarrow$~\textit{RESPONSE}
  3667   $\rightarrow$~RESPONSE
  3671 
  3668 
  3672 \item[RESPONSE] If the mailbox response could not be fetched, the data
  3669 \item[RESPONSE] If the mailbox response could not be fetched, the data
  3673   is invalid, the wrong protocol was received, or a ``Abort SDO
  3670   is invalid, the wrong protocol was received, or a ``Abort SDO
  3674   Transfer Request'' was received, the SDO download is aborted.
  3671   Transfer Request'' was received, the SDO download is aborted.
  3675   $\rightarrow$~\textit{ERROR}
  3672   $\rightarrow$~ERROR
  3676 
  3673 
  3677   If a ``SDO Download Normal Response'' acknowledgement was received,
  3674   If a ``SDO Download Normal Response'' acknowledgement was received,
  3678   the SDO download was successful. $\rightarrow$~\textit{END}
  3675   the SDO download was successful. $\rightarrow$~END
  3679 
  3676 
  3680 \item[END] The SDO download was successful.
  3677 \item[END] The SDO download was successful.
  3681 
  3678 
  3682 \item[ERROR] The SDO download was aborted due to an error.
  3679 \item[ERROR] The SDO download was aborted due to an error.
  3683 
  3680 
  3755 
  3752 
  3756 Below is a typical listing of the masters Sysfs directory (that is a
  3753 Below is a typical listing of the masters Sysfs directory (that is a
  3757 file system representation of the master's kobject):
  3754 file system representation of the master's kobject):
  3758 
  3755 
  3759 \begin{lstlisting}
  3756 \begin{lstlisting}
  3760   host> `\textbf{ls /sys/ethercat0}`
  3757   `\$` `\textbf{ls /sys/ethercat0}`
  3761   debug_level          slave000  slave003  slave006
  3758   debug_level          slave000  slave003  slave006
  3762   eeprom_write_enable  slave001  slave004  slave007
  3759   eeprom_write_enable  slave001  slave004  slave007
  3763   info                 slave002  slave005  slave008
  3760   info                 slave002  slave005  slave008
  3764 \end{lstlisting}
  3761 \end{lstlisting}
  3765 
  3762 
  3771   syslog. The values 0 (no additional debug messages), 1 (a few
  3768   syslog. The values 0 (no additional debug messages), 1 (a few
  3772   additional debug messages) and 2 (all additional debug messages) are
  3769   additional debug messages) and 2 (all additional debug messages) are
  3773   defined. Writing is done with command like
  3770   defined. Writing is done with command like
  3774 
  3771 
  3775   \begin{lstlisting}[gobble=4]
  3772   \begin{lstlisting}[gobble=4]
  3776     host# `\textbf{echo 1 > /sys/ethercat0/debug\_level}`
  3773     # `\textbf{echo 1 > /sys/ethercat0/debug\_level}`
  3777   \end{lstlisting}
  3774   \end{lstlisting}
  3778 
  3775 
  3779   and is receipted with a syslog message by the master:
  3776   and is receipted with a syslog message by the master:
  3780 
  3777 
  3781   \begin{lstlisting}[gobble=4]
  3778   \begin{lstlisting}[gobble=4]
  3787 
  3784 
  3788 \item[info] (read only) This attribute contains information about the
  3785 \item[info] (read only) This attribute contains information about the
  3789   master. Example contents are below:
  3786   master. Example contents are below:
  3790 
  3787 
  3791   \begin{lstlisting}[gobble=4]
  3788   \begin{lstlisting}[gobble=4]
  3792     host> `\textbf{cat /sys/ethercat0/info}`
  3789     `\$` `\textbf{cat /sys/ethercat0/info}`
  3793 
  3790 
  3794     Mode: IDLE
  3791     Mode: IDLE
  3795     Slaves: 9
  3792     Slaves: 9
  3796 
  3793 
  3797     Timing (min/avg/max) [us]:
  3794     Timing (min/avg/max) [us]:
  3813 In operation mode, each created domain is represented as a directory
  3810 In operation mode, each created domain is represented as a directory
  3814 \textit{domainX}, where X is the domain index. Below is a listing of
  3811 \textit{domainX}, where X is the domain index. Below is a listing of
  3815 the domain directory contents:
  3812 the domain directory contents:
  3816 
  3813 
  3817 \begin{lstlisting}
  3814 \begin{lstlisting}
  3818   host> `\textbf{ls /sys/ethercat0/domain0}`
  3815   `\$` `\textbf{ls /sys/ethercat0/domain0}`
  3819   image_size
  3816   image_size
  3820 \end{lstlisting}
  3817 \end{lstlisting}
  3821 
  3818 
  3822 The domain directories currently only export the domain's image size.
  3819 The domain directories currently only export the domain's image size.
  3823 It is planned to export the whole process data mapping for debugging
  3820 It is planned to export the whole process data mapping for debugging
  3829 Each slave on the bus is represented in its own directory
  3826 Each slave on the bus is represented in its own directory
  3830 \textit{slaveXXX}, where XXX is the slave's 3-digit ring position in
  3827 \textit{slaveXXX}, where XXX is the slave's 3-digit ring position in
  3831 the EtherCAT bus. Below is a listing of a slave directory:
  3828 the EtherCAT bus. Below is a listing of a slave directory:
  3832 
  3829 
  3833 \begin{lstlisting}
  3830 \begin{lstlisting}
  3834   host> `\textbf{ls /sys/ethercat0/slave003}`
  3831   `\$` `\textbf{ls /sys/ethercat0/slave003}`
  3835   eeprom  info  state
  3832   eeprom  info  state
  3836 \end{lstlisting}
  3833 \end{lstlisting}
  3837 
  3834 
  3838 \begin{description}
  3835 \begin{description}
  3839 \item[eeprom] (read/write) See section~\ref{sec:eepromaccess} for how
  3836 \item[eeprom] (read/write) See section~\ref{sec:eepromaccess} for how
  3841 
  3838 
  3842 \item[info] (read only) This attribute contains a bunch of information
  3839 \item[info] (read only) This attribute contains a bunch of information
  3843   about the slave. Below is an example output:
  3840   about the slave. Below is an example output:
  3844 
  3841 
  3845   \begin{lstlisting}[gobble=4]
  3842   \begin{lstlisting}[gobble=4]
  3846     host> `\textbf{cat /sys/ethercat0/slave003/info}`
  3843     `\$` `\textbf{cat /sys/ethercat0/slave003/info}`
  3847 
  3844 
  3848     Name: EL4132 2K. Ana. Ausgang +/-10V
  3845     Name: EL4132 2K. Ana. Ausgang +/-10V
  3849     Vendor ID: 0x00000002
  3846     Vendor ID: 0x00000002
  3850     Product code: 0x10243052
  3847     Product code: 0x10243052
  3851 
  3848 
  3887 
  3884 
  3888 \item[state] (read/write) This attribute contains the slave's state.
  3885 \item[state] (read/write) This attribute contains the slave's state.
  3889   It can be read or written:
  3886   It can be read or written:
  3890 
  3887 
  3891   \begin{lstlisting}[gobble=4]
  3888   \begin{lstlisting}[gobble=4]
  3892     host# `\textbf{cat /sys/ethercat0/slave003/state}`
  3889     # `\textbf{cat /sys/ethercat0/slave003/state}`
  3893     OP
  3890     OP
  3894     host# `\textbf{echo SAVEOP > /sys/ethercat0/slave003/state}`
  3891     # `\textbf{echo SAVEOP > /sys/ethercat0/slave003/state}`
  3895   \end{lstlisting}
  3892   \end{lstlisting}
  3896 
  3893 
  3897   This command should also be receipted with a syslog message:
  3894   This command should also be receipted with a syslog message:
  3898 
  3895 
  3899   \begin{lstlisting}[gobble=4]
  3896   \begin{lstlisting}[gobble=4]
  3932 Reading out E$^2$PROM data is as easy as reading other
  3929 Reading out E$^2$PROM data is as easy as reading other
  3933 attributes. Though the data are in binary format, analyzation is
  3930 attributes. Though the data are in binary format, analyzation is
  3934 easier with a tool like \textit{hexdump}:
  3931 easier with a tool like \textit{hexdump}:
  3935 
  3932 
  3936 \begin{lstlisting}
  3933 \begin{lstlisting}
  3937   host> `\textbf{cat /sys/ethercat0/slave003/eeprom | hexdump}`
  3934   `\$` `\textbf{cat /sys/ethercat0/slave003/eeprom | hexdump}`
  3938   0000000 0103 0000 0000 0000 0000 0000 0000 008c
  3935   0000000 0103 0000 0000 0000 0000 0000 0000 008c
  3939   0000010 0002 0000 3052 07f0 0000 0000 0000 0000
  3936   0000010 0002 0000 3052 07f0 0000 0000 0000 0000
  3940   0000020 0000 0000 0000 0000 0000 0000 0000 0000
  3937   0000020 0000 0000 0000 0000 0000 0000 0000 0000
  3941   ...
  3938   ...
  3942 \end{lstlisting}
  3939 \end{lstlisting}
  3943 
  3940 
  3944 Backing up E$^2$PROM contents gets as easy as copying a file:
  3941 Backing up E$^2$PROM contents gets as easy as copying a file:
  3945 
  3942 
  3946 \begin{lstlisting}
  3943 \begin{lstlisting}
  3947   host> `\textbf{cp /sys/ethercat0/slave003/eeprom slave003.eep}`
  3944   `\$` `\textbf{cp /sys/ethercat0/slave003/eeprom slave003.eep}`
  3948 \end{lstlisting}
  3945 \end{lstlisting}
  3949 
  3946 
  3950 Writing access is only possible as \textit{root}. Moreover writing has
  3947 Writing access is only possible as \textit{root}. Moreover writing has
  3951 to be explicitly enabled and is only allowed in idle mode. This is a
  3948 to be explicitly enabled and is only allowed in idle mode. This is a
  3952 safety measure, because without the correct memory contents, a slave
  3949 safety measure, because without the correct memory contents, a slave
  3954 provided yet.
  3951 provided yet.
  3955 
  3952 
  3956 E$^2$PROM writing is enabled with the command below:
  3953 E$^2$PROM writing is enabled with the command below:
  3957 
  3954 
  3958 \begin{lstlisting}
  3955 \begin{lstlisting}
  3959   host# `\textbf{echo 1 > /sys/ethercat0/eeprom\_write\_enable}`
  3956   # `\textbf{echo 1 > /sys/ethercat0/eeprom\_write\_enable}`
  3960 \end{lstlisting}
  3957 \end{lstlisting}
  3961 
  3958 
  3962 The success can be seen in the syslog messages again:
  3959 The success can be seen in the syslog messages again:
  3963 
  3960 
  3964 \begin{lstlisting}
  3961 \begin{lstlisting}
  3969 will accept data through the \textit{eeprom} file and will perform a
  3966 will accept data through the \textit{eeprom} file and will perform a
  3970 short validation of the contents, before starting the write operation.
  3967 short validation of the contents, before starting the write operation.
  3971 This validation checks the complete size and the category headers.
  3968 This validation checks the complete size and the category headers.
  3972 
  3969 
  3973 \begin{lstlisting}
  3970 \begin{lstlisting}
  3974   host# `\textbf{cat slave003.eep > /sys/ethercat0/slave003/eeprom}`
  3971   # `\textbf{cat slave003.eep > /sys/ethercat0/slave003/eeprom}`
  3975 \end{lstlisting}
  3972 \end{lstlisting}
  3976 
  3973 
  3977 The write operation can take a few seconds.
  3974 The write operation can take a few seconds.
  3978 
  3975 
  3979 \begin{lstlisting}
  3976 \begin{lstlisting}
  3990 There is a user space tool called \textit{lsec}\index{lsec} (``List
  3987 There is a user space tool called \textit{lsec}\index{lsec} (``List
  3991 EtherCAT'') to visualize the EtherCAT bus. Running it usually results
  3988 EtherCAT'') to visualize the EtherCAT bus. Running it usually results
  3992 in an output like this:
  3989 in an output like this:
  3993 
  3990 
  3994 \begin{lstlisting}
  3991 \begin{lstlisting}
  3995   host> `\textbf{lsec}`
  3992   `\$` `\textbf{lsec}`
  3996   EtherCAT bus listing for master 0:
  3993   EtherCAT bus listing for master 0:
  3997      0  1:0  OP      EK1100 Ethernet Kopplerklemme (2A E-Bus)
  3994      0  1:0  OP      EK1100 Ethernet Kopplerklemme (2A E-Bus)
  3998      1  1:1  INIT    EL4132 2K. Ana. Ausgang +/-10V
  3995      1  1:1  INIT    EL4132 2K. Ana. Ausgang +/-10V
  3999      2  1:2  INIT    EL4132 2K. Ana. Ausgang +/-10V
  3996      2  1:2  INIT    EL4132 2K. Ana. Ausgang +/-10V
  4000      3  1:3  SAVEOP  EL4132 2K. Ana. Ausgang +/-10V
  3997      3  1:3  SAVEOP  EL4132 2K. Ana. Ausgang +/-10V
  4015 \textit{info} attributes of the slaves (see
  4012 \textit{info} attributes of the slaves (see
  4016 section~\ref{sec:sysfs-slave}). This is done for master $0$ by
  4013 section~\ref{sec:sysfs-slave}). This is done for master $0$ by
  4017 default, but the master index can be specified via command line:
  4014 default, but the master index can be specified via command line:
  4018 
  4015 
  4019 \begin{lstlisting}
  4016 \begin{lstlisting}
  4020   host> `\textbf{lsec -h}`
  4017   `\$` `\textbf{lsec -h}`
  4021   Usage: ec_list [OPTIONS]
  4018   Usage: ec_list [OPTIONS]
  4022           -m <IDX>    Query master <IDX>.
  4019           -m <IDX>    Query master <IDX>.
  4023           -h          Show this help.
  4020           -h          Show this help.
  4024 \end{lstlisting}
  4021 \end{lstlisting}
  4025 
  4022 
  4072   ### END INIT INFO
  4069   ### END INIT INFO
  4073 \end{lstlisting}
  4070 \end{lstlisting}
  4074 
  4071 
  4075 The init script can also be used for manually starting and stopping
  4072 The init script can also be used for manually starting and stopping
  4076 the EtherCAT master. It has to be executed with one of the parameters
  4073 the EtherCAT master. It has to be executed with one of the parameters
  4077 \textit{start}, \textit{stop}, \textit{restart} or \textit{status}.
  4074 \texttt{start}, \texttt{stop}, \texttt{restart} or \texttt{status}.
  4078 
  4075 
  4079 \begin{lstlisting}
  4076 \begin{lstlisting}
  4080   host# `\textbf{/etc/init.d/ethercat restart}`
  4077   # `\textbf{/etc/init.d/ethercat restart}`
  4081   Shutting down EtherCAT master                done
  4078   Shutting down EtherCAT master                done
  4082   Starting EtherCAT master                     done
  4079   Starting EtherCAT master                     done
  4083 \end{lstlisting}
  4080 \end{lstlisting}
  4084 
  4081 
  4085 \subsubsection{The EtherCAT Sysconfig File}
  4082 \subsubsection{The EtherCAT Sysconfig File}
  4100   section~\ref{sec:eoeimp}. Default: $0$
  4097   section~\ref{sec:eoeimp}. Default: $0$
  4101 \item[EOE\_BRIDGE] If this variable is set, all EoE interfaces will be
  4098 \item[EOE\_BRIDGE] If this variable is set, all EoE interfaces will be
  4102   added to a network bridge according to IEEE 802.1D after master
  4099   added to a network bridge according to IEEE 802.1D after master
  4103   startup. The variable must contain the name of the bridge. To use
  4100   startup. The variable must contain the name of the bridge. To use
  4104   this functionality, the kernel must be configured with the
  4101   this functionality, the kernel must be configured with the
  4105   \textit{CONFIG\_BRIDGE} option and the \textit{bridge-utils} package
  4102   CONFIG\_BRIDGE option and the \textit{bridge-utils} package must be
  4106   must be installed (i.~e. the \textit{brctl} command is needed).
  4103   installed (i.~e. the \textit{brctl} command is needed).
  4107 \item[EOE\_IP\_ADDRESS] The IP address of the EoE bridge. Setting this
  4104 \item[EOE\_IP\_ADDRESS] The IP address of the EoE bridge. Setting this
  4108   together with \textit{EOE\_IP\_NETMASK} will let the local host
  4105   together with \$EOE\_IP\_NETMASK will let the local host communicate
  4109   communicate with devices on the EoE bridge.
  4106   with devices on the EoE bridge.
  4110 \item[EOE\_IP\_NETMASK] IP netmask of the EoE bridge.
  4107 \item[EOE\_IP\_NETMASK] IP netmask of the EoE bridge.
  4111 \item[EOE\_EXTRA\_INTERFACES] The list of extra interfaces to include
  4108 \item[EOE\_EXTRA\_INTERFACES] The list of extra interfaces to include
  4112   in the EoE brid\-ge. Set this to interconnect the EoE bridge with
  4109   in the EoE brid\-ge. Set this to interconnect the EoE bridge with
  4113   other local interfaces. If \textit{EOE\_\-BRIDGE} is empty or
  4110   other local interfaces. If \$EOE\_\-BRIDGE is empty or undefined,
  4114   undefined, setting this variable has no effect. Important: The IP
  4111   setting this variable has no effect. Important: The IP address of
  4115   address of the listed interfaces will be cleared. Setting
  4112   the listed interfaces will be cleared. Setting
  4116   \textit{EOE\_\-IP\_\-ADDRESS} and \textit{EOE\_IP\_NETMASK} will
  4113   \$EOE\_\-IP\_\-ADDRESS and \$EOE\_IP\_NETMASK will re-enable them
  4117   re-enable them for IP traffic.
  4114   for IP traffic.
  4118 \item[EOE\_GATEWAY] The IP address of the default gateway. If this
  4115 \item[EOE\_GATEWAY] The IP address of the default gateway. If this
  4119   variable is set, the gateway will be renewed after bridge
  4116   variable is set, the gateway will be renewed after bridge
  4120   installation. This is necessary, if the default gateway's interface
  4117   installation. This is necessary, if the default gateway's interface
  4121   is one of the \textit{EOE\_EXTRA\_INTERFACES}.
  4118   is one of the \$EOE\_EXTRA\_INTERFACES.
  4122 \end{description}
  4119 \end{description}
  4123 
  4120 
  4124 %------------------------------------------------------------------------------
  4121 %------------------------------------------------------------------------------
  4125 
  4122 
  4126 \subsection{Monitoring and Debugging}
  4123 \subsection{Monitoring and Debugging}
  4304 can be obtained from the EtherLab\textsuperscript{\textregistered} CD.
  4301 can be obtained from the EtherLab\textsuperscript{\textregistered} CD.
  4305 The \textit{tar.bz2} file has to be unpacked with the command below
  4302 The \textit{tar.bz2} file has to be unpacked with the command below
  4306 (or similar):
  4303 (or similar):
  4307 
  4304 
  4308 \begin{lstlisting}
  4305 \begin{lstlisting}
  4309   host> `\textbf{tar xjf ethercat-1.1-rXXX.tar.bz2}`
  4306   `\$` `\textbf{tar xjf ethercat-1.1-rXXX.tar.bz2}`
  4310   host> `\textbf{cd ethercat-1.1-rXXX/}`
  4307   `\$` `\textbf{cd ethercat-1.1-rXXX/}`
  4311 \end{lstlisting}
  4308 \end{lstlisting}
  4312 
  4309 
  4313 The tarball was created with GNU Autotools, so the build process
  4310 The tarball was created with GNU Autotools, so the build process
  4314 follows the usual commands:
  4311 follows the usual commands:
  4315 
  4312 
  4316 \begin{lstlisting}
  4313 \begin{lstlisting}
  4317   host> `\textbf{./configure}`
  4314   `\$` `\textbf{./configure}`
  4318   host> `\textbf{make}`
  4315   `\$` `\textbf{make}`
  4319 \end{lstlisting}
  4316 \end{lstlisting}
  4320 
  4317 
  4321 The default installation prefix is \textit{/opt/etherlab}. It can be
  4318 The default installation prefix is \textit{/opt/etherlab}. It can be
  4322 changed with the \texttt{--prefix} argument.
  4319 changed with the \texttt{--prefix} argument.
  4323 
  4320 
  4327 modules for a different kernel than the running kernel, the target
  4324 modules for a different kernel than the running kernel, the target
  4328 kernel version can be specified with the \texttt{--with-linux}
  4325 kernel version can be specified with the \texttt{--with-linux}
  4329 argument. Example:
  4326 argument. Example:
  4330 
  4327 
  4331 \begin{lstlisting}
  4328 \begin{lstlisting}
  4332   host> `\textbf{./configure --with-linux="2.6.17-ipipe"}`
  4329   `\$` `\textbf{./configure --with-linux="2.6.17-ipipe"}`
  4333   host> `\textbf{make}`
  4330   `\$` `\textbf{make}`
  4334 \end{lstlisting}
  4331 \end{lstlisting}
  4335 
  4332 
  4336 The following commands have to be entered as \textit{root}: To install
  4333 The following commands have to be entered as \textit{root}: To install
  4337 the kernel modules, headers, the init script, the sysconfig file and
  4334 the kernel modules, headers, the init script, the sysconfig file and
  4338 the user space tools, the below command has to be executed:
  4335 the user space tools, the below command has to be executed:
  4339 
  4336 
  4340 \begin{lstlisting}
  4337 \begin{lstlisting}
  4341   host# `\textbf{make install}`
  4338   # `\textbf{make install}`
  4342 \end{lstlisting}
  4339 \end{lstlisting}
  4343 
  4340 
  4344 If the EtherCAT master shall be run as a service
  4341 If the EtherCAT master shall be run as a service
  4345 (recommended\footnote{Even if the EtherCAT master shall not be loaded
  4342 (recommended\footnote{Even if the EtherCAT master shall not be loaded
  4346   on system startup, the use of the init script is recommended for
  4343   on system startup, the use of the init script is recommended for
  4347   manual (un-)loading.}), the init script and the sysconfig file have
  4344   manual (un-)loading.}), the init script and the sysconfig file have
  4348 to be copied to the appropriate locations. The below example is
  4345 to be copied to the appropriate locations. The below example is
  4349 suitable for SUSE Linux.  It may vary for other distributions.
  4346 suitable for SUSE Linux.  It may vary for other distributions.
  4350 
  4347 
  4351 \begin{lstlisting}
  4348 \begin{lstlisting}
  4352   host# `\textbf{cd /opt/etherlab}`
  4349   # `\textbf{cd /opt/etherlab}`
  4353   host# `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}`
  4350   # `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}`
  4354   host# `\textbf{cp etc/init.d/ethercat /etc/init.d/}`
  4351   # `\textbf{cp etc/init.d/ethercat /etc/init.d/}`
  4355   host# `\textbf{insserv ethercat}`
  4352   # `\textbf{insserv ethercat}`
  4356 \end{lstlisting}
  4353 \end{lstlisting}
  4357 
  4354 
  4358 Now the sysconfig file \texttt{/etc/sysconfig/ethercat} (see
  4355 Now the sysconfig file \texttt{/etc/sysconfig/ethercat} (see
  4359 section~\ref{sec:sysconfig}) has to be customized: This is mainly done
  4356 section~\ref{sec:sysconfig}) has to be customized: This is mainly done
  4360 by uncommenting and adjusting the \textit{DEVICE\_INDEX} variable. It
  4357 by uncommenting and adjusting the \$DEVICE\_INDEX variable. It has to
  4361 has to be set to the index of the compatible network device to use
  4358 be set to the index of the compatible network device to use with
  4362 with EtherCAT, where the order of devices is dependent on their
  4359 EtherCAT, where the order of devices is dependent on their position in
  4363 position in the PCI bus:
  4360 the PCI bus:
  4364 
  4361 
  4365 \begin{lstlisting}[numbers=left,basicstyle=\ttfamily\scriptsize]
  4362 \begin{lstlisting}[numbers=left,basicstyle=\ttfamily\scriptsize]
  4366   host# `\textbf{lspci}`
  4363   # `\textbf{lspci}`
  4367   00:00.0 Host bridge: VIA Technologies, Inc. VT8363/8365 [KT133/KM133] (rev 03)
  4364   00:00.0 Host bridge: VIA Technologies, Inc. VT8363/8365 [KT133/KM133] (rev 03)
  4368   00:01.0 PCI bridge: VIA Technologies, Inc. VT8363/8365 [KT133/KM133 AGP]
  4365   00:01.0 PCI bridge: VIA Technologies, Inc. VT8363/8365 [KT133/KM133 AGP]
  4369   00:04.0 ISA bridge: VIA Technologies, Inc. VT82C686 [Apollo Super South] (rev 40)
  4366   00:04.0 ISA bridge: VIA Technologies, Inc. VT82C686 [Apollo Super South] (rev 40)
  4370   00:04.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C...
  4367   00:04.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C...
  4371   00:04.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller...
  4368   00:04.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller...
  4378   00:11.0 Unknown mass storage controller: Promise Technology, Inc. PDC20265...
  4375   00:11.0 Unknown mass storage controller: Promise Technology, Inc. PDC20265...
  4379 \end{lstlisting}
  4376 \end{lstlisting}
  4380 
  4377 
  4381 In the above output of the \textit{lspci} command, two compatible
  4378 In the above output of the \textit{lspci} command, two compatible
  4382 network devices can be found in lines~\textcircled{\tiny 9} and
  4379 network devices can be found in lines~\textcircled{\tiny 9} and
  4383 \textcircled{\tiny 11}. The \textit{DEVICE\_INDEX} variable should be
  4380 \textcircled{\tiny 11}. The \$DEVICE\_INDEX variable should be set to
  4384 set to $0$ or $1$, respectively.
  4381 $0$ or $1$, respectively.
  4385 
  4382 
  4386 After the basic configuration is done, the master can be started with
  4383 After the basic configuration is done, the master can be started with
  4387 the below command:
  4384 the below command:
  4388 
  4385 
  4389 \begin{lstlisting}
  4386 \begin{lstlisting}
  4390   host# `\textbf{/etc/init.d/ethercat start}`
  4387   # `\textbf{/etc/init.d/ethercat start}`
  4391 \end{lstlisting}
  4388 \end{lstlisting}
  4392 
  4389 
  4393 The operation of the master can be observed by looking at the
  4390 The operation of the master can be observed by looking at the
  4394 syslog\index{syslog} messages, which should look like the ones below.
  4391 syslog\index{syslog} messages, which should look like the ones below.
  4395 If EtherCAT slaves are connected to the master's EtherCAT device, the
  4392 If EtherCAT slaves are connected to the master's EtherCAT device, the
  4548   Alternatively the data fields could be registered with individual
  4545   Alternatively the data fields could be registered with individual
  4549   calls of \textit{ecrt\_domain\_register\_pdo()}.
  4546   calls of \textit{ecrt\_domain\_register\_pdo()}.
  4550 \item[\normalfont\textcircled{\tiny 16}] After the configuration of
  4547 \item[\normalfont\textcircled{\tiny 16}] After the configuration of
  4551   process data mapping, the master can be activated for cyclic
  4548   process data mapping, the master can be activated for cyclic
  4552   operation. This will configure all slaves and bring them into
  4549   operation. This will configure all slaves and bring them into
  4553   \textit{OP} state.
  4550   OP state.
  4554 \item[\normalfont\textcircled{\tiny 20}] This call is needed to avoid
  4551 \item[\normalfont\textcircled{\tiny 20}] This call is needed to avoid
  4555   a case differentiation in cyclic operation: The first operation in
  4552   a case differentiation in cyclic operation: The first operation in
  4556   cyclic mode is a receive call. Due to the fact, that there is
  4553   cyclic mode is a receive call. Due to the fact, that there is
  4557   nothing to receive during the first cycle, there had to be an
  4554   nothing to receive during the first cycle, there had to be an
  4558   \textit{if}-statement to avoid a warning. A call to
  4555   \textit{if}-statement to avoid a warning. A call to
  4583   necessary to stop the cyclic processing. This is done by a call to
  4580   necessary to stop the cyclic processing. This is done by a call to
  4584   \textit{del\_timer\_sync()} which safely removes a queued timer
  4581   \textit{del\_timer\_sync()} which safely removes a queued timer
  4585   object. It is assured, that no cyclic work will be done after this
  4582   object. It is assured, that no cyclic work will be done after this
  4586   call returns.
  4583   call returns.
  4587 \item[\normalfont\textcircled{\tiny 4}] This call deactivates the
  4584 \item[\normalfont\textcircled{\tiny 4}] This call deactivates the
  4588   master, which results in all slaves being brought to their
  4585   master, which results in all slaves being brought to their INIT
  4589   \textit{INIT} state again.
  4586   state again.
  4590 \item[\normalfont\textcircled{\tiny 5}] This call releases the master,
  4587 \item[\normalfont\textcircled{\tiny 5}] This call releases the master,
  4591   removes any existing configuration and silently starts the idle
  4588   removes any existing configuration and silently starts the idle
  4592   mode. The value of the master pointer is invalid after this call and
  4589   mode. The value of the master pointer is invalid after this call and
  4593   the module can be safely unloaded.
  4590   the module can be safely unloaded.
  4594 \end{description}
  4591 \end{description}