816 |
820 |
817 \item[\usebox\boxopen] This function is called when network communication has |
821 \item[\usebox\boxopen] This function is called when network communication has |
818 to be started, for example after a command \lstinline+ip link set ethX up+ |
822 to be started, for example after a command \lstinline+ip link set ethX up+ |
819 from userspace. Frame reception has to be enabled by the driver. |
823 from userspace. Frame reception has to be enabled by the driver. |
820 |
824 |
821 \item[\usebox\boxstop] The purpose of this callback is to ``close'' the device, |
825 \item[\usebox\boxstop] The purpose of this callback is to ``close'' the |
822 i.~e. make the hardware stop receiving frames. |
826 device, i.~e. make the hardware stop receiving frames. |
823 |
827 |
824 \item[\usebox\boxxmit] This function is called for each frame that has to be |
828 \item[\usebox\boxxmit] This function is called for each frame that has to be |
825 transmitted. The network stack passes the frame as a pointer to an |
829 transmitted. The network stack passes the frame as a pointer to an |
826 \lstinline+sk_buff+ structure (``socket buffer''\index{Socket buffer}, see |
830 \lstinline+sk_buff+ structure (``socket buffer''\index{Socket buffer}, see |
827 below), which has to be freed after sending. |
831 below), which has to be freed after sending. |
2315 |
2319 |
2316 \subsection{Bus Cycle Measuring} |
2320 \subsection{Bus Cycle Measuring} |
2317 \label{sec:timing-bus} |
2321 \label{sec:timing-bus} |
2318 \index{Bus cycle} |
2322 \index{Bus cycle} |
2319 |
2323 |
2320 For measuring the time, a frame is ``on the wire'', two timestamps |
2324 For measuring the time, a frame is ``on the wire'', two timestamps must be |
2321 must be be taken: |
2325 taken: |
2322 |
2326 |
2323 \begin{enumerate} |
2327 \begin{enumerate} |
2324 \item The time, the Ethernet hardware begins with physically sending |
2328 |
2325 the frame. |
2329 \item The time, the Ethernet hardware begins with physically sending the |
2326 \item The time, the frame is completely received by the Ethernet |
2330 frame. |
2327 hardware. |
2331 |
|
2332 \item The time, the frame is completely received by the Ethernet hardware. |
|
2333 |
2328 \end{enumerate} |
2334 \end{enumerate} |
2329 |
2335 |
2330 Both times are difficult to determine. The first reason is, that the |
2336 Both times are difficult to determine. The first reason is, that the |
2331 interrupts are disabled and the master is not notified, when a frame |
2337 interrupts are disabled and the master is not notified, when a frame is sent |
2332 is sent or received (polling would distort the results). The second |
2338 or received (polling would distort the results). The second reason is, that |
2333 reason is, that even with interrupts enabled, the time from the event |
2339 even with interrupts enabled, the time from the event to the notification is |
2334 to the notification is unknown. Therefore the only way to confidently |
2340 unknown. Therefore the only way to confidently determine the bus cycle time is |
2335 determine the bus cycle time is an electrical measuring. |
2341 an electrical measuring. |
2336 |
2342 |
2337 Anyway, the bus cycle time is an important factor when designing realtime |
2343 Anyway, the bus cycle time is an important factor when designing realtime |
2338 code, because it limits the maximum frequency for the cyclic task of the |
2344 code, because it limits the maximum frequency for the cyclic task of the |
2339 application. In practice, these timing parameters are highly dependent on the |
2345 application. In practice, these timing parameters are highly dependent on the |
2340 hardware and often a trial and error method must be used to determine the |
2346 hardware and often a trial and error method must be used to determine the |
2341 limits of the system. |
2347 limits of the system. |
2342 |
2348 |
2343 The central question is: What happens, if the cycle frequency is too high? The |
2349 The central question is: What happens, if the cycle frequency is too high? The |
2344 answer is, that the EtherCAT frames that have been sent at the end of the cycle |
2350 answer is, that the EtherCAT frames that have been sent at the end of the |
2345 are not yet received, when the next cycle starts. First this is noticed by |
2351 cycle are not yet received, when the next cycle starts. First this is noticed |
2346 \textit{ecrt\_domain\_process()}, because the working counter of the process |
2352 by \textit{ecrt\_domain\_process()}, because the working counter of the |
2347 data datagrams were not increased. The function will notify the user via |
2353 process data datagrams were not increased. The function will notify the user |
2348 Syslog\footnote{To limit Syslog output, a mechanism has been implemented, that |
2354 via Syslog\footnote{To limit Syslog output, a mechanism has been implemented, |
2349 outputs a summarized notification at maximum once a second.}. In this case, the |
2355 that outputs a summarized notification at maximum once a second.}. In this |
2350 process data keeps being the same as in the last cycle, because it is not |
2356 case, the process data keeps being the same as in the last cycle, because it |
2351 erased by the domain. When the domain datagrams are queued again, the master |
2357 is not erased by the domain. When the domain datagrams are queued again, the |
2352 notices, that they are already queued (and marked as sent). The master will |
2358 master notices, that they are already queued (and marked as sent). The master |
2353 mark them as unsent again and output a warning, that datagrams were |
2359 will mark them as unsent again and output a warning, that datagrams were |
2354 ``skipped''. |
2360 ``skipped''. |
2355 |
2361 |
2356 On the mentioned \unit{2.0}{\giga\hertz} system, the possible cycle frequency |
2362 On the mentioned \unit{2.0}{\giga\hertz} system, the possible cycle frequency |
2357 can be up to \unit{25}{\kilo\hertz} without skipped frames. This value can |
2363 can be up to \unit{25}{\kilo\hertz} without skipped frames. This value can |
2358 surely be increased by choosing faster hardware. Especially the RealTek network |
2364 surely be increased by choosing faster hardware. Especially the RealTek |
2359 hardware could be replaced by a faster one. Besides, implementing a dedicated |
2365 network hardware could be replaced by a faster one. Besides, implementing a |
2360 ISR for EtherCAT devices would also contribute to increasing the latency. These |
2366 dedicated ISR for EtherCAT devices would also contribute to increasing the |
2361 are two points on the author's to-do list. |
2367 latency. These are two points on the author's to-do list. |
2362 |
2368 |
2363 %------------------------------------------------------------------------------ |
2369 %------------------------------------------------------------------------------ |
2364 |
2370 |
2365 \chapter{Installation} |
2371 \chapter{Installation} |
2366 \label{sec:installation} |
2372 \label{sec:installation} |