author | etisserant |
Tue, 12 Feb 2008 15:38:54 +0100 | |
changeset 393 | 05ad3ba0201d |
parent 392 | 3788feef57e0 |
child 394 | b8755668c9e2 |
permissions | -rw-r--r-- |
393 | 1 |
%% LyX 1.5.1 created this file. For more info, see http://www.lyx.org/. |
2 |
%% Do not edit unless you really know what you are doing. |
|
3 |
\documentclass[12pt,english,a4paper]{book} |
|
208 | 4 |
\usepackage[T1]{fontenc} |
393 | 5 |
\usepackage[latin9]{inputenc} |
6 |
\setcounter{secnumdepth}{5} |
|
7 |
\setcounter{tocdepth}{3} |
|
8 |
\usepackage{graphicx} |
|
9 |
\usepackage{amsfonts} |
|
10 |
\usepackage{textcomp} |
|
208 | 11 |
\usepackage{color} |
12 |
\usepackage{calc} |
|
13 |
\usepackage{longtable} |
|
14 |
\usepackage{hyperref} |
|
15 |
\usepackage{graphics} |
|
16 |
\DeclareGraphicsExtensions{.jpg} |
|
17 |
\DeclareGraphicsExtensions{.png} |
|
18 |
\hypersetup{colorlinks=true, linkcolor=blue, filecolor=blue, pagecolor=blue, urlcolor=blue} |
|
19 |
||
20 |
%%%%\%%%%%%%% titre, auteurs, date, etc...%%%%%%%%%%%%%%%%%% |
|
249 | 21 |
\title{\Huge The CanFestival CANOpen stack manual} |
208 | 22 |
\author{Edouard TISSERANT} |
23 |
\date{\today} |
|
24 |
||
393 | 25 |
\newcommand{\canopen}{CANopen } |
392
3788feef57e0
Some typo fixes in the manual, thanks to Yegor Yefremov (VisionSystems)
etisserant
parents:
391
diff
changeset
|
26 |
|
208 | 27 |
\begin{document} |
393 | 28 |
{\centering\textsf{\huge The CanFestival \canopen stack manual.}} |
29 |
||
30 |
\renewcommand{\contentsname}{CanFestival v3.0 Manual} |
|
31 |
\setcounter{tocdepth}{2} \tableofcontents{} |
|
32 |
||
33 |
\clearpage{} |
|
34 |
||
208 | 35 |
\section{Introduction} |
393 | 36 |
|
37 |
CanFestival is an OpenSource (LGPL and GPL) \canopen framework. |
|
208 | 38 |
|
39 |
\subsection{The CanFestival project} |
|
393 | 40 |
|
41 |
This project, initiated by Edouard TISSERANT in 2001, has grown thanks |
|
42 |
to Francis DUPIN and other contributors. |
|
43 |
||
44 |
Today, CanFestival focuses on providing an ANSI-C platform independent |
|
45 |
\canopen stack that can be implemented as master or slave nodes on |
|
46 |
PCs, Real-time IPCs, and Microcontrollers. |
|
208 | 47 |
|
48 |
CanFestival is a project supported by Lolitech. |
|
49 |
||
393 | 50 |
|
51 |
\subsection{What is \canopen} |
|
52 |
||
53 |
CANopen is a CAN based high level protocol. It defines some protocols |
|
54 |
to : |
|
55 |
||
208 | 56 |
\begin{enumerate} |
393 | 57 |
\item Configure a CAN network. |
58 |
\item Transmit data to a specific node or in broadcast. |
|
59 |
\item Administrate the network. For example detecting a not responding node. |
|
208 | 60 |
\end{enumerate} |
392
3788feef57e0
Some typo fixes in the manual, thanks to Yegor Yefremov (VisionSystems)
etisserant
parents:
391
diff
changeset
|
61 |
The documentation can be found on the CAN in Automation website : |
208 | 62 |
|
393 | 63 |
\href{http://www.can-cia.de/canopen}{http://www.can-cia.de/canopen} |
64 |
||
65 |
The most important document about \canopen is the normative CiA Draft |
|
66 |
Standard 301, version 4.02. You can now download the specification |
|
67 |
from the CAN in Automation website at no cost. |
|
68 |
||
69 |
To continue reading this document, let us assume that you have read |
|
70 |
some papers introducing \canopen . |
|
71 |
||
208 | 72 |
|
73 |
\section{CanFestival Features} |
|
393 | 74 |
|
75 |
||
208 | 76 |
\subsection{Tools } |
393 | 77 |
|
78 |
The \canopen library is coming with some tools : |
|
79 |
||
208 | 80 |
\begin{enumerate} |
393 | 81 |
\item Object Dictionary editor GUI. WxPython Model-View-Controler based |
82 |
GUI, that help a lot in generating object dictionary source code for |
|
83 |
each node. |
|
84 |
\item A configure script, that let you chose compile time options such as |
|
85 |
target CPU/HOST, CAN and TIMER drivers.\\ |
|
86 |
This script has not been generated with autoconf, it has been made |
|
87 |
keeping micro-controller target in mind. |
|
208 | 88 |
\end{enumerate} |
393 | 89 |
|
208 | 90 |
\subsection{Standard conformance} |
393 | 91 |
|
92 |
||
93 |
\subsubsection{Multi-Platform} |
|
94 |
||
208 | 95 |
\begin{enumerate} |
393 | 96 |
\item Library source code is C-ANSI. |
97 |
\item Driver and examples coding conventions merely depend on target specific |
|
98 |
contributor/compiler. |
|
208 | 99 |
\item Unix compatible interfaces and examples should compile and run on |
393 | 100 |
any Unix system (tested on GNU/Linux and GNU/FreeBSD). |
208 | 101 |
\end{enumerate} |
393 | 102 |
|
103 |
\subsubsection{\canopen conformance} |
|
104 |
||
105 |
||
106 |
\paragraph{DS-301} |
|
107 |
||
208 | 108 |
\begin{enumerate} |
393 | 109 |
\item Should conform to DS301. V.4.02 13 february 2002. |
110 |
\item Master and Slave functionality implemented. |
|
111 |
\item Sending SYNC implemented. |
|
208 | 112 |
\item 1 SDO server per node. (update: more than one possible. To be more |
393 | 113 |
tested) |
114 |
\item Unlimited SDO client. |
|
115 |
\item SDO transmission mode : normal, expedited download and upload. |
|
116 |
\item Unlimited PDO receive. |
|
117 |
\item Unlimited PDO transmit. |
|
118 |
\item Object Data type implemented : 8, 16, 32 bits values, and fixed length |
|
119 |
strings. |
|
120 |
\item Slave state full implemented. |
|
121 |
\item NMT to change slaves state implemented. |
|
122 |
\item PDO transmission mode : on request, every reception of 0 to n SYNC, |
|
123 |
on event. |
|
124 |
\item NMT Heartbeat implemented : A node can be either heartbeat producer |
|
125 |
or receiver. |
|
126 |
\item NMT NodeGuard implemented : Not fully implemented. |
|
127 |
\item TIME (time Stamp) : Not implemented. |
|
128 |
\item EMCY (emergency objects) : Sending and reception of EMCY objectos |
|
129 |
(without manufacturer specific error field). |
|
130 |
\item PDO Mapping bit per bit implemented. |
|
208 | 131 |
\end{enumerate} |
393 | 132 |
|
133 |
\paragraph{DS-302} |
|
134 |
||
208 | 135 |
\begin{enumerate} |
393 | 136 |
\item Concise DFC : implemented. |
208 | 137 |
\end{enumerate} |
393 | 138 |
|
208 | 139 |
\section{How to start} |
393 | 140 |
|
141 |
||
208 | 142 |
\subsection{Host requirements} |
393 | 143 |
|
208 | 144 |
What you need on your development workstation. |
145 |
||
393 | 146 |
|
208 | 147 |
\subsubsection{Object Dictionary Editor GUI} |
393 | 148 |
|
208 | 149 |
\begin{enumerate} |
150 |
\item Python, with |
|
151 |
\item wxPyhon modules installed (at least version 2.6.3). |
|
393 | 152 |
\item Gnosis xml tools. (Optional can also be installed locally to the project |
153 |
automatically with the help of a Makefile. Please see {}``Using Dictionary |
|
154 |
Editor GUI'' ) |
|
208 | 155 |
\end{enumerate} |
393 | 156 |
|
157 |
\subsubsection{Linux and Unix-likes} |
|
158 |
||
208 | 159 |
\begin{enumerate} |
393 | 160 |
\item Linux, FreeBSD, Cygwin or any Unix environment with GNU toolchain. |
161 |
\item The GNU C compiler (gcc) or any other ANSI-C compiler for your target |
|
162 |
platform. |
|
208 | 163 |
\item Xpdf, and the official 301\_v04000201.pdf file in order to get GUI |
393 | 164 |
context sensitive help. |
165 |
\item GNU Make |
|
166 |
\item Bash and sed |
|
208 | 167 |
\end{enumerate} |
393 | 168 |
|
208 | 169 |
\subsubsection{Windows (for native win32 target)} |
393 | 170 |
|
208 | 171 |
\begin{enumerate} |
393 | 172 |
\item Visual Studio Express 2005 or worst. |
173 |
\item Microsoft platform SDK (requires Genuine Advantage) |
|
174 |
\item Cygwin (for configuration only) |
|
208 | 175 |
\end{enumerate} |
393 | 176 |
|
208 | 177 |
\subsection{How to get CanFestival} |
393 | 178 |
|
208 | 179 |
Please always use CVS, this is the best way to get the most reactive |
180 |
support from the developer community : |
|
181 |
||
393 | 182 |
cvs -d:pserver:anonymous@lolitech.dyndns.org:/canfestival login\\ |
183 |
(type return, without entering a password) |
|
184 |
||
185 |
Then, enter : \\ |
|
186 |
cvs -z3 -d:pserver:anonymous@lolitech.dyndns.org:/canfestival co |
|
187 |
-P CanFestival-3 |
|
188 |
||
208 | 189 |
|
190 |
\section{Understanding Canfestival} |
|
393 | 191 |
|
192 |
||
208 | 193 |
\subsection{CanFestival Project tree layout} |
393 | 194 |
|
208 | 195 |
Simplified directory structure. |
196 |
||
393 | 197 |
\texttt{\textbf{./src ANSI-C source of \canopen stack}} |
198 |
||
199 |
\texttt{\textbf{./include Exportables Header files}} |
|
200 |
||
201 |
\texttt{\textbf{./drivers Interfaces to specific platforms/HW}} |
|
202 |
||
203 |
\texttt{./drivers/unix Linux and Cygwin OS interface} |
|
204 |
||
205 |
\texttt{./drivers/win32 Native Win32 OS interface} |
|
206 |
||
207 |
\texttt{./drivers/timers\_xeno Xenomai timers/threads (Linux only)} |
|
208 |
||
209 |
\texttt{./drivers/timers\_kernel Linux kernel timer/threads} |
|
210 |
||
211 |
\texttt{./drivers/timers\_unix Posix timers/threads (Linux, Cygwin)} |
|
212 |
||
213 |
\texttt{./drivers/can\_virtual\_kernel Fake CAN network (kernel space)} |
|
214 |
||
215 |
\texttt{./drivers/can\_peak\_linux PeakSystem CAN library interface} |
|
216 |
||
217 |
\texttt{./drivers/can\_peak\_win32 PeakSystem PCAN -Light interface} |
|
218 |
||
219 |
\texttt{./drivers/can\_uvccm\_win32 Acacetus{\textquotesingle}s |
|
220 |
RS232 {}``CAN -uVCCM'' interface} |
|
221 |
||
222 |
\texttt{./drivers/can\_virtual Fake CAN network (Linux, Cygwin)} |
|
223 |
||
224 |
\texttt{./drivers/hcs12 HCS12 full target interface} |
|
225 |
||
226 |
\texttt{\textbf{./examples Examples}} |
|
227 |
||
228 |
\texttt{./examples/TestMasterSlave 2 nodes, NMT SYNC SDO PDO, win32+unix} |
|
229 |
||
230 |
\texttt{./examples/TestMasterMicroMod 1 node, control Peak I/O Module, |
|
231 |
unix} |
|
232 |
||
233 |
\texttt{./examples/gene\_SYNC\_HCS12 Just send periodic SYNC on HCS12} |
|
234 |
||
235 |
\texttt{./examples/win32test Ask some DS301 infos to a node (}\texttt{\textbf{win32)}} |
|
236 |
||
237 |
\texttt{\textbf{./objdictgen Object Dictionary editor GUI}} |
|
238 |
||
239 |
\texttt{./objdictgen/config Pre -defined OD profiles} |
|
240 |
||
241 |
\texttt{./objdictgen/examples Some examples/test OD} |
|
242 |
||
243 |
\texttt{\textbf{./doc Project and \canopen doc}} |
|
244 |
||
208 | 245 |
|
246 |
\subsection{Implement CanFestival in your application} |
|
393 | 247 |
|
248 |
\begin{center} |
|
249 |
\includegraphics[width=12cm]{Pictures/10000201000003F9000002CF880931E7} |
|
250 |
\par\end{center} |
|
251 |
||
252 |
\bigskip{} |
|
253 |
||
254 |
||
208 | 255 |
|
256 |
\subsection{CanFestival CAN interfaces} |
|
393 | 257 |
|
208 | 258 |
Because most CAN controllers and drivers implement FIFOs, CanFestival |
259 |
consider sending message as a non bloking operation. |
|
260 |
||
393 | 261 |
In order to prevent reentrent calls to the stack, messages reception |
262 |
is implemented differently on {\textmu}C and OS.: |
|
263 |
||
208 | 264 |
\begin{enumerate} |
393 | 265 |
\item {\textmu}C must provide interuption masking for timer and can receive |
266 |
TI\\ |
|
267 |
||
268 |
||
269 |
||
270 |
\begin{center} |
|
271 |
\includegraphics[width=12cm]{Pictures/10000201000003CA0000016604E6A5EF} |
|
272 |
\par\end{center} |
|
273 |
||
208 | 274 |
\item OS must provide a receive thread, a timer thread and a mutex. CAN |
393 | 275 |
reception is a bloking operation.\\ |
276 |
||
277 |
||
278 |
||
279 |
\begin{center} |
|
280 |
\includegraphics[width=12cm]{Pictures/10000201000003F9000002CF8B0CDAEA} |
|
281 |
\par\end{center} |
|
282 |
||
208 | 283 |
\end{enumerate} |
393 | 284 |
|
208 | 285 |
\subsection{CanFestival events scheduling} |
393 | 286 |
|
287 |
A \canopen node must be able to take delayed actions. |
|
208 | 288 |
|
289 |
As exemples, periodic sync emission, heartbeat production or SDO timeout |
|
290 |
need to set some alarms that will be called later and do the job. |
|
291 |
||
393 | 292 |
{\textmu}C generaly do not have enough free timers to handle all |
293 |
the \canopen needs directly. Moreover, CanFestival internal data |
|
294 |
may be corrupt by reentrant calls. |
|
295 |
||
296 |
CanFestival implement a micro -scheduler (timer.c). It uses only one |
|
208 | 297 |
timer to mimic many timers. It manage an alarm table, and call alarms |
298 |
at desired time. |
|
299 |
||
300 |
\begin{center} |
|
393 | 301 |
\includegraphics[width=12cm]{Pictures/100000000000022C000000DEDAD2140C} |
302 |
\par\end{center} |
|
303 |
||
304 |
Scheduler can handle short clock value ranges limitation found on |
|
305 |
some {\textmu}C. As an example, value range for a 16bit clock counter |
|
306 |
with 4{\textmu}s tick is crossed within 0.26 seconds... Long alarms |
|
307 |
must be segmented. |
|
308 |
||
309 |
Chronogram illustrate a long alarm (A) and a short periodic alarm |
|
310 |
(B), with a A value {\textgreater} clock range {\textgreater} |
|
311 |
B value. Values t0...t8 are successive setTimer call parameter values. |
|
312 |
t1 illustrates an intermediate call to TimeDispatch, caused by a delay |
|
313 |
longer than clock range. Because of long alarm segmentation, at the |
|
314 |
end of t1, TimeDispatch call will not trig any alarm callback. |
|
315 |
||
316 |
\begin{center} |
|
317 |
\includegraphics[width=12cm]{Pictures/1000000000000396000000FFC42573DA} |
|
318 |
\par\end{center} |
|
319 |
||
208 | 320 |
|
321 |
\section{Linux Target} |
|
393 | 322 |
|
208 | 323 |
Linux target is default configure target. |
324 |
||
393 | 325 |
|
208 | 326 |
\subsection{Linux Compilation and installation} |
393 | 327 |
|
328 |
Call ./configure -- help to see all available compile time options. |
|
208 | 329 |
|
330 |
After invoking ./configure with your platform specific switches, just |
|
331 |
type make. |
|
332 |
||
393 | 333 |
\texttt{./configure {[}options]} |
334 |
||
335 |
\texttt{make} |
|
336 |
||
337 |
\texttt{make install} |
|
338 |
||
208 | 339 |
|
340 |
\subsubsection{Standard Linux node} |
|
393 | 341 |
|
208 | 342 |
Configure switch: |
343 |
||
393 | 344 |
\texttt{- -timers=unix} |
345 |
||
346 |
To do a \canopen node running on PC -Linux, you need : |
|
347 |
||
208 | 348 |
\begin{enumerate} |
393 | 349 |
\item A working linux distribution |
350 |
\item One or more Peak system PC CAN interface and the last Peak Linux driver |
|
351 |
installed. |
|
208 | 352 |
\end{enumerate} |
393 | 353 |
|
354 |
\subsubsection{Real -Time Linux node} |
|
355 |
||
208 | 356 |
Configure switch: |
357 |
||
393 | 358 |
\texttt{- -timers=xeno} |
359 |
||
360 |
To do a \canopen node running on PC -Linux, you need : |
|
361 |
||
208 | 362 |
\begin{enumerate} |
393 | 363 |
\item A working Linux distribution patched with XENOMAI 2.1 or greater. |
364 |
\item One or more Peak system PC CAN interface and the last Peak Real Time |
|
365 |
Linux driver installed. |
|
208 | 366 |
\end{enumerate} |
391
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
367 |
|
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
368 |
\subsubsection{Linux kernel node} |
393 | 369 |
|
391
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
370 |
To do a CANopen node running on PC-Linux in kernel space, you need: |
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
371 |
|
393 | 372 |
|
391
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
373 |
\paragraph{A working Linux distribution with pre-built 2.6.x.x kernel sources} |
393 | 374 |
|
375 |
||
391
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
376 |
\paragraph{A CAN card driver compatible with CanFestival} |
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
377 |
|
393 | 378 |
|
208 | 379 |
\subsubsection{CAN devices} |
393 | 380 |
|
208 | 381 |
Curently supported CAN devices and corresponding configure switch: |
382 |
||
393 | 383 |
|
208 | 384 |
\paragraph{Peak systems} |
393 | 385 |
|
208 | 386 |
Configure switch: |
387 |
||
393 | 388 |
\texttt{- -can=peak\_linux} |
389 |
||
390 |
PeakSystems CAN interface is automatically chosen as default CAN interface |
|
391 |
if libpcan is present in the system. |
|
392 |
||
393 |
Please download driver at \href{http://www.peak-system.com/linux}{http://www.peak |
|
394 |
-system.com/linux} and follow instructions in order to install driver |
|
395 |
on your system. |
|
396 |
||
397 |
||
398 |
\paragraph{Socket -Can (http://socketcan.berlios.de)} |
|
399 |
||
208 | 400 |
Configure switch: |
401 |
||
393 | 402 |
\texttt{- -can=socket} |
403 |
||
208 | 404 |
|
405 |
\paragraph{LinCan} |
|
393 | 406 |
|
208 | 407 |
Configure switch: |
408 |
||
393 | 409 |
\texttt{- -can=lincan} |
410 |
||
208 | 411 |
|
412 |
\paragraph{Virtual CAN interfaces (for test/debug)} |
|
393 | 413 |
|
208 | 414 |
Configure switch: |
415 |
||
393 | 416 |
\texttt{- -can=virtual (in user space)} |
417 |
||
418 |
\texttt{- -can=virtual\_kernel (in kernel space)} |
|
208 | 419 |
|
420 |
Virtual CAN interface use Unix pipes to emulate a virtual CAN network. |
|
421 |
Each message issued from a node is repeat to all other nodes. Currently |
|
422 |
only works with nodes running in the same process, and does not support |
|
423 |
work with Xenomai. |
|
424 |
||
393 | 425 |
|
208 | 426 |
\subsection{Testing your CanFestival installation} |
393 | 427 |
|
208 | 428 |
Sample provided in /example/TestMasterSlave is installed into your |
429 |
system during installation. |
|
430 |
||
393 | 431 |
\texttt{TestMasterSlave} |
208 | 432 |
|
392
3788feef57e0
Some typo fixes in the manual, thanks to Yegor Yefremov (VisionSystems)
etisserant
parents:
391
diff
changeset
|
433 |
Default CAN driver library is libcanfestival\_can\_virtual.so., which |
208 | 434 |
will simply pass CAN messages through Unix pipes between Master and |
393 | 435 |
Slave. |
436 |
||
437 |
You may also want to specify different can interface and define some |
|
438 |
CAN ports. Another example using Peak{\textquotesingle}s dual PCMCIA |
|
439 |
(configure and install with --can=peak) : |
|
440 |
||
441 |
\texttt{TestMasterSlave -l libcanfestival\_can\_peak.so -s 40 -m 41} |
|
442 |
||
443 |
\texttt{example/kerneltest} It's based on TestMasterSlave example |
|
444 |
and has the same functionality. Uses virtual can driver as default |
|
445 |
too. After successfull installation you can insert the module by typing: |
|
446 |
modprobe canf\_ktest Module control is done by simple console 'canf\_ktest\_console' |
|
447 |
which is used to start/stop sending data. |
|
448 |
||
391
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
449 |
|
208 | 450 |
\section{Windows Targets} |
393 | 451 |
|
208 | 452 |
CanFestival can be compiled and run on Windows platform. It is possible |
453 |
to use both Cygwin and win32 native runtime environment. |
|
454 |
||
393 | 455 |
|
208 | 456 |
\subsection{Object Dictionary Editor GUI installation.} |
393 | 457 |
|
458 |
Please refer to \hyperlink{a821UsingDictionaryEditorGUIoutline}{8.2.1)Using |
|
459 |
Dictionary Editor GUI} |
|
460 |
||
208 | 461 |
|
462 |
\subsection{CYGWIN} |
|
393 | 463 |
|
464 |
||
208 | 465 |
\subsubsection{Requirements} |
393 | 466 |
|
208 | 467 |
Cygwin have to be installed with those packages : |
468 |
||
469 |
\begin{enumerate} |
|
393 | 470 |
\item gcc |
471 |
\item unzip |
|
472 |
\item wget |
|
473 |
\item make |
|
208 | 474 |
\end{enumerate} |
475 |
Currently, the only supported CAN devices are PeakSystems ones, with |
|
393 | 476 |
PcanLight driver and library. |
477 |
||
478 |
Please download driver at \href{http://www.peak-system.com/themen/download_gb.html}{http://www.peak |
|
479 |
-system.com/themen/download\_gb.html} \ and follow instructions |
|
480 |
in order to install driver on your system. |
|
208 | 481 |
|
482 |
Install Cygwin as required, and the driver for your Peak CAN device. |
|
483 |
||
484 |
Open a Cygwin terminal, and follow those instructions: |
|
485 |
||
393 | 486 |
|
208 | 487 |
\subsubsection{Cygwin configuration and compilation} |
393 | 488 |
|
489 |
||
490 |
\paragraph{A single node with PcanLight and Peak CAN -USB adapter} |
|
491 |
||
492 |
Download the PCAN -Light Zip file for your HW ( URL from download |
|
493 |
page ): |
|
494 |
||
495 |
\texttt{wget http://www.peak -system.com/files/usb.zip} |
|
496 |
||
497 |
Extract its content into your cygwin home (it will create a {}``Disk'' |
|
208 | 498 |
directory): |
499 |
||
393 | 500 |
\texttt{unzip usb.zip} |
501 |
||
502 |
Configure CanFestival3 providing path to the desired PcanLight implementation: |
|
503 |
||
504 |
\texttt{cd CanFestival -3} |
|
505 |
||
506 |
\texttt{export PCAN\_INCLUDE=\~{ }/Disk/PCAN -Light/Api/} |
|
507 |
||
508 |
\texttt{export PCAN\_HEADER=Pcan\_usb.h} |
|
509 |
||
510 |
\texttt{export PCAN\_LIB=\~{ }/Disk/PCAN -Light/Lib/Visual\textbackslash{} |
|
208 | 511 |
C++/Pcan\_usb.lib} |
512 |
||
393 | 513 |
\texttt{./configure -{}-can=peak\_win32} |
514 |
||
515 |
\texttt{make} |
|
516 |
||
517 |
In order to test, you have to use another CanFestival node, connect |
|
518 |
with a CAN cable. |
|
519 |
||
520 |
\texttt{cp \~{ }/Disk/PCAN -Light/Pcan\_usb.dll .} |
|
521 |
||
522 |
\texttt{./examples/TestMasterSlave/TestMasterSlave \textbackslash{}} |
|
523 |
||
524 |
\texttt{-l drivers/can\_peak\_win32/cygcan\_peak\_win32.dll \textbackslash{}} |
|
525 |
||
526 |
\texttt{-S 500K -M none} |
|
208 | 527 |
|
528 |
Then, on the other node : |
|
529 |
||
393 | 530 |
\texttt{./TestMasterSlave -l my\_driver.so -S none -M 500K} |
208 | 531 |
|
532 |
Now messages are beeing exchanged between master and slave node. |
|
533 |
||
393 | 534 |
|
535 |
\paragraph{Two nodes with PcanLight and Peak dual PCMCIA -CAN adapter} |
|
536 |
||
537 |
Download the PCAN -Light Zip file for your HW ( URL from download |
|
538 |
page ): |
|
539 |
||
540 |
\texttt{wget http://www.peak -system.com/files/pccard.zip} |
|
541 |
||
542 |
Extract its content into your cygwin home (it will create a {}``Disk'' |
|
208 | 543 |
directory): |
544 |
||
393 | 545 |
\texttt{unzip pccard.zip} |
208 | 546 |
|
547 |
The configure CanFestival3 providing path to the desired PcanLight |
|
548 |
implementation: |
|
549 |
||
393 | 550 |
\texttt{export PCAN\_INCLUDE=\~{ }/Disk/PCAN -Light/Api/} |
551 |
||
552 |
\texttt{export PCAN\_HEADER=Pcan\_pcc.h} |
|
553 |
||
554 |
\texttt{export PCAN\_LIB=\~{ }/Disk/PCAN -Light/Lib/Visual\textbackslash{} |
|
555 |
C++/Pcan\_pcc.lib} |
|
556 |
||
557 |
\texttt{export PCAN2\_HEADER=Pcan\_2pcc.h} |
|
558 |
||
559 |
\texttt{export PCAN2\_LIB=\~{ }/Disk/PCAN -Light/Lib/Visual\textbackslash{} |
|
208 | 560 |
C++/Pcan\_2pcc.lib} |
561 |
||
562 |
In order to test, just connect together both CAN ports of the PCMCIA |
|
563 |
card. Don{\textquotesingle}t forget 120ohms terminator. |
|
564 |
||
393 | 565 |
\texttt{cp \~{ }/Disk/PCAN -Light/Pcan\_pcc.dll .} |
566 |
||
567 |
\texttt{cp \~{ }/Disk/PCAN -Light/Pcan\_2pcc.dll .} |
|
568 |
||
569 |
\texttt{./examples/TestMasterSlave/TestMasterSlave \textbackslash{}} |
|
570 |
||
571 |
\texttt{-l drivers/can\_peak\_win32/cygcan\_peak\_win32.dll} |
|
208 | 572 |
|
573 |
Messages are then exchanged between master and slave node, both inside |
|
574 |
TestMasterSlave{\textquotesingle}s process. |
|
575 |
||
393 | 576 |
|
208 | 577 |
\subsection{Visual Studio C++} |
393 | 578 |
|
579 |
||
208 | 580 |
\subsubsection{Requirements} |
393 | 581 |
|
208 | 582 |
Minimal Cygwin installation is required at configuration time in order |
583 |
to create specific header files (config.h and cancfg.h). Once this |
|
584 |
files created, cygwin is not necessary any more. |
|
585 |
||
586 |
Project and solution files have been created and tested with Visual |
|
393 | 587 |
Studio Express 2005. Be sure to have installed Microsoft Platform |
588 |
SDK, as recommended at the end of Visual Studio installation. |
|
589 |
||
208 | 590 |
|
591 |
\subsubsection{Configuration with cygwin} |
|
393 | 592 |
|
593 |
Follow instructions given at \hyperlink{Cygwin configuration and compilation}{Cygwin |
|
208 | 594 |
configuration and compilation}, but do neither call make nor do tests, |
595 |
just do configuration steps. This will create headers files accordingly |
|
596 |
to your configuration parameters, and the desired CAN hardware. |
|
597 |
||
393 | 598 |
|
208 | 599 |
\subsubsection{Compilation with Visual Studio} |
393 | 600 |
|
601 |
You can either load independents {}``{*}.vcproj'' project files |
|
602 |
along your own projects in your own solution or load the provided |
|
603 |
{}``CanFestival -3.vc8.sln'' solution files directly. |
|
604 |
||
605 |
Build CanFestival -3 project first. |
|
606 |
||
208 | 607 |
|
608 |
\paragraph{PcanLight and the can\_peak\_win32 project.} |
|
393 | 609 |
|
208 | 610 |
Chosen Pcan\_xxx.lib and eventually Pcan\_2xxx.lib files must be added |
393 | 611 |
to can\_peak\_win32 \ \ project before build of the DLL. |
612 |
||
208 | 613 |
|
614 |
\subsubsection{Testing} |
|
393 | 615 |
|
616 |
Copy eventually needed dlls (ie : Pcan\_Nxxx.lib) into Release or |
|
617 |
Debug directory, and run the test program: |
|
618 |
||
619 |
\texttt{TestMasterSlave.exe -l can\_peak\_win32.dll} |
|
620 |
||
208 | 621 |
|
282 | 622 |
\subsection{MSYS} |
623 |
||
624 |
||
625 |
\subsubsection{Requirements} |
|
626 |
||
627 |
Download from : http://sourceforge.net/project/showfiles.php?group\_id=2435 |
|
628 |
||
629 |
\begin{enumerate} |
|
393 | 630 |
\item MSYS-1.0.10.exe |
631 |
\item MinGW-5.1.3.exe |
|
632 |
\item mingwPORT (which contains wget-1.9.1) |
|
282 | 633 |
\end{enumerate} |
634 |
Please download driver at http://www.peak-system.com/themen/download\_gb.html |
|
635 |
and follow instructions in order to install driver on your system. |
|
636 |
Install MSYS and MingW as required, and the driver for your Peak CAN |
|
637 |
device. Open a MSYS terminal, and follow those instructions:\\ |
|
638 |
||
639 |
||
640 |
\begin{itemize} |
|
393 | 641 |
\item extract wget-1.9.1-mingwPORT.tar.bz2 |
642 |
\item copy wget.exe in c:\textbackslash{} msys\textbackslash{} 1.0\textbackslash{} |
|
643 |
bin\textbackslash{} |
|
282 | 644 |
\item start MSYS and check the file /etc/fstab contain the line c:/MinGW |
393 | 645 |
/mingw |
282 | 646 |
\end{itemize} |
647 |
||
648 |
\subsubsection{MSYS configuration and compilation} |
|
649 |
||
393 | 650 |
Instructions for compilation are nearly the same as CYGWIN part. |
282 | 651 |
|
652 |
||
653 |
\paragraph{A single node with PcanLight and Peak CAN-USB adapter} |
|
654 |
||
655 |
Download the PCAN-Light Zip file for your HW ( URL from download page |
|
656 |
): |
|
657 |
||
393 | 658 |
\begin{quotation} |
659 |
\texttt{wget http://www.peak-system.com/files/usb.zip} |
|
660 |
\end{quotation} |
|
661 |
Extract its content into your MSYS's home (it will create a \char`\"{} |
|
662 |
Disk\char`\"{} directory): |
|
663 |
||
664 |
\begin{quotation} |
|
665 |
\texttt{unzip usb.zip} |
|
666 |
\end{quotation} |
|
282 | 667 |
Configure CanFestival3 providing path to the desired PcanLight implementation: |
668 |
||
393 | 669 |
\begin{quotation} |
282 | 670 |
\texttt{cd CanFestival-3} |
671 |
||
672 |
\texttt{export PCAN\_INCLUDE=\~{ }/Disk/PCAN-Light/Api/} |
|
673 |
||
674 |
\texttt{export PCAN\_HEADER=Pcan\_usb.h} |
|
675 |
||
676 |
\texttt{export PCAN\_LIB=\~{ }/Disk/PCAN-Light/Lib/Visual\textbackslash{} |
|
677 |
C++/Pcan\_usb.lib} |
|
678 |
||
393 | 679 |
\texttt{./configure - -can=peak\_win32} |
680 |
||
681 |
\texttt{make} |
|
682 |
\end{quotation} |
|
282 | 683 |
In order to test, you have to use another CanFestival node, connect |
684 |
with a CAN cable. |
|
685 |
||
393 | 686 |
\begin{quotation} |
282 | 687 |
\texttt{cp \~{ }/Disk/PCAN-Light/Pcan\_usb.dll .} |
688 |
||
689 |
\texttt{./examples/TestMasterSlave/TestMasterSlave \textbackslash{}} |
|
690 |
||
691 |
\texttt{-l drivers/can\_peak\_win32/cygcan\_peak\_win32.dll \textbackslash{}} |
|
692 |
||
393 | 693 |
\texttt{-S 500K -M none} |
694 |
\end{quotation} |
|
282 | 695 |
Then, on the other node : |
696 |
||
393 | 697 |
\begin{quotation} |
698 |
\texttt{./TestMasterSlave -l my\_driver.so -S none -M 500K -m 0} |
|
699 |
\end{quotation} |
|
282 | 700 |
Now messages are beeing exchanged between master and slave node. |
701 |
||
702 |
||
703 |
\paragraph{Two nodes with PcanLight and Peak dual PCMCIA-CAN adapter} |
|
704 |
||
705 |
Download the PCAN-Light Zip file for your HW ( URL from download page |
|
706 |
): |
|
707 |
||
393 | 708 |
\begin{quotation} |
709 |
\texttt{wget http://www.peak-system.com/files/pccard.zip} |
|
710 |
\end{quotation} |
|
711 |
Extract its content into your MSYS's home (it will create a \char`\"{} |
|
712 |
Disk\char`\"{} directory): |
|
713 |
||
714 |
\begin{quotation} |
|
715 |
\texttt{unzip pccard.zip} |
|
716 |
\end{quotation} |
|
282 | 717 |
The configure CanFestival3 providing path to the desired PcanLight |
393 | 718 |
implementation: |
719 |
||
720 |
\begin{quotation} |
|
282 | 721 |
\texttt{export PCAN\_INCLUDE=\~{ }/Disk/PCAN-Light/Api/} |
722 |
||
723 |
\texttt{export PCAN\_HEADER=Pcan\_pcc.h} |
|
724 |
||
725 |
\texttt{export PCAN\_LIB=\~{ }/Disk/PCAN-Light/Lib/Visual\textbackslash{} |
|
726 |
C++/Pcan\_pcc.lib} |
|
727 |
||
728 |
\texttt{export PCAN2\_HEADER=Pcan\_2pcc.h} |
|
729 |
||
730 |
\texttt{export PCAN2\_LIB=\~{ }/Disk/PCAN-Light/Lib/Visual\textbackslash{} |
|
393 | 731 |
C++/Pcan\_2pcc.lib} |
732 |
\end{quotation} |
|
282 | 733 |
In order to test, just connect together both CAN ports of the PCMCIA |
734 |
card. Don't forget 120ohms terminator. |
|
735 |
||
393 | 736 |
\begin{quotation} |
282 | 737 |
\texttt{cp\~{ }/Disk/PCAN-Light/Pcan\_pcc.dll ~.} |
738 |
||
739 |
\texttt{cp \~{ }/Disk/PCAN-Light/Pcan\_2pcc.dll ~.} |
|
740 |
||
741 |
\texttt{./examples/TestMasterSlave/TestMasterSlave \textbackslash{}} |
|
742 |
||
743 |
\texttt{-l drivers/can\_peak\_win32/cygcan\_peak\_win32.dll -m 0 -s |
|
393 | 744 |
1} |
745 |
\end{quotation} |
|
282 | 746 |
Messages are then exchanged between master and slave node, both inside |
747 |
TestMasterSlave's process. |
|
748 |
||
393 | 749 |
|
208 | 750 |
\section{Motorola HCS12} |
393 | 751 |
|
752 |
The examples have been tested on a MC9S12DG255 mounted on a Elektronikladen |
|
753 |
HCS12 T -board. |
|
754 |
||
755 |
Beware that there are few differences in the MSCAN module of the 68HC12 |
|
756 |
and HCS12 microcontroller. For a HC12, you must adapt the driver that |
|
757 |
we provide for \ the HCS12. |
|
758 |
||
759 |
For the difference MSCAN HC12/HCS12, see the Motorola application |
|
760 |
note AN2011/D. |
|
208 | 761 |
|
762 |
Configure switch: |
|
763 |
||
393 | 764 |
\texttt{-{}-target=hcs12} |
765 |
||
766 |
To do a \canopen node running on a microncontroller Motorola MC9S12DP256, |
|
208 | 767 |
you need : |
768 |
||
769 |
\begin{enumerate} |
|
393 | 770 |
\item The compiler GNU gcc for HC11, HC12, HCS12 : m6811 -elf. \\ |
771 |
Download the \textbf{release 3.1} at : \href{http://m68hc11.serveftp.org/m68hc11_pkg_rpm.php}{http://m68hc11.serveftp.org/m68hc11\_pkg\_rpm.php} |
|
772 |
\item A board with this chip. We are using the T -board from Electronikladden. |
|
773 |
\item At least about 40 kBytes of program memory. |
|
774 |
\item A tool to flash the memory. (We are using the hight cost Lauterbach |
|
775 |
debugger). |
|
208 | 776 |
\end{enumerate} |
393 | 777 |
|
208 | 778 |
\subsection{Running a HCS12 node} |
393 | 779 |
|
780 |
||
208 | 781 |
\subsubsection{Compiling Canfestival:} |
393 | 782 |
|
783 |
\texttt{./configure -{}-target=hcs12} |
|
784 |
||
208 | 785 |
|
786 |
\subsubsection{Compiling and building an example} |
|
393 | 787 |
|
788 |
Enter in the folder of an HCS12 example, |
|
789 |
||
790 |
\texttt{make all} |
|
791 |
||
208 | 792 |
|
793 |
\subsubsection{Flashing the memory :} |
|
393 | 794 |
|
795 |
Use your prefered loader ! If you are using a debugger Lauterbach, |
|
796 |
you can load the bash file : trace32\_flash\_programmer.cmm. It loads |
|
208 | 797 |
directly the elf file. |
798 |
||
393 | 799 |
|
208 | 800 |
\subsubsection{Connecting to a serial RS232 console :} |
393 | 801 |
|
208 | 802 |
Connect the portS(TxD0) of the HCS12 to a console configured at 19200 |
803 |
bauds 8N1, via a Max232 chip to adapt the electricals levels. On Linux, |
|
804 |
you can use minicom. Connecting to a console is usefull to read the |
|
805 |
messages, but not required. |
|
806 |
||
393 | 807 |
|
208 | 808 |
\subsubsection{Connecting to the CAN network :} |
393 | 809 |
|
810 |
Connect the port CAN0 (pin PM0, PM1) to the network via a CAN controller. |
|
811 |
On our board, the CAN controler is a PCA82C250 chip. |
|
812 |
||
208 | 813 |
|
814 |
\subsubsection{starting the node :} |
|
393 | 815 |
|
208 | 816 |
Press the reset of your HCS12 board. |
817 |
||
393 | 818 |
|
208 | 819 |
\section{Example and test program:} |
393 | 820 |
|
821 |
The {}``examples'' directory contains some test program you can |
|
822 |
use as example for your own developments. |
|
823 |
||
208 | 824 |
|
825 |
\subsection{TestMasterSlave} |
|
393 | 826 |
|
827 |
\texttt{{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}\ } |
|
828 |
||
829 |
\texttt{{*} \ TestMasterSlave \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
830 |
||
831 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
832 |
||
833 |
\texttt{{*} \ A simple example for PC. It does implement 2 \canopen |
|
834 |
\ \ \ \ \ {*}} |
|
835 |
||
836 |
\texttt{{*} \ nodes in the same process. A master and a slave. Both |
|
837 |
\ \ \ \ {*}} |
|
838 |
||
839 |
\texttt{{*} \ communicate together, exchanging periodically NMT, |
|
840 |
SYNC, \ {*}} |
|
841 |
||
842 |
\texttt{{*} \ SDO and PDO. Master configure heartbeat producer time |
|
843 |
\ \ \ \ {*}} |
|
844 |
||
845 |
\texttt{{*} \ at 1000 ms for slave node -id 0x02 by concise DCF. \ \ \ \ \ \ \ \ {*}} |
|
846 |
||
847 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
848 |
||
849 |
\texttt{{*} \ \ Usage: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
850 |
||
851 |
\texttt{{*} \ \ ./TestMasterSlave \ {[}OPTIONS] \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
852 |
||
853 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
854 |
||
855 |
\texttt{{*} \ \ OPTIONS: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
856 |
||
857 |
\texttt{{*} \ \ \ \ -l : Can library {[}{\textquotedbl}libcanfestival\_can\_virtual.so{\textquotedbl}] |
|
858 |
\ \ \ \ {*}} |
|
859 |
||
860 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
861 |
||
862 |
\texttt{{*} \ \ \ Slave: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
863 |
||
864 |
\texttt{{*} \ \ \ \ -s : bus name {[}{\textquotedbl}0{\textquotedbl}] |
|
865 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
866 |
||
867 |
\texttt{{*} \ \ \ \ -S : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) |
|
868 |
\ {*}} |
|
869 |
||
870 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
871 |
||
872 |
\texttt{{*} \ \ \ Master: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
873 |
||
874 |
\texttt{{*} \ \ \ \ -m : bus name {[}{\textquotedbl}1{\textquotedbl}] |
|
875 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
876 |
||
877 |
\texttt{{*} \ \ \ \ -M : 1M,500K,250K,125K,100K,50K,20K,10K,none(disable) |
|
878 |
\ {*}} |
|
879 |
||
880 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
881 |
||
882 |
\texttt{{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}} |
|
883 |
||
884 |
\bigskip{} |
|
885 |
||
886 |
||
887 |
\textsf{Notes for Concise DCF :} |
|
888 |
||
889 |
\bigskip{} |
|
890 |
||
891 |
||
892 |
\textsf{In this example, Master configure \ heartbeat producer time |
|
893 |
at 1000 ms for slave node -id 0x02 by concise DCF according DS -302 |
|
894 |
profile.} |
|
895 |
||
896 |
\textsf{Index 0x1F22 , sub -index 0x00 of the master OD, correspond |
|
897 |
to the number of entries. This equal to the maximum possible nodeId |
|
898 |
(127). Each sub -index points to the Node -ID of the device, to which |
|
899 |
the configuration belongs.} |
|
900 |
||
901 |
\bigskip{} |
|
902 |
||
903 |
||
904 |
\textsf{To add more parameters configurations to the slave, the value |
|
905 |
at sub -index 0x02 must be a binary stream (little -endian) following |
|
906 |
this structure :}\\ |
|
907 |
\textsf{ \{ (UNS32) nb of entries}\\ |
|
908 |
\textsf{ (UNS16) index parameter 1}\\ |
|
909 |
\textsf{ (UNS8) sub -index parameter 1}\\ |
|
910 |
\textsf{ (UNS32) size data parameter 1}\\ |
|
911 |
\textsf{ (DOMAIN) data parameter 1}\\ |
|
912 |
\textsf{ (UNS16) index parameter 2}\\ |
|
913 |
\textsf{ (UNS8) sub -index parameter 2}\\ |
|
914 |
\textsf{ (UNS32) size data parameter 2}\\ |
|
915 |
\textsf{ (DOMAIN) data parameter 2}\\ |
|
916 |
\textsf{ \ \ \ \ \ ....}\\ |
|
917 |
\textsf{ (UNS16) index parameter n}\\ |
|
918 |
\textsf{ (UNS8) sub -index parameter n}\\ |
|
919 |
\textsf{ (UNS32) size data parameter n}\\ |
|
920 |
\textsf{ (DOMAIN) data parameter n}\\ |
|
921 |
\textsf{ \}} |
|
922 |
||
923 |
\textsf{So the binary value stream to configure heartbeat producer |
|
924 |
time must be :}\\ |
|
925 |
\textsf{ 0100000017100002000000e803} |
|
926 |
||
927 |
\textsf{The slave node is configured just before the Master entering |
|
928 |
in Pre\_operational state.} |
|
929 |
||
208 | 930 |
|
931 |
\subsection{gene\_SYNC\_HCS12 :} |
|
393 | 932 |
|
933 |
This is a simple \canopen node that only send cyclic SYNC message. |
|
934 |
It demonstrate implementation on HCS12 based board. |
|
935 |
||
936 |
\bigskip{} |
|
937 |
||
938 |
||
939 |
||
391
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
940 |
\subsection{kerneltest :} |
7802a7d5584f
Accepted Vladimir Chren linux kernelspace port patch.
etisserant
parents:
284
diff
changeset
|
941 |
|
393 | 942 |
Example based on TestMasterSlave slightly modified to suit kernel |
943 |
space requisites. It will do the same as TestMasterSlave but in kernel |
|
944 |
space sending kernel messages (displayed by dmesg for example). It |
|
945 |
is designed as external kernel module implemented as character device. |
|
946 |
There is a shell script called 'insert.sh', which will insert the |
|
947 |
module and create a new device file /dev/canf\_ktest (used to sending |
|
948 |
commands to module). To actual sending commands you can use simple |
|
949 |
console named 'canf\_ktest\_console'. The module is dependent on a |
|
950 |
another separate module 'canfestival.ko' implementing CanOpen stack |
|
951 |
which exports requisite functions. Canfestival.ko module is then dependent |
|
952 |
on CAN card driver module, by default CAN virtual driver will be loaded. |
|
953 |
After installing modules (make install), all dependencies are solved |
|
954 |
automatically by kernel. To run the example type: \texttt{sh run.sh} |
|
955 |
It will insert required modules, start console, and after quitting |
|
956 |
console it'll remove modules from kernel. |
|
957 |
||
958 |
\bigskip{} |
|
959 |
||
960 |
||
208 | 961 |
|
962 |
\subsection{TestMasterMicroMod } |
|
393 | 963 |
|
964 |
\texttt{{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}} |
|
965 |
||
966 |
\texttt{{*} \ TestMasterMicroMod \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
967 |
||
968 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
969 |
||
970 |
\texttt{{*} \ A simple example for PC. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
971 |
||
972 |
\texttt{{*} \ A \canopen master that control a MicroMod module: \ \ \ \ \ \ \ \ \ {*}} |
|
973 |
||
974 |
\texttt{{*} \ - setup module TPDO 1 transmit type \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
975 |
||
976 |
\texttt{{*} \ - setup module RPDO 1 transmit type \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
977 |
||
978 |
\texttt{{*} \ - setup module hearbeatbeat period \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
979 |
||
980 |
\texttt{{*} \ - disable others TPDOs \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
981 |
||
982 |
\texttt{{*} \ - set state to operational \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
983 |
||
984 |
\texttt{{*} \ - send periodic SYNC \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
985 |
||
986 |
\texttt{{*} \ - send periodic RPDO 1 to Micromod (digital output) |
|
987 |
\ \ \ \ \ \ {*}} |
|
988 |
||
989 |
\texttt{{*} \ - listen Micromod{\textquotesingle}s TPDO 1 (digital |
|
990 |
input) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
991 |
||
992 |
\texttt{{*} \ - Mapping RPDO 1 bit per bit (digital input) \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
993 |
||
994 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
995 |
||
996 |
\texttt{{*} \ \ Usage: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
997 |
||
998 |
\texttt{{*} \ \ ./TestMasterMicroMod \ {[}OPTIONS] \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
999 |
||
1000 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1001 |
||
1002 |
\texttt{{*} \ \ OPTIONS: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1003 |
||
1004 |
\texttt{{*} \ \ \ \ -l : Can library {[}{\textquotedbl}libcanfestival\_can\_virtual.so{\textquotedbl}] |
|
1005 |
\ \ \ \ {*}} |
|
1006 |
||
1007 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1008 |
||
1009 |
\texttt{{*} \ \ \ Slave: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1010 |
||
1011 |
\texttt{{*} \ \ \ \ -i : Slave Node id format {[}0x01 , 0x7F] |
|
1012 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1013 |
||
1014 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1015 |
||
1016 |
\texttt{{*} \ \ \ Master: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1017 |
||
1018 |
\texttt{{*} \ \ \ \ -m : bus name {[}{\textquotedbl}1{\textquotedbl}] |
|
1019 |
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1020 |
||
1021 |
\texttt{{*} \ \ \ \ -M : 1M,500K,250K,125K,100K,50K,20K,10K \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1022 |
||
1023 |
\texttt{{*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}} |
|
1024 |
||
1025 |
\texttt{{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}} |
|
1026 |
||
208 | 1027 |
|
1028 |
\section{Developing a new node} |
|
393 | 1029 |
|
1030 |
Using provided examples as a base for your new node is generally a |
|
1031 |
good idea. You can also use the provided {*}.od files as a base for |
|
1032 |
your node object dictionary. |
|
1033 |
||
1034 |
Creating a new \canopen node implies to define the Object Dictionary |
|
1035 |
of this node. For that, developer has to provide a C file. This C |
|
1036 |
file contains the definition of all dictionary entries, and some kind |
|
1037 |
of index table that helps the stack to access some entries directly. |
|
1038 |
||
208 | 1039 |
|
1040 |
\subsection{Using Dictionary Editor GUI} |
|
393 | 1041 |
|
1042 |
The Object Dictionary Editor is a WxPython based GUI that is used |
|
1043 |
to create the C file needed to create a new \canopen node. |
|
1044 |
||
208 | 1045 |
|
1046 |
\subsubsection{Installation and usage on Linux} |
|
393 | 1047 |
|
208 | 1048 |
You first have to download and install Gnosis XML modules. This is |
1049 |
automated by a Makefile rule. |
|
1050 |
||
393 | 1051 |
\texttt{cd objdictgen} |
1052 |
||
1053 |
\texttt{make} |
|
208 | 1054 |
|
1055 |
Now start the editor. |
|
1056 |
||
393 | 1057 |
\texttt{python objdictedit.py {[}od files...]} |
1058 |
||
208 | 1059 |
|
1060 |
\subsubsection{Installation and usage on Windows} |
|
393 | 1061 |
|
208 | 1062 |
Install Python (at least version 2.4) and wxPython (at least version |
1063 |
2.6.3.2). |
|
1064 |
||
1065 |
Cygwin users can install Gnosis XML utils the same as Linux use. Just |
|
1066 |
call make. |
|
1067 |
||
393 | 1068 |
\texttt{cd objdictgen} |
1069 |
||
1070 |
\texttt{make} |
|
208 | 1071 |
|
1072 |
Others will have to download and intall Gnosis XML by hand : |
|
1073 |
||
393 | 1074 |
\texttt{Gnosis Utils:} |
1075 |
||
1076 |
\texttt{http://freshmeat.net/projects/gnosisxml/} |
|
1077 |
||
1078 |
\texttt{http://www.gnosis.cx/download/Gnosis\_Utils.More/Gnosis\_Utils |
|
1079 |
-1.2.1.win32 -py24.exe} |
|
1080 |
||
1081 |
\texttt{Get latest version.} |
|
1082 |
||
1083 |
Download CanFestival archive and uncompress it. Use windows file explorer |
|
1084 |
to go into CanFestival3\textbackslash{}objdicgten, and double -click |
|
1085 |
on objdictedit.py. |
|
1086 |
||
208 | 1087 |
|
1088 |
\subsubsection{About} |
|
393 | 1089 |
|
1090 |
The Object Dictionary editor GUI is a python application that use |
|
1091 |
the Model-View-Controller design pattern. It depends on WxPython to |
|
208 | 1092 |
display view on any supported platform. |
1093 |
||
393 | 1094 |
\begin{center} |
1095 |
\includegraphics[width=7cm]{Pictures/10000201000001FC000001E5D65E8766} |
|
1096 |
\par\end{center} |
|
1097 |
||
208 | 1098 |
|
1099 |
\subsubsection{Main view} |
|
393 | 1100 |
|
208 | 1101 |
Top list let you choose dictionary section, bottom left list is the |
1102 |
selected index in that dictionary, and bottom right list are edited |
|
393 | 1103 |
sub -indexes. |
1104 |
||
1105 |
\begin{center} |
|
1106 |
\includegraphics[width=12cm]{Pictures/10000201000003E7000001C7B0296577} |
|
1107 |
\par\end{center} |
|
1108 |
||
1109 |
\begin{center} |
|
1110 |
\includegraphics[width=3cm]{Pictures/10000000000000B6000000DF1EDD1E73} |
|
1111 |
\par\end{center} |
|
1112 |
||
1113 |
\begin{center} |
|
1114 |
\includegraphics[width=3cm]{Pictures/10000000000000AC000000C9C3F53FA6} |
|
1115 |
\par\end{center} |
|
1116 |
||
1117 |
\begin{center} |
|
1118 |
\includegraphics[width=3cm]{Pictures/100000000000006D000000A31EC8CB54} |
|
1119 |
\par\end{center} |
|
1120 |
||
1121 |
\begin{center} |
|
1122 |
\includegraphics[width=3cm]{Pictures/10000000000000AA0000006014F74635} |
|
1123 |
\par\end{center} |
|
1124 |
||
208 | 1125 |
|
1126 |
\subsubsection{New node} |
|
393 | 1127 |
|
1128 |
Edit your node name, ID and type. Choose your inherited specific profile. |
|
1129 |
||
1130 |
\begin{center} |
|
1131 |
\includegraphics[width=11cm]{Pictures/10000201000001CB0000015F4FC09B68} |
|
1132 |
\par\end{center} |
|
1133 |
||
208 | 1134 |
|
1135 |
\subsubsection{Node info} |
|
393 | 1136 |
|
208 | 1137 |
Edit your node name, ID and type. |
1138 |
||
393 | 1139 |
\begin{center} |
1140 |
\includegraphics[width=7cm]{Pictures/10000201000001010000011DA724D25C} |
|
1141 |
\par\end{center} |
|
1142 |
||
208 | 1143 |
|
1144 |
\subsubsection{Profile editor} |
|
393 | 1145 |
|
1146 |
Chose the used profile to edit. |
|
1147 |
||
1148 |
\begin{center} |
|
1149 |
\includegraphics[width=4cm]{Pictures/10000000000000AB000000C88F594413} |
|
1150 |
\par\end{center} |
|
1151 |
||
1152 |
Pick up optional chosen profile entries. |
|
1153 |
||
1154 |
\begin{center} |
|
1155 |
\includegraphics[width=11cm]{Pictures/10000201000002DE000001D82D89C224} |
|
1156 |
\par\end{center} |
|
1157 |
||
208 | 1158 |
|
1159 |
\subsubsection{User types} |
|
393 | 1160 |
|
1161 |
Use User Types to implement value boundaries, and string lentgth |
|
1162 |
||
1163 |
\begin{center} |
|
1164 |
\includegraphics[width=11cm]{Pictures/10000201000001C40000010766961D7F} |
|
1165 |
\par\end{center} |
|
1166 |
||
208 | 1167 |
|
1168 |
\subsubsection{Mapped variable} |
|
393 | 1169 |
|
1170 |
Add your own specific dictionary entries and associated mapped variables. |
|
1171 |
||
1172 |
\begin{center} |
|
1173 |
\includegraphics[width=11cm]{Pictures/10000201000001C4000000DD129D4661} |
|
1174 |
\par\end{center} |
|
1175 |
||
208 | 1176 |
|
1177 |
\subsubsection{Integrated help} |
|
393 | 1178 |
|
1179 |
Using F1 key, you can get context sensitive help. |
|
1180 |
||
1181 |
\begin{center} |
|
1182 |
\includegraphics[width=12cm]{Pictures/10000201000002F30000020B23ED7F67} |
|
1183 |
\par\end{center} |
|
208 | 1184 |
|
1185 |
In order to do that, official 301\_v04000201.pdf file must be placed |
|
1186 |
into doc/ directory, and xpdf must be present on your system. |
|
1187 |
||
393 | 1188 |
F2 key open HTML CanFestival help. |
1189 |
||
1190 |
\begin{center} |
|
1191 |
\includegraphics[width=12cm]{Pictures/10000201000003440000025ACC3FD2F1} |
|
1192 |
\par\end{center} |
|
1193 |
||
208 | 1194 |
|
1195 |
\subsection{Generating the object Dictionary} |
|
393 | 1196 |
|
208 | 1197 |
Once object dictionary has been edited and saved, you have to generate |
1198 |
object dictionary C code for your CanFestival node. |
|
1199 |
||
393 | 1200 |
|
208 | 1201 |
\subsubsection{With GUI} |
393 | 1202 |
|
1203 |
Menu entry {}``File/Build Dictionary''. |
|
1204 |
||
1205 |
\begin{center} |
|
1206 |
\includegraphics[width=4cm]{Pictures/10000201000000B7000000C66AF89CD5} |
|
1207 |
\par\end{center} |
|
208 | 1208 |
|
1209 |
Choose C file to create or overwrite. Header file will be also created |
|
1210 |
with the same prefix as C file. |
|
1211 |
||
393 | 1212 |
|
208 | 1213 |
\subsubsection{With command line} |
393 | 1214 |
|
1215 |
\texttt{Usage of objdictgen.py :} |
|
1216 |
||
1217 |
\texttt{python objdictgen.py XMLFilePath CfilePath} |
|
1218 |
||
208 | 1219 |
|
1220 |
\section{FAQ} |
|
393 | 1221 |
|
1222 |
||
208 | 1223 |
\subsection{General} |
393 | 1224 |
|
1225 |
||
208 | 1226 |
\subsubsection{Does the code compiles on Windows ?} |
393 | 1227 |
|
1228 |
Yes, with both Cygwin and Visual Studio C++. |
|
1229 |
||
1230 |
Because \canopen layer is coded with C, put a compilation option |
|
1231 |
/TC or /TP if you plan to mix C++ files. See the MSDN documentation |
|
1232 |
about that. |
|
1233 |
||
1234 |
||
1235 |
\subsubsection{How to fit the library to an other microcontrôler ?} |
|
1236 |
||
1237 |
First, be sure that you have at least 40K bytes of program memory, |
|
1238 |
and about 2k of RAM. |
|
1239 |
||
1240 |
You have to create target specific interface to HW resources. Take |
|
1241 |
model on bundled interfaces provided in drivers/ and create your own |
|
1242 |
interface. You also have to update Makefile.in files for target specific |
|
1243 |
cflags and options. Choose {--}target= configure switch to compile |
|
1244 |
your specific interface. |
|
1245 |
||
1246 |
You are welcome to contribute -back your own interfaces! Other Canfestival |
|
1247 |
users will use it and provide feedback, tests and enhancements. |
|
1248 |
||
208 | 1249 |
|
1250 |
\subsubsection{Is CanFestival3 conform to DS301 v.4.02 ?} |
|
393 | 1251 |
|
208 | 1252 |
Thanks to Philippe Foureys (IUT of Valence), a slave node have been |
393 | 1253 |
tested with the National Instrument \canopen Conformance Test. It |
1254 |
passed the test with success. |
|
208 | 1255 |
|
1256 |
Some very small unconformity have been found in very unusual situations, |
|
1257 |
for example in the SDO code response to wrong messages. |
|
1258 |
||
393 | 1259 |
|
208 | 1260 |
\subsection{LINUX} |
393 | 1261 |
|
1262 |
||
208 | 1263 |
\subsubsection{How to use a Peaksystem CAN board ?} |
393 | 1264 |
|
1265 |
Just install peak driver and then compile and install Canfestival. |
|
1266 |
Peak driver is detected at compile time. |
|
1267 |
||
208 | 1268 |
|
1269 |
\subsubsection{How to use an unsupported CAN board ?} |
|
393 | 1270 |
|
208 | 1271 |
You have to install the specific driver on your system, with necessary |
393 | 1272 |
libs and headers. |
1273 |
||
1274 |
Use can\_peak.c/h or can\_virtual.c/h as an example, and adapt it |
|
1275 |
to your driver API. |
|
1276 |
||
1277 |
Execute configure script and choose --can=mydriver |
|
1278 |
||
208 | 1279 |
|
1280 |
\subsection{Win32} |
|
393 | 1281 |
|
208 | 1282 |
Compatibility: |
1283 |
||
1284 |
\begin{enumerate} |
|
393 | 1285 |
\item Code was compiled MS VisualStudio 2003.NET and VisualStudio 2005.NET |
1286 |
for WindowsXP \ with ANSI and UNICODE configurations and for WindowsCE |
|
1287 |
5.0. |
|
1288 |
\item Some preliminary testing was done, but not enough to be used in mission |
|
1289 |
critical projects. |
|
208 | 1290 |
\end{enumerate} |
1291 |
Additional Features: |
|
1292 |
||
1293 |
\begin{enumerate} |
|
393 | 1294 |
\item Non -integral integers support implementation UNS24, UNS40, UNS48 |
1295 |
etc. |
|
1296 |
\item When enable debug output with DEBUG\_WAR\_CONSOLE\_ON or DEBUG\_ERR\_CONSOLE\_ON, |
|
1297 |
you can navigate in CanFestival source code by double clicking at |
|
1298 |
diagnostic lines in VisualStudio.NET 200X Debug Output Window. |
|
208 | 1299 |
\end{enumerate} |
393 | 1300 |
Custom size integral types such as INTEGER24, UNS40, INTEGER56 etc. |
1301 |
have been defined as 64 bits integers. You will need to replace sizeof(TYPE) |
|
208 | 1302 |
operators to sizeof\_TYPE definitions in generated code, i.e. replace |
1303 |
sizeof(UNS40) with sizeof\_UNS40. |
|
1304 |
||
1305 |
||
1306 |
\subsection{HCS12} |
|
393 | 1307 |
|
1308 |
||
208 | 1309 |
\subsubsection{Which board are you using ?} |
393 | 1310 |
|
1311 |
A T -board from elektronikladen with a MC9S12DP256 or MC9S12DG256. |
|
1312 |
||
1313 |
||
1314 |
\subsubsection{Does the code compile with an other compiler than GNU gcc ?} |
|
1315 |
||
1316 |
It is known to work with Metrowerks CodeWarrior. Here are some tips |
|
1317 |
from Philippe Foureys. : |
|
1318 |
||
208 | 1319 |
|
1320 |
\paragraph{Interrupt functions} |
|
393 | 1321 |
|
1322 |
||
208 | 1323 |
\subparagraph{Code for GCC:} |
393 | 1324 |
|
1325 |
\texttt{// prototype}~\\ |
|
1326 |
\texttt{ void \_\_attribute\_\_((interrupt))timer3Hdl(void):}~\\ |
|
1327 |
\texttt{ // function}~\\ |
|
1328 |
\texttt{ void \_\_attribute\_\_((interrupt))timer3Hdl(void)\{...\}} |
|
1329 |
||
208 | 1330 |
|
1331 |
\subparagraph{Code for CodeWarrior} |
|
393 | 1332 |
|
1333 |
\texttt{// protoype}~\\ |
|
1334 |
\texttt{ void interrupt timer3Hdl(void);}~\\ |
|
1335 |
\texttt{ // function}~\\ |
|
1336 |
\texttt{ pragma CODE\_SEG\_\_NEAR\_SEG\_NON\_BANKED}~\\ |
|
1337 |
\texttt{ void interrupt timer3Hdl(void)}~\\ |
|
1338 |
\texttt{ \{...\}}~\\ |
|
1339 |
\texttt{ pragma CODE\_SEG\_DEFAULT} |
|
1340 |
||
208 | 1341 |
|
1342 |
\paragraph{Interrupt lock, unlock} |
|
393 | 1343 |
|
1344 |
||
208 | 1345 |
\subparagraph{Code for GCC} |
393 | 1346 |
|
1347 |
\texttt{void unlock (void)}~\\ |
|
1348 |
\texttt{ \ }~\\ |
|
1349 |
\texttt{ \ \_\_asm\_\_ \_\_volatile\_\_({\textquotedbl}cli{\textquotedbl});}~\\ |
|
1350 |
\texttt{ \}}~\\ |
|
1351 |
\texttt{ void lock (void)}~\\ |
|
1352 |
\texttt{ \ }~\\ |
|
1353 |
\texttt{ \ unsigned short mask;}~\\ |
|
1354 |
\texttt{ \ \_\_asm\_\_ \_\_volatile\_\_({\textquotedbl}tpa{\textbackslash{} |
|
1355 |
}n{\textbackslash{} }tsei{\textquotedbl}:{\textquotedbl}=d{\textquotedbl}(mask));}~\\ |
|
1356 |
\texttt{ \}} |
|
1357 |
||
208 | 1358 |
|
1359 |
\subparagraph{Code for CodeWarrior} |
|
393 | 1360 |
|
1361 |
\texttt{void unlock (void)}~\\ |
|
1362 |
\texttt{ \ }~\\ |
|
1363 |
\texttt{ \ \_\_asm({\textquotedbl}cli{\textquotedbl});}~\\ |
|
1364 |
\texttt{ \}}~\\ |
|
1365 |
\texttt{ void lock (void)}~\\ |
|
1366 |
\texttt{ \ }~\\ |
|
1367 |
\texttt{ \ unsigned short mask;}~\\ |
|
1368 |
\texttt{ \ \_\_asm}~\\ |
|
1369 |
\texttt{ \ }~\\ |
|
1370 |
\texttt{ \ tpa:tsei:{\textquotedbl}=d{\textquotedbl}(mask);}~\\ |
|
1371 |
\texttt{ \}}~\\ |
|
1372 |
\texttt{ \}} |
|
1373 |
||
208 | 1374 |
|
1375 |
\paragraph{Initialize function} |
|
393 | 1376 |
|
1377 |
||
208 | 1378 |
\subparagraph{Code for GCC} |
393 | 1379 |
|
1380 |
\texttt{void initCanHCS12 (void)}~\\ |
|
1381 |
\texttt{ \{ \ }~\\ |
|
1382 |
\texttt{ \ //Init the HCS12 microcontroler for \canopen} ~\\ |
|
1383 |
\texttt{ \ initHCS12();}~\\ |
|
1384 |
\texttt{ \ \ // Init the HCS12 \ CAN driver}~\\ |
|
1385 |
\texttt{ \ const canBusInit bi0 = \ }~\\ |
|
1386 |
\texttt{ \ \ \ 0, \ \ \ /{*} no low power \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/} |
|
1387 |
~\\ |
|
1388 |
\texttt{ \ \ \ 0, \ \ \ /{*} no time stamp \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1389 |
\texttt{ \ \ \ 1, \ \ \ /{*} enable MSCAN \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1390 |
\texttt{ \ \ \ 0, \ \ \ /{*} clock source : oscillator (In |
|
1391 |
fact, it is not used) \ \ {*}/}~\\ |
|
1392 |
\texttt{ \ \ \ 0, \ \ \ /{*} no loop back \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1393 |
\texttt{ \ \ \ 0, \ \ \ /{*} no listen only \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1394 |
\texttt{ \ \ \ 0, \ \ \ /{*} no low pass filter for wk up {*}/}~\\ |
|
1395 |
\texttt{ \ CAN\_Baudrates{[}CAN\_BAUDRATE\_250K],}~\\ |
|
1396 |
\texttt{ \ \ \ \ }~\\ |
|
1397 |
\texttt{ \ \ \ \ \ 0x00, \ \ \ /{*} Filter on 16 bits.}~\\ |
|
1398 |
\texttt{ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ See Motorola |
|
1399 |
Block Guide V02.14 fig 4 -3 {*}/}~\\ |
|
1400 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 0 hight accept all |
|
1401 |
msg \ \ \ \ \ {*}/}~\\ |
|
1402 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 0 low accept all |
|
1403 |
msg \ \ \ \ \ \ \ {*}/}~\\ |
|
1404 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 1 hight filter all |
|
1405 |
of \ msg \ {*}/}~\\ |
|
1406 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 1 low filter all |
|
1407 |
of \ msg \ \ \ {*}/}~\\ |
|
1408 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 2 hight filter most |
|
1409 |
of \ msg {*}/}~\\ |
|
1410 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 2 low filter most |
|
1411 |
of \ msg \ \ {*}/}~\\ |
|
1412 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 3 hight filter most |
|
1413 |
of \ msg {*}/}~\\ |
|
1414 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 3 low filter most |
|
1415 |
of \ msg \ \ {*}/}~\\ |
|
1416 |
\texttt{ \ \ \ \}}~\\ |
|
1417 |
\texttt{ \ \};} |
|
1418 |
||
208 | 1419 |
|
1420 |
\subparagraph{Code for CodeWarrior} |
|
393 | 1421 |
|
1422 |
\texttt{void initCanHCS12 (void)}~\\ |
|
1423 |
\texttt{ \{ \ }~\\ |
|
1424 |
\texttt{ \ //Init the HCS12 microcontroler for \canopen} ~\\ |
|
1425 |
\texttt{ \ initHCS12();}~\\ |
|
1426 |
\texttt{ \ \ // Init the HCS12 \ CAN driver}~\\ |
|
1427 |
\texttt{ \ const canBusInit bi0 = \ }~\\ |
|
1428 |
\texttt{ \ \ \ 0, \ \ \ /{*} no low power \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/} |
|
1429 |
~\\ |
|
1430 |
\texttt{ \ \ \ 0, \ \ \ /{*} no time stamp \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1431 |
\texttt{ \ \ \ 1, \ \ \ /{*} enable MSCAN \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1432 |
\texttt{ \ \ \ 0, \ \ \ /{*} clock source : oscillator (In |
|
1433 |
fact, it is not used) \ \ {*}/}~\\ |
|
1434 |
\texttt{ \ \ \ 0, \ \ \ /{*} no loop back \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1435 |
\texttt{ \ \ \ 0, \ \ \ /{*} no listen only \ \ \ \ \ \ \ \ \ \ \ \ \ \ {*}/}~\\ |
|
1436 |
\texttt{ \ \ \ 0, \ \ \ /{*} no low pass filter for wk up {*}/}~\\ |
|
1437 |
\texttt{ \ \ \ \ }~\\ |
|
1438 |
\texttt{ \ \ \ \ 1, /{*} clksrc {*}/}~\\ |
|
1439 |
\texttt{ \ \ \ \ 3, /{*} brp \ \ \ {*}/}~\\ |
|
1440 |
\texttt{ \ \ \ \ 0, /{*} sjw \ \ \ {*}/}~\\ |
|
1441 |
\texttt{ \ \ \ \ 0, /{*} samp \ \ {*}/}~\\ |
|
1442 |
\texttt{ \ \ \ \ 1, /{*} tseg2 \ {*}/}~\\ |
|
1443 |
\texttt{ \ \ \ \ 12,/{*} tseg1 \ {*}/}~\\ |
|
1444 |
\texttt{ \ \ \ \},}~\\ |
|
1445 |
\texttt{ \ \ \ \ }~\\ |
|
1446 |
\texttt{ \ \ \ \ \ 0x00, \ \ \ /{*} Filter on 16 bits.}~\\ |
|
1447 |
\texttt{ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ See Motorola |
|
1448 |
Block Guide V02.14 fig 4 -3 {*}/}~\\ |
|
1449 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 0 hight accept all |
|
1450 |
msg \ \ \ \ \ {*}/}~\\ |
|
1451 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 0 low accept all |
|
1452 |
msg \ \ \ \ \ \ \ {*}/}~\\ |
|
1453 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 1 hight filter all |
|
1454 |
of \ msg \ {*}/}~\\ |
|
1455 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 1 low filter all |
|
1456 |
of \ msg \ \ \ {*}/}~\\ |
|
1457 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 2 hight filter most |
|
1458 |
of \ msg {*}/}~\\ |
|
1459 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 2 low filter most |
|
1460 |
of \ msg \ \ {*}/}~\\ |
|
1461 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 3 hight filter most |
|
1462 |
of \ msg {*}/}~\\ |
|
1463 |
\texttt{ \ \ \ \ \ 0x00, 0xFF, /{*} filter 3 low filter most |
|
1464 |
of \ msg \ \ {*}/}~\\ |
|
1465 |
\texttt{ \ \ \ \}}~\\ |
|
1466 |
\texttt{ \ \};} |
|
1467 |
||
208 | 1468 |
|
1469 |
\subsubsection{Does the code works in banked memory ?} |
|
393 | 1470 |
|
208 | 1471 |
No. Today it seems that the port of gcc is bogged for using the banked |
1472 |
memory. So, unfortunately, we are limited to 48 Kbytes of memory code. |
|
1473 |
||
393 | 1474 |
|
208 | 1475 |
\subsubsection{What GCC version are you using ?} |
393 | 1476 |
|
208 | 1477 |
We are using the stable RPM release 2.2 : |
1478 |
||
1479 |
\begin{enumerate} |
|
393 | 1480 |
\item GNU Gcc 3.0.4. Build 20030501 |
1481 |
\item Newlib 1.10.0 Build 20030421 |
|
1482 |
\item GNU Binutils 2.12.1 Build 20030427 |
|
208 | 1483 |
\end{enumerate} |
393 | 1484 |
|
1485 |
\section{Documentation resources} |
|
1486 |
||
1487 |
||
1488 |
\paragraph{CIA : Can in Automation } |
|
1489 |
||
1490 |
\href{http://www.can-cia.de/}{http://www.can -cia.de} |
|
1491 |
||
1492 |
||
1493 |
\paragraph{Resources and training in \canopen } |
|
1494 |
||
208 | 1495 |
\href{http://www.esacademy.com/}{http://www.esacademy.com} |
1496 |
||
393 | 1497 |
|
1498 |
\paragraph{Elektronikladen HCS12 T -board } |
|
1499 |
||
208 | 1500 |
\href{http://www.elektronikladen.de/en_hcs12tb.html}{http://www.elektronikladen.de/en\_hcs12tb.html} |
1501 |
||
393 | 1502 |
|
1503 |
\paragraph{Gnu gcc compiler for HC12} |
|
1504 |
||
208 | 1505 |
\href{http://m68hc11.serveftp.org/m68hc11_port.php}{http://m68hc11.serveftp.org/m68hc11\_port.php} |
1506 |
||
393 | 1507 |
|
1508 |
\paragraph{Motorola documentation on HC12 } |
|
1509 |
||
208 | 1510 |
\href{http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MC9S12DP256}{http://www.freescale.com/webapp/sps/site/prod\_summary.jsp?code=MC9S12DP256} |
1511 |
||
393 | 1512 |
|
1513 |
\paragraph{Lauterbach debugger for HC12 } |
|
1514 |
||
208 | 1515 |
\href{http://www.lauterbach.com/}{http://www.lauterbach.com} |
1516 |
||
393 | 1517 |
|
1518 |
\paragraph{Python language } |
|
1519 |
||
208 | 1520 |
\href{http://www.python.org/}{http://www.python.org} |
1521 |
||
393 | 1522 |
\clearpage{} |
1523 |
||
1524 |
||
1525 |
\section{About the project} |
|
1526 |
||
1527 |
||
208 | 1528 |
\subsection{Contributors } |
393 | 1529 |
|
1530 |
\begin{center} |
|
1531 |
\includegraphics[width=10cm]{Pictures/1000020100000258000000832C6FFAB4} |
|
1532 |
\par\end{center} |
|
1533 |
||
1534 |
Unité mixte de recherche INRETS -LCPC |
|
1535 |
||
1536 |
sur les Interractions Véhicule -Infrastructure -Conducteur |
|
1537 |
||
1538 |
14, route de la miničre |
|
208 | 1539 |
|
1540 |
78000 Versailles |
|
1541 |
||
1542 |
FRANCE |
|
1543 |
||
1544 |
Tel : +33 1 40 43 29 01 |
|
1545 |
||
1546 |
\href{http://www.inrets.fr/ur/livic}{http://www.inrets.fr/ur/livic} |
|
1547 |
||
1548 |
\textbf{Contributors :} Francis DUPIN |
|
1549 |
||
393 | 1550 |
Camille BOSSARD |
1551 |
||
1552 |
Laurent ROMIEUX |
|
1553 |
||
1554 |
\bigskip{} |
|
1555 |
||
1556 |
||
1557 |
\begin{center} |
|
1558 |
\includegraphics[width=10cm]{Pictures/100002010000013A0000004A96B0C1FF} |
|
1559 |
\par\end{center} |
|
208 | 1560 |
|
1561 |
LOLITECH |
|
1562 |
||
1563 |
204, rue du Haut du Pin |
|
1564 |
||
393 | 1565 |
88470 Saint -Michel sur Meurthe |
208 | 1566 |
|
1567 |
FRANCE |
|
1568 |
||
1569 |
Tel : +33 3 29 52 95 67 |
|
1570 |
||
1571 |
\href{http://www.lolitech.fr/}{http://www.lolitech.fr} |
|
1572 |
||
393 | 1573 |
\textbf{Contributors :} Edouard TISSERANT (Original author) |
1574 |
||
1575 |
Laurent BESSARD |
|
1576 |
||
1577 |
\bigskip{} |
|
1578 |
||
208 | 1579 |
|
1580 |
Many thanks to the other contributors for their great work: |
|
1581 |
||
393 | 1582 |
Raphael ZULLIGER |
1583 |
||
1584 |
David DUMINY (sté A6R) |
|
1585 |
||
1586 |
Zakaria BELAMRI |
|
1587 |
||
208 | 1588 |
|
1589 |
\subsection{Getting support} |
|
393 | 1590 |
|
1591 |
Send your feedback and bug reports to \href{mailto:canfestival-devel@lists.sourceforge.net}{canfestival-devel@lists.sourceforge.net}. |
|
1592 |
||
1593 |
For commercial support, \ training and specific integration and developments, |
|
1594 |
please ask LOLITECH (see contributors). |
|
1595 |
||
208 | 1596 |
|
1597 |
\subsection{Contributing} |
|
393 | 1598 |
|
208 | 1599 |
You are free to contribute your specific interfaces back to the project. |
1600 |
This way, you can hope to get support from CanFestival users community. |
|
1601 |
||
393 | 1602 |
Please send your patch to \href{mailto:canfestival-devel@lists.sourceforge.net}{canfestival |
1603 |
-devel@lists.sourceforge.net}. |
|
1604 |
||
1605 |
Feel free to create some new predefined DS -4xx profiles ({*}.prf) |
|
1606 |
in objdictgen/config, as much as possible respectful to the official |
|
208 | 1607 |
specifications. |
1608 |
||
393 | 1609 |
|
208 | 1610 |
\subsection{License} |
393 | 1611 |
|
1612 |
All the project is licensed with LGPL. This mean you can link CanFestival |
|
1613 |
with any code without being obliged to publish it. |
|
1614 |
||
1615 |
\texttt{\#This file is part of CanFestival, a library implementing |
|
1616 |
\canopen Stack.} |
|
1617 |
||
1618 |
\texttt{\#} |
|
1619 |
||
1620 |
\texttt{\#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent |
|
1621 |
BESSARD} |
|
1622 |
||
1623 |
\texttt{\#} |
|
1624 |
||
1625 |
\texttt{\#See COPYING file for copyrights details.} |
|
1626 |
||
1627 |
\texttt{\#} |
|
1628 |
||
1629 |
\texttt{\#This library is free software; you can redistribute it and/or} |
|
1630 |
||
1631 |
\texttt{\#modify it under the terms of the GNU Lesser General Public} |
|
1632 |
||
1633 |
\texttt{\#License as published by the Free Software Foundation; either} |
|
1634 |
||
1635 |
\texttt{\#version 2.1 of the License, or (at your option) any later |
|
1636 |
version.} |
|
1637 |
||
1638 |
\texttt{\#} |
|
1639 |
||
1640 |
\texttt{\#This library is distributed in the hope that it will be |
|
1641 |
useful,} |
|
1642 |
||
1643 |
\texttt{\#but WITHOUT ANY WARRANTY; without even the implied warranty |
|
1644 |
of} |
|
1645 |
||
1646 |
\texttt{\#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
|
1647 |
the GNU} |
|
1648 |
||
1649 |
\texttt{\#Lesser General Public License for more details.} |
|
1650 |
||
1651 |
\texttt{\#} |
|
1652 |
||
1653 |
\texttt{\#You should have received a copy of the GNU Lesser General |
|
1654 |
Public} |
|
1655 |
||
1656 |
\texttt{\#License along with this library; if not, write to the Free |
|
1657 |
Software} |
|
1658 |
||
1659 |
\texttt{\#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
1660 |
\ 02111 -1307 \ USA} |
|
208 | 1661 |
\end{document} |