]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - examples/kerneltest/Slave.c
Accepted Vladimir Chren linux kernelspace port patch.
[CanFestival-3.git] / examples / kerneltest / Slave.c
1 /*
2 This file is part of CanFestival, a library implementing CanOpen Stack. 
3
4 Copyright (C): Edouard TISSERANT and Francis DUPIN
5
6 See COPYING file for copyrights details.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 */
22
23 #include "Slave.h"
24 #include "Master.h"
25 #include "TestMasterSlave.h"
26 #include "can_driver.h"
27
28 extern s_BOARD SlaveBoard;
29 /*****************************************************************************/
30 void TestSlave_heartbeatError(CO_Data* d, UNS8 heartbeatID)
31 {
32         eprintf("TestSlave_heartbeatError %d\n", heartbeatID);
33 }
34
35 void TestSlave_initialisation(CO_Data* d)
36 {
37         eprintf("TestSlave_initialisation\n");
38 }
39
40 void TestSlave_preOperational(CO_Data* d)
41 {
42         eprintf("TestSlave_preOperational\n");
43 }
44
45 void TestSlave_operational(CO_Data* d)
46 {
47         eprintf("TestSlave_operational\n");
48 }
49
50 void TestSlave_stopped(CO_Data* d)
51 {
52         eprintf("TestSlave_stopped\n");
53 }
54
55 void TestSlave_post_sync(CO_Data* d)
56 {
57       eprintf("TestSlave_post_sync\n");
58       
59       SlaveMap1=1;
60       SlaveMap2=1;
61       SlaveMap3=0;
62       SlaveMap4=0;
63       SlaveMap5=1;
64       SlaveMap6=0;
65       SlaveMap7=1;
66       SlaveMap8=0;
67       SlaveMap9=16;
68       SlaveMap10 = 0xff00ff00;
69       SlaveMap11 = 0xabcd;
70       SlaveMap12 += SlaveMap12 > 0x80 ? 0 : 1;
71       eprintf("Slave: %d %d %d %d %d %d %d %d %d %x %x %d %d \n",
72         SlaveMap1, 
73         SlaveMap2, 
74         SlaveMap3, 
75         SlaveMap4, 
76         SlaveMap5, 
77         SlaveMap6, 
78         SlaveMap7, 
79         SlaveMap8, 
80         SlaveMap9, 
81         SlaveMap10,
82         SlaveMap11, 
83         SlaveMap12,
84         SlaveMap13);
85 }
86
87 void TestSlave_post_TPDO(CO_Data* d)
88 {
89         SlaveMap13 += 1;
90         eprintf("TestSlave_post_TPDO\n");
91         
92         /* send an error and recover inmediately every 12 cycles */
93         if(SlaveMap13 % 12 == 0)
94         {
95                 EMCY_setError(&TestSlave_Data, 0x4200, 0x08, 0x0000);
96                 EMCY_errorRecovered(&TestSlave_Data, 0x4200);
97         }
98 }
99
100 void TestSlave_storeODSubIndex(CO_Data* d, UNS16 wIndex, UNS8 bSubindex)
101 {
102         /*TODO : 
103          * - call getODEntry for index and subindex, 
104          * - save content to file, database, flash, nvram, ...
105          * 
106          * To ease flash organisation, index of variable to store
107          * can be established by scanning d->objdict[d->ObjdictSize]
108          * for variables to store.
109          * 
110          * */
111         eprintf("TestSlave_storeODSubIndex : %4.4x %2.2x\n", wIndex,  bSubindex);
112 }
113
114 void TestSlave_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
115 {
116         eprintf("Slave received EMCY message. Node: %2.2x  ErrorCode: %4.4x  ErrorRegister: %2.2x\n", nodeID, errCode, errReg);
117 }