]> rtime.felk.cvut.cz Git - CanFestival-3.git/blob - examples/TestMasterSlave/Master.c
Changes in the API:
[CanFestival-3.git] / examples / TestMasterSlave / Master.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 "Master.h"
24 #include "Slave.h"
25 #include "TestMasterSlave.h"
26
27 /*****************************************************************************/
28 void TestMaster_heartbeatError(UNS8 heartbeatID)
29 {
30         eprintf("TestMaster_heartbeatError %d\n", heartbeatID);
31 }
32
33 /*****************************************************************************/
34 void TestMaster_SDOtimeoutError (UNS8 line)
35 {
36         eprintf("TestMaster_SDOtimeoutError %d\n", line);
37 }
38
39 /*****************************************************************************/
40 void TestMaster_initialisation()
41 {
42         eprintf("TestMaster_initialisation\n");
43 }
44
45 void TestMaster_preOperational()
46 {
47         eprintf("TestMaster_preOperational\n");
48 }
49
50 void TestMaster_operational()
51 {
52         eprintf("TestMaster_operational\n");
53 }
54
55 void TestMaster_stopped()
56 {
57         eprintf("TestMaster_stopped\n");
58 }
59
60 void TestMaster_post_sync()
61 {
62         eprintf("TestMaster_post_sync\n");
63         eprintf("Master: %d %d %d %d\n",MasterMap1, MasterMap2, MasterMap3, MasterMap4);
64 }
65
66 char query_result = 0;
67 char waiting_answer = 0;
68
69 void TestMaster_post_TPDO()
70 {
71         eprintf("TestMaster_post_TPDO\n");
72
73 //      {
74 //              char zero = 0;
75 //              if(MasterMap4 > 0x80){
76 //                      writeNetworkDict (
77 //                              &TestMaster_Data,
78 //                              TestSlave_Data->bDeviceNodeId,
79 //                              0x2002,
80 //                              0x00,
81 //                              1,
82 //                              0,
83 //                              &zero); 
84 //              }
85 //      }
86
87         if(waiting_answer){
88                 UNS32 abortCode;                        
89                 UNS8 size;                      
90                 switch(getReadResultNetworkDict (
91                         &TestMaster_Data, 
92                         *TestSlave_Data.bDeviceNodeId,
93                         &query_result,
94                         &size,
95                         &abortCode))
96                 {
97                         case SDO_FINISHED:
98                                 /* Do something with result here !!*/
99                                 eprintf("Got SDO answer (0x2002, 0x00), %d %d\n",query_result,size);
100                         case SDO_ABORTED_RCV:
101                         case SDO_ABORTED_INTERNAL:
102                         case SDO_RESET:
103                                 waiting_answer = 0;
104                                 closeSDOtransfer(
105                                         &TestMaster_Data,
106                                         *TestSlave_Data.        bDeviceNodeId,
107                                         SDO_CLIENT);
108                         break;
109                         case SDO_DOWNLOAD_IN_PROGRESS:
110                         case SDO_UPLOAD_IN_PROGRESS:
111                         break;
112                 }
113         }else if(MasterMap1 % 10 == 0){
114                 readNetworkDict (
115                         &TestMaster_Data,
116                         *TestSlave_Data.bDeviceNodeId,
117                         0x2002,
118                         0x00,
119                         0);
120                 waiting_answer = 1;
121         }
122                 
123 }