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