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